Skip to contentSkip to conversation

freeing pagecache

DISCUSSION David Chow 2 participants 3 messages Sep 29, 2002 VFS

lore
Share & tools
lore

David Chow

author
#0 lore raw

Hi all,

This is probabaly a question for the VFS or VM. If I some pages are associated with an inode (pagec->mapping->host == the_inode) . When running out of memory, how does the vm freeing up the pagecache? OK, if I am running out of memory, is there any chance for the vm freeing up the pages and leaving the inode and dentry in the dcache or it is trigerred by the shring_dcache and result in freeing up all the pages. In case if the pages are locked, how does the VM handle this case? Anyway, it is probably a question of the path of freeing up page cache... The reason I am asking the question is that if I am safe to make use of an unlocked mapped pagecahed page. Thanks for comments and answers.

David

#1 lore raw
Quoted 3 lines · David Chow

cache... The reason I am asking the question is that if I am safe to make use of an unlocked mapped pagecahed page. Thanks for comments and answers.

You don't need to lock it, just bump its page count. include/linux/mm.h:

* Also, many kernel routines increase the page count before a critical
* routine so they can be sure the page doesn't go away from under them. */
#define get_page(p) atomic_inc(&(p)->count)
#define put_page(p) __free_page(p)

Signature · 1 line
Revolutions do not require corporate support.
author
#2 lore raw
Quoted 7 lines · Matthew Wilcox
Quoted 3 lines · David Chow

cache... The reason I am asking the question is that if I am safe to make use of an unlocked mapped pagecahed page. Thanks for comments and answers.

Quoted 10 lines

You don't need to lock it, just bump its page count. include/linux/mm.h:

* Also, many kernel routines increase the page count before a critical
* routine so they can be sure the page doesn't go away from under them. */
#define get_page(p) atomic_inc(&(p)->count)
#define put_page(p) __free_page(p)

I've read about the struct page, I thought it is some kind of lru algorithm used by kswapd, that measn pagecache is just like dcache which has usage counts. There are a couple listhead, is there any listhead that are not used for a pagecached page? If there are something that I can make use, I can simply use the listhead for my list... but I am not sure are there any potential hazards. Thanks for helps, comments are welcome.

David