arch/x86/mm/pat/memtype_interval.c

Source file repositories/reference/linux-study-clean/arch/x86/mm/pat/memtype_interval.c

File Facts

System
Linux kernel
Corpus path
arch/x86/mm/pat/memtype_interval.c
Extension
.c
Size
3792 bytes
Lines
150
Domain
Architecture Layer
Bucket
arch/x86
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (entry->start == start && entry->end == end) {
			interval_remove(entry, &memtype_rbroot);
			return entry;
		}
		entry = interval_iter_next(entry, start, end - 1);
	}
	return ERR_PTR(-EINVAL);
}

struct memtype *memtype_lookup(u64 addr)
{
	return interval_iter_first(&memtype_rbroot, addr, addr + PAGE_SIZE-1);
}

/*
 * Debugging helper, copy the Nth entry of the tree into a
 * a copy for printout. This allows us to print out the tree
 * via debugfs, without holding the memtype_lock too long:
 */
#ifdef CONFIG_DEBUG_FS
int memtype_copy_nth_element(struct memtype *entry_out, loff_t pos)
{
	struct memtype *entry_match;
	int i = 1;

	entry_match = interval_iter_first(&memtype_rbroot, 0, ULONG_MAX);

	while (entry_match && pos != i) {
		entry_match = interval_iter_next(entry_match, 0, ULONG_MAX);
		i++;
	}

	if (entry_match) { /* pos == i */
		*entry_out = *entry_match;
		return 0;
	} else {
		return 1;
	}
}
#endif

Annotation

Implementation Notes