From: Johannes Weiner <hannes@cmpxchg.org>
To: Simon Jeons <simon.jeons@gmail.com>
Cc: Li Haifeng <omycle@gmail.com>,
open@kvack.org, list@kvack.org,
MEMORY MANAGEMENT <linux-mm@kvack.org>,
open list <linux-kernel@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] mm: Fixup the condition whether the page cache is free
Date: Thu, 7 Mar 2013 21:37:05 -0500 [thread overview]
Message-ID: <20130308023705.GI24384@cmpxchg.org> (raw)
In-Reply-To: <51394945.4070803@gmail.com>
On Fri, Mar 08, 2013 at 10:13:25AM +0800, Simon Jeons wrote:
> Ping, :-)
> On 03/07/2013 09:05 AM, Simon Jeons wrote:
> >Hi Johannes,
> >On 03/07/2013 03:47 AM, Johannes Weiner wrote:
> >>On Wed, Mar 06, 2013 at 09:04:55AM +0800, Simon Jeons wrote:
> >>>Hi Johannes,
> >>>On 03/04/2013 11:09 PM, Johannes Weiner wrote:
> >>>>On Mon, Mar 04, 2013 at 09:54:26AM +0800, Li Haifeng wrote:
> >>>>>When a page cache is to reclaim, we should to decide whether the page
> >>>>>cache is free.
> >>>>>IMO, the condition whether a page cache is free should be 3 in page
> >>>>>frame reclaiming. The reason lists as below.
> >>>>>
> >>>>>When page is allocated, the page->_count is 1(code
> >>>>>fragment is code-1 ).
> >>>>>And when the page is allocated for reading files from
> >>>>>extern disk, the
> >>>>>page->_count will increment 1 by page_cache_get() in
> >>>>>add_to_page_cache_locked()(code fragment is code-2). When
> >>>>>the page is to
> >>>>>reclaim, the isolated LRU list also increase the page->_count(code
> >>>>>fragment is code-3).
> >>>>The page count is initialized to 1, but that does not stay with the
> >>>>object. It's a reference that is passed to the allocating task, which
> >>>>drops it again when it's done with the page. I.e. the pattern is like
> >>>>this:
> >>>>
> >>>>instantiation:
> >>>>page = page_cache_alloc() /* instantiator reference -> 1 */
> >>>>add_to_page_cache(page, mapping, offset)
> >>>> get_page(page) /* page cache reference -> 2 */
> >>>>lru_cache_add(page)
> >>>> get_page(page) /* pagevec reference -> 3 */
> >>>>/* ...initiate read, write, associate buffers, ... */
> >>>>page_cache_release(page) /* drop instantiator reference
> >>>>-> 2 + private */
> >>>>
> >>>>reclaim:
> >>>>lru_add_drain()
> >>>> page_cache_release(page) /* drop pagevec reference ->
> >>>>1 + private */
> >>>IIUC, when add page to lru will lead to add to pagevec firstly, and
> >>>pagevec will take one reference, so if lru will take over the
> >>>reference taken by pagevec when page transmit from pagevec to lru?
> >>>or just drop the reference and lru will not take reference for page?
> >>The LRU does not hold a reference, it would not make sense. The
> >>pagevec only needs one because it would be awkward to remove a
> >>concurrently freed page out of a pagevec, but unlinking a page from
> >>the LRU is easy. See mm/swap.c::__page_cache_release() and friends.
> >
> >Since pagevec is per cpu, when can remove a concurrently freed
> >page out of a pagevec happen?
It doesn't because the pagevec holds a reference, as I wrote above.
Feel free to consult the code as well for questions like these ;-)
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-03-08 2:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 1:54 Li Haifeng
2013-03-04 15:09 ` Johannes Weiner
2013-03-05 1:51 ` Li Haifeng
2013-03-06 1:04 ` Simon Jeons
2013-03-06 19:47 ` Johannes Weiner
2013-03-07 1:05 ` Simon Jeons
2013-03-08 2:13 ` Simon Jeons
2013-03-08 2:37 ` Johannes Weiner [this message]
2013-03-08 2:48 ` Simon Jeons
2013-03-08 3:16 ` Johannes Weiner
2013-03-12 3:19 ` Simon Jeons
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=20130308023705.GI24384@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=list@kvack.org \
--cc=omycle@gmail.com \
--cc=open@kvack.org \
--cc=simon.jeons@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox