From: Johannes Weiner <hannes@cmpxchg.org>
To: Bob Liu <lliubbo@gmail.com>
Cc: akpm@linux-foundation.org, linux-mm@kvack.org,
kosaki.motohiro@jp.fujitsu.com, riel@redhat.com
Subject: Re: [RFC][PATCH] shrink_page_list: save page_mapped() to local val
Date: Wed, 24 Mar 2010 14:26:03 +0100 [thread overview]
Message-ID: <20100324132603.GB20640@cmpxchg.org> (raw)
In-Reply-To: <1269432687-1580-1-git-send-email-lliubbo@gmail.com>
Hi,
On Wed, Mar 24, 2010 at 08:11:27PM +0800, Bob Liu wrote:
> In funtion shrink_page_list(), page_mapped() is called several
> times,save it to local val to reduce atomic_read.
>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
> mm/vmscan.c | 8 +++++---
> 1 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 79c8098..08cc3ac 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -637,6 +637,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> struct address_space *mapping;
> struct page *page;
> int may_enter_fs;
> + int page_mapcount;
>
> cond_resched();
>
> @@ -653,11 +654,12 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> if (unlikely(!page_evictable(page, NULL)))
> goto cull_mlocked;
>
> - if (!sc->may_unmap && page_mapped(page))
> + page_mapcount = page_mapped(page);
> + if (!sc->may_unmap && page_mapcount)
> goto keep_locked;
>
> /* Double the slab pressure for mapped and swapcache pages */
> - if (page_mapped(page) || PageSwapCache(page))
> + if (page_mapcount || PageSwapCache(page))
> sc->nr_scanned++;
Note that the mapcount is unstable and might very well drop while this code
runs.
The first two instances are close enough together that a change is unlikely,
but between them and the below check before try_to_unmap() we might be even
waiting for writeback to complete.
try_to_unmap() will figure it out, but it would lock the mapping first and
then read the mapcount.
I am unsure whether the change is worth it.
> may_enter_fs = (sc->gfp_mask & __GFP_FS) ||
> @@ -707,7 +709,7 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> * The page is mapped into the page tables of one or more
> * processes. Try to unmap it here.
> */
> - if (page_mapped(page) && mapping) {
> + if (page_mapcount && mapping) {
> switch (try_to_unmap(page, TTU_UNMAP)) {
> case SWAP_FAIL:
> goto activate_locked;
--
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>
prev parent reply other threads:[~2010-03-24 13:26 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-24 12:11 Bob Liu
2010-03-24 13:26 ` Johannes Weiner [this message]
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=20100324132603.GB20640@cmpxchg.org \
--to=hannes@cmpxchg.org \
--cc=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-mm@kvack.org \
--cc=lliubbo@gmail.com \
--cc=riel@redhat.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