Hi, This function yields the number of avail pages (pages that exist and are not mapped to kernels or pre-uvm data) in a given address range. Beck needs this.
Ok? -- Ariane Index: uvm/uvm_page.c =================================================================== RCS file: /cvs/src/sys/uvm/uvm_page.c,v retrieving revision 1.102 diff -u -d -p -r1.102 uvm_page.c --- uvm/uvm_page.c 7 Aug 2010 03:50:02 -0000 1.102 +++ uvm/uvm_page.c 1 Apr 2011 19:20:03 -0000 @@ -1464,3 +1464,28 @@ uvm_page_lookup_freelist(struct vm_page return (vm_physmem[lcv].free_list); #endif } + +/* + * uvm_pagecount: count the number of physical pages in the address range. + */ +psize_t +uvm_pagecount(struct uvm_constraint_range* constraint) +{ + int lcv; + psize_t sz; + paddr_t low, high; + paddr_t ps_low, ps_high; + + /* Algorithm uses page numbers. */ + low = atop(constraint->ucr_low); + high = atop(constraint->ucr_high); + + sz = 0; + for (lcv = 0; lcv < vm_nphysseg; lcv++) { + ps_low = MAX(low, vm_physmem[lcv].avail_start); + ps_high = MIN(high, vm_physmem[lcv].avail_end); + if (ps_low < ps_high) + sz += ps_high - ps_low; + } + return sz; +} Index: uvm/uvm_page.h =================================================================== RCS file: /cvs/src/sys/uvm/uvm_page.h,v retrieving revision 1.44 diff -u -d -p -r1.44 uvm_page.h --- uvm/uvm_page.h 29 Jun 2010 21:25:16 -0000 1.44 +++ uvm/uvm_page.h 1 Apr 2011 19:20:03 -0000 @@ -252,6 +252,9 @@ void uvm_pagezero(struct vm_page *); void uvm_pagealloc_pg(struct vm_page *, struct uvm_object *, voff_t, struct vm_anon *); +struct uvm_constraint_range; /* XXX move to uvm_extern.h? */ +psize_t uvm_pagecount(struct uvm_constraint_range*); + int uvm_page_lookup_freelist(struct vm_page *); #if VM_PHYSSEG_MAX == 1