On Thu, Sep 02, 2010 at 06:27:57PM +0000, Pratyush Kshirsagar wrote: > diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c > index a326037..4eb9026 100644 > --- a/sys/vm/vm_map.c > +++ b/sys/vm/vm_map.c > @@ -3657,3 +3657,20 @@ DB_SHOW_COMMAND(procvm, procvm) > } > > #endif /* DDB */ > + > +long vmap_resident_count(vm_map_t v) > +{ > + vm_map_entry_t entry; > + vm_map_object_t *mobj; > + vm_object_t obj; > + long pres = 0; > + entry = &(v->header); > + while(entry->next != NULL){ > + mobj = &entry->object; > + if(mobj->vm_object != NULL) { > + obj = mobj->vm_object; > + pres = pres + (long) (obj->agg_pv_list_count / > obj->resident_page_count); > + } > + } > + return pres; > +}
The variable `entry' is not advanced in the loop, so it doesn't terminate until a new element is appended to the current one.