vm active queue

Hi!

First of all, your question does not make much sense to me. Perhaps your question was "when" does a page gets removed from the active page list or perhaps "where" does that page go to when it is removed. Anyhoo, I ll try to answer both questions.

The OS monitors memory utilization and runs every once in a while the pageout daemon in order to keep a certain amount of inactive, free & cache pages. This daemon figures out how much memory is needed and how many pages must be moved to less active lists. The daemon moves pages from the active list -> inactive, from the inactive -> cache and from cache -> free list.
Now we know the pageout daemon scans the active list to find pages to swap to the inactive list. The pages that can be removed from the active list are those that have a "usage counter" of 0. Suppose that when the page is first claimed, this counter has an initial value of X. Every once in a while the page will get scanned by the daemon and if it is currently being referenced by an object the counter goes ++. If not, the counter goes --. When this counter reaches zero, the pageout daemon is free to remove it from the active list to the inactive list, if it is short on inactive pages. Ta da!

I hope this answers your question.
 
Hi,

by where, I meant in which function a page actually gets removed from active queue. Before removing the page I want to check something related to that particular page, like to which process the page belongs. I am trying to implement my code in the function
Code:
void vm_page_remove(vm_page_t m)
{...}
, int the sense of what I am trying to do, is this function correct?
 
Go here
http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/vm/vm_pageout.c
and check out the vm_pageout_scan function, that's where the magic happens. I do believe however that if the page is being removed atm and the usage counter is zero, you can't tell which thread used to reference it. I don't have the time to go through the code atm because I'm swamped, so study it yourself and find out what you can or can't do. Or wait until xmas and I'll tell you myself :-D

Apart from this, i have another wild theory. What you want to know does sound like statistics that the OS just maaay happen to keep, check out the wait4 sys/call as well because it can return various statistics about the resources that the (now terminated) child utilized.

Happy hacking!
 
Back
Top