From: Sam Ben <sam.bennn@gmail.com>
To: Mel Gorman <mgorman@suse.de>
Cc: Alexey Lyahkov <alexey.lyashkov@gmail.com>,
Andrew Perepechko <anserper@ya.ru>,
Robin Dong <sanbai@taobao.com>, Theodore Tso <tytso@mit.edu>,
Andrew Morton <akpm@linux-foundation.org>,
Hugh Dickins <hughd@google.com>, Rik van Riel <riel@redhat.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Bernd Schubert <bernd.schubert@fastmail.fm>,
David Howells <dhowells@redhat.com>,
Trond Myklebust <Trond.Myklebust@netapp.com>,
Linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux-ext4 <linux-ext4@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH 2/3] mm: Ensure that mark_page_accessed moves pages to the active list
Date: Wed, 01 May 2013 13:41:34 +0800 [thread overview]
Message-ID: <5180AB0E.6030407@gmail.com> (raw)
In-Reply-To: <1367253119-6461-3-git-send-email-mgorman@suse.de>
Hi Mel,
On 04/30/2013 12:31 AM, Mel Gorman wrote:
> If a page is on a pagevec then it is !PageLRU and mark_page_accessed()
> may fail to move a page to the active list as expected. Now that the
> LRU is selected at LRU drain time, mark pages PageActive if they are
> on a pagevec so it gets moved to the correct list at LRU drain time.
> Using a debugging patch it was found that for a simple git checkout
> based workload that pages were never added to the active file list in
Could you show us the details of your workload?
> practice but with this patch applied they are.
>
> before after
> LRU Add Active File 0 757121
> LRU Add Active Anon 2678833 2633924
> LRU Add Inactive File 8821711 8085543
> LRU Add Inactive Anon 183 200
>
> The question to consider is if this is universally safe. If the page
> was isolated for reclaim and there is a parallel mark_page_accessed()
> then vmscan.c will get upset when it finds an isolated PageActive page.
> Similarly a potential race exists between a per-cpu drain on a pagevec
> list and an activation on a remote CPU.
>
> lru_add_drain_cpu
> __pagevec_lru_add
> lru = page_lru(page);
> mark_page_accessed
> if (PageLRU(page))
> activate_page
> else
> SetPageActive
> SetPageLRU(page);
> add_page_to_lru_list(page, lruvec, lru);
>
> A PageActive page is now added to the inactivate list.
>
> While this looks strange, I think it is sufficiently harmless that additional
> barriers to address the case is not justified. Unfortunately, while I never
> witnessed it myself, these parallel updates potentially trigger defensive
> DEBUG_VM checks on PageActive and hence they are removed by this patch.
>
> Signed-off-by: Mel Gorman <mgorman@suse.de>
> ---
> mm/swap.c | 18 ++++++++++++------
> mm/vmscan.c | 3 ---
> 2 files changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/mm/swap.c b/mm/swap.c
> index 80fbc37..2a10d08 100644
> --- a/mm/swap.c
> +++ b/mm/swap.c
> @@ -437,8 +437,17 @@ void activate_page(struct page *page)
> void mark_page_accessed(struct page *page)
> {
> if (!PageActive(page) && !PageUnevictable(page) &&
> - PageReferenced(page) && PageLRU(page)) {
> - activate_page(page);
> + PageReferenced(page)) {
> +
> + /*
> + * If the page is on the LRU, promote immediately. Otherwise,
> + * assume the page is on a pagevec, mark it active and it'll
> + * be moved to the active LRU on the next drain
> + */
> + if (PageLRU(page))
> + activate_page(page);
> + else
> + SetPageActive(page);
> ClearPageReferenced(page);
> } else if (!PageReferenced(page)) {
> SetPageReferenced(page);
> @@ -478,11 +487,8 @@ EXPORT_SYMBOL(__lru_cache_add);
> */
> void lru_cache_add_lru(struct page *page, enum lru_list lru)
> {
> - if (PageActive(page)) {
> + if (PageActive(page))
> VM_BUG_ON(PageUnevictable(page));
> - } else if (PageUnevictable(page)) {
> - VM_BUG_ON(PageActive(page));
> - }
>
> VM_BUG_ON(PageLRU(page));
> __lru_cache_add(page, lru);
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 88c5fed..751b897 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -704,7 +704,6 @@ static unsigned long shrink_page_list(struct list_head *page_list,
> if (!trylock_page(page))
> goto keep;
>
> - VM_BUG_ON(PageActive(page));
> VM_BUG_ON(page_zone(page) != zone);
>
> sc->nr_scanned++;
> @@ -935,7 +934,6 @@ activate_locked:
> /* Not a candidate for swapping, so reclaim swap space. */
> if (PageSwapCache(page) && vm_swap_full())
> try_to_free_swap(page);
> - VM_BUG_ON(PageActive(page));
> SetPageActive(page);
> pgactivate++;
> keep_locked:
> @@ -3488,7 +3486,6 @@ void check_move_unevictable_pages(struct page **pages, int nr_pages)
> if (page_evictable(page)) {
> enum lru_list lru = page_lru_base_type(page);
>
> - VM_BUG_ON(PageActive(page));
> ClearPageUnevictable(page);
> del_page_from_lru_list(page, lruvec, LRU_UNEVICTABLE);
> add_page_to_lru_list(page, lruvec, lru);
--
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-05-01 5:41 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-29 16:31 [RFC PATCH 0/3] Obey mark_page_accessed hint given by filesystems Mel Gorman
2013-04-29 16:31 ` [PATCH 1/3] mm: pagevec: Defer deciding what LRU to add a page to until pagevec drain time Mel Gorman
2013-04-29 16:50 ` Rik van Riel
2013-05-03 7:51 ` Jan Kara
2013-05-03 8:37 ` Mel Gorman
2013-04-29 16:31 ` [PATCH 2/3] mm: Ensure that mark_page_accessed moves pages to the active list Mel Gorman
2013-04-29 17:12 ` Rik van Riel
2013-04-29 21:53 ` Mel Gorman
2013-05-01 5:41 ` Sam Ben [this message]
2013-05-01 8:06 ` Mel Gorman
2013-05-01 8:14 ` Ric Mason
2013-05-01 8:31 ` Mel Gorman
2013-04-29 16:31 ` [PATCH 3/3] mm: Remove lru parameter from __pagevec_lru_add and remove parts of pagevec API Mel Gorman
2013-05-03 8:00 ` Jan Kara
2013-05-01 6:28 ` [RFC PATCH 0/3] Obey mark_page_accessed hint given by filesystems Will Huck
2013-05-01 8:08 ` Mel Gorman
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=5180AB0E.6030407@gmail.com \
--to=sam.bennn@gmail.com \
--cc=Trond.Myklebust@netapp.com \
--cc=akpm@linux-foundation.org \
--cc=alexey.lyashkov@gmail.com \
--cc=anserper@ya.ru \
--cc=bernd.schubert@fastmail.fm \
--cc=dhowells@redhat.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=riel@redhat.com \
--cc=sanbai@taobao.com \
--cc=tytso@mit.edu \
/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;
as well as URLs for NNTP newsgroup(s).