All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhengda1936@gmail.com (Da Zheng)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Can we put the pages allocated by alloc_pages in the page cache?
Date: Sun, 04 Sep 2011 23:05:54 -0400	[thread overview]
Message-ID: <4E643C92.20703@gmail.com> (raw)

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

                 reply	other threads:[~2011-09-05  3:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4E643C92.20703@gmail.com \
    --to=zhengda1936@gmail.com \
    --cc=kernelnewbies@lists.kernelnewbies.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.