From mboxrd@z Thu Jan 1 00:00:00 1970 From: zhengda1936@gmail.com (Da Zheng) Date: Sun, 04 Sep 2011 23:05:54 -0400 Subject: Can we put the pages allocated by alloc_pages in the page cache? Message-ID: <4E643C92.20703@gmail.com> To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 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