Can we put the pages allocated by alloc_pages in the page cache?
Da Zheng
zhengda1936 at gmail.com
Sun Sep 4 23:05:54 EDT 2011
Hello,
I'm modifying a filesystem. I need to allocate multiple contiguous pages to
store data, and I use alloc_pages to do so. In order to reduce memory copy, I
should put these pages directly to the page cache. I don't know if it's proper.
Can I allocate multiple pages together and free them and return them to the
buddy system separately? VFS uses page_cache_alloc to allocate a page each time,
so the pages can be freed independently.
My other concern is the reference counters of the pages. When I allocate
multiple contiguous pages with alloc_pages, only the first page's counter is 1.
The reference counters of the remaining pages are 0. It confuses me. Should I
set the reference counters of all pages to 1 first before I add them in the page
cache? Understanding the Linux Kernel says a page is unused when its reference
counter is -1, instead of 0. I wonder who is using the page when its counter is 0.
Thanks,
Da
More information about the Kernelnewbies
mailing list