Changeset View
Changeset View
Standalone View
Standalone View
vm/vm_phys.h
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | |||||
extern int vm_ndomains; | extern int vm_ndomains; | ||||
extern struct vm_phys_seg vm_phys_segs[]; | extern struct vm_phys_seg vm_phys_segs[]; | ||||
extern int vm_phys_nsegs; | 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(u_long npages, vm_paddr_t low, vm_paddr_t high, | vm_page_t vm_phys_alloc_contig(int domain, u_long npages, vm_paddr_t low, | ||||
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 freelist, int pool, int order); | vm_page_t vm_phys_alloc_freelist_pages(int domain, int freelist, int pool, | ||||
vm_page_t vm_phys_alloc_pages(int pool, int order); | int order); | ||||
vm_page_t vm_phys_alloc_pages(int domain, int pool, int order); | |||||
boolean_t vm_phys_domain_intersects(long mask, vm_paddr_t low, vm_paddr_t high); | boolean_t vm_phys_domain_intersects(long mask, vm_paddr_t low, vm_paddr_t high); | ||||
int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, | int vm_phys_fictitious_reg_range(vm_paddr_t start, vm_paddr_t end, | ||||
vm_memattr_t memattr); | vm_memattr_t memattr); | ||||
void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); | void vm_phys_fictitious_unreg_range(vm_paddr_t start, vm_paddr_t end); | ||||
vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); | vm_page_t vm_phys_fictitious_to_vm_page(vm_paddr_t pa); | ||||
void vm_phys_free_contig(vm_page_t m, u_long npages); | void vm_phys_free_contig(vm_page_t m, u_long npages); | ||||
void vm_phys_free_pages(vm_page_t m, int order); | void vm_phys_free_pages(vm_page_t m, int order); | ||||
void vm_phys_init(void); | void vm_phys_init(void); | ||||
void vm_phys_init_page(vm_paddr_t pa); | void vm_phys_init_page(vm_paddr_t pa); | ||||
vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa); | vm_page_t vm_phys_paddr_to_vm_page(vm_paddr_t pa); | ||||
vm_page_t vm_phys_scan_contig(u_long npages, vm_paddr_t low, vm_paddr_t high, | vm_page_t vm_phys_scan_contig(u_long npages, vm_paddr_t low, vm_paddr_t high, | ||||
u_long alignment, vm_paddr_t boundary, int options); | u_long alignment, vm_paddr_t boundary, int options); | ||||
void vm_phys_set_pool(int pool, vm_page_t m, int order); | void vm_phys_set_pool(int pool, vm_page_t m, int order); | ||||
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); | ||||
/* | /* | ||||
* vm_phys_domain: | * vm_phys_domain: | ||||
* | * | ||||
* Return the memory domain the page belongs to. | * Return the memory domain the page belongs to. | ||||
*/ | */ | ||||
static inline struct vm_domain * | static inline int | ||||
vm_phys_domain(vm_page_t m) | vm_phys_domain(vm_page_t m) | ||||
kib: I would prefer to call this function vm_page_domain_idx() instead. It is impossible to say… | |||||
jeffAuthorUnsubmitted Not Done Inline ActionsI agree. I will look at the use cases and come up with another name. jeff: I agree. I will look at the use cases and come up with another name. | |||||
{ | { | ||||
#ifdef VM_NUMA_ALLOC | #ifdef VM_NUMA_ALLOC | ||||
int domn, segind; | int domn, segind; | ||||
/* XXXKIB try to assert that the page is managed */ | /* XXXKIB try to assert that the page is managed */ | ||||
segind = m->segind; | segind = m->segind; | ||||
KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m)); | KASSERT(segind < vm_phys_nsegs, ("segind %d m %p", segind, m)); | ||||
domn = vm_phys_segs[segind].domain; | domn = vm_phys_segs[segind].domain; | ||||
KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m)); | KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m)); | ||||
return (&vm_dom[domn]); | return (domn); | ||||
#else | #else | ||||
return (&vm_dom[0]); | return (0); | ||||
#endif | #endif | ||||
} | } | ||||
/* | |||||
* vm_page_domain: | |||||
* | |||||
* Return the memory domain structure the page belongs to. | |||||
*/ | |||||
static inline struct vm_domain * | |||||
vm_page_domain(vm_page_t m) | |||||
jeffAuthorUnsubmitted Not Done Inline ActionsThis is in the wrong header but dependency issues make it really hard to move. jeff: This is in the wrong header but dependency issues make it really hard to move. | |||||
{ | |||||
int domn; | |||||
domn = vm_phys_domain(m); | |||||
KASSERT(domn < vm_ndomains, ("domain %d m %p", domn, m)); | |||||
return (&vm_dom[domn]); | |||||
} | |||||
static inline u_int | static inline u_int | ||||
vm_phys_freecnt_adj(vm_page_t m, int adj) | vm_phys_freecnt_adj(vm_page_t m, int adj) | ||||
{ | { | ||||
mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); | mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); | ||||
vm_phys_domain(m)->vmd_free_count += adj; | vm_page_domain(m)->vmd_free_count += adj; | ||||
return (vm_cnt.v_free_count += adj); | return (vm_cnt.v_free_count += adj); | ||||
} | } | ||||
#endif /* _KERNEL */ | #endif /* _KERNEL */ | ||||
#endif /* !_VM_PHYS_H_ */ | #endif /* !_VM_PHYS_H_ */ |
I would prefer to call this function vm_page_domain_idx() instead. It is impossible to say from the names of vm_page_domain()/vm_phys_domain() what is the difference, and practically impossible to remember.
I used vm_phys prefix for the name because it is placed in vm_phys.h. Yes, it is too hard to move it into other place.