Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_phys.h
Show All 36 Lines | |||||
* Physical memory system definitions | * Physical memory system definitions | ||||
*/ | */ | ||||
#ifndef _VM_PHYS_H_ | #ifndef _VM_PHYS_H_ | ||||
#define _VM_PHYS_H_ | #define _VM_PHYS_H_ | ||||
#ifdef _KERNEL | #ifdef _KERNEL | ||||
#ifndef VM_NFREEORDER_MAX | extern vm_paddr_t phys_avail[]; | ||||
#define VM_NFREEORDER_MAX VM_NFREEORDER | |||||
#endif | |||||
extern vm_paddr_t phys_avail[PHYS_AVAIL_COUNT]; | |||||
/* Domains must be dense (non-sparse) and zero-based. */ | /* Domains must be dense (non-sparse) and zero-based. */ | ||||
struct mem_affinity { | struct mem_affinity { | ||||
vm_paddr_t start; | vm_paddr_t start; | ||||
vm_paddr_t end; | vm_paddr_t end; | ||||
int domain; | int domain; | ||||
}; | }; | ||||
#ifdef NUMA | #ifdef NUMA | ||||
extern struct mem_affinity *mem_affinity; | extern struct mem_affinity *mem_affinity; | ||||
extern int *mem_locality; | extern int *mem_locality; | ||||
#endif | #endif | ||||
struct vm_freelist { | |||||
struct pglist pl; | |||||
int lcnt; | |||||
}; | |||||
struct vm_phys_seg { | |||||
vm_paddr_t start; | |||||
vm_paddr_t end; | |||||
vm_page_t first_page; | |||||
#if VM_NRESERVLEVEL > 0 | |||||
vm_reserv_t first_reserv; | |||||
#endif | |||||
#ifdef __aarch64__ | |||||
void *md_first; | |||||
#endif | |||||
int domain; | |||||
struct vm_freelist (*free_queues)[VM_NFREEPOOL][VM_NFREEORDER_MAX]; | |||||
}; | |||||
extern struct vm_phys_seg vm_phys_segs[]; | |||||
extern int vm_phys_nsegs; | |||||
/* | /* | ||||
* The following functions are only to be used by the virtual memory system. | * The following functions are only to be used by the virtual memory system. | ||||
*/ | */ | ||||
void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end); | void vm_phys_add_seg(vm_paddr_t start, vm_paddr_t end); | ||||
vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low, | vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low, | ||||
vm_paddr_t high, u_long alignment, vm_paddr_t boundary); | vm_paddr_t high, u_long alignment, vm_paddr_t boundary); | ||||
vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool, | vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool, | ||||
int order); | int order); | ||||
Show All 17 Lines | |||||
boolean_t vm_phys_unfree_page(vm_page_t m); | boolean_t vm_phys_unfree_page(vm_page_t m); | ||||
int vm_phys_mem_affinity(int f, int t); | int vm_phys_mem_affinity(int f, int t); | ||||
void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end); | void vm_phys_early_add_seg(vm_paddr_t start, vm_paddr_t end); | ||||
vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size); | vm_paddr_t vm_phys_early_alloc(int domain, size_t alloc_size); | ||||
void vm_phys_early_startup(void); | void vm_phys_early_startup(void); | ||||
int vm_phys_avail_largest(void); | int vm_phys_avail_largest(void); | ||||
vm_paddr_t vm_phys_avail_size(int i); | vm_paddr_t vm_phys_avail_size(int i); | ||||
/* | |||||
* | |||||
* vm_phys_domain: | |||||
* | |||||
* Return the index of the domain the page belongs to. | |||||
*/ | |||||
static inline int | static inline int | ||||
vm_phys_domain(vm_page_t m) | vm_phys_domain(vm_paddr_t pa) | ||||
alc: In general, I'm a fan of longer names, especially ones that include a verb. :-) But, in this… | |||||
{ | { | ||||
#ifdef NUMA | #ifdef NUMA | ||||
int domn, segind; | int i; | ||||
/* XXXKIB try to assert that the page is managed */ | if (vm_ndomains == 1) | ||||
segind = m->segind; | return (0); | ||||
KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m)); | for (i = 0; mem_affinity[i].end != 0; i++) | ||||
domn = vm_phys_segs[segind].domain; | if (mem_affinity[i].start <= pa && | ||||
KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m)); | mem_affinity[i].end >= pa) | ||||
return (domn); | return (mem_affinity[i].domain); | ||||
return (-1); | |||||
#else | #else | ||||
return (0); | return (0); | ||||
#endif | #endif | ||||
} | } | ||||
int _vm_phys_domain(vm_paddr_t pa); | |||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* !_VM_PHYS_H_ */ | #endif /* !_VM_PHYS_H_ */ |
In general, I'm a fan of longer names, especially ones that include a verb. :-) But, in this case, I would advocate for the shorter vm_page_domain(). The only thing that the phys_ prefix does is hint at where the function is implemented. But, conceptually this is an operation on a vm_page.