linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: zhong jiang <zhongjiang@huawei.com>
Cc: Michal Hocko <mhocko@kernel.org>,
	akpm@linux-foundation.org, minchan@kernel.org,
	linux-mm@kvack.org
Subject: Re: [PATCH v3] mm: fix trying to reclaim unevictable lru page when calling madvise_pageout
Date: Tue, 5 Nov 2019 13:48:11 -0500	[thread overview]
Message-ID: <20191105184811.GA44848@cmpxchg.org> (raw)
In-Reply-To: <5DC182DD.5010304@huawei.com>

On Tue, Nov 05, 2019 at 10:10:37PM +0800, zhong jiang wrote:
> On 2019/11/5 20:45, Michal Hocko wrote:
> > On Tue 05-11-19 20:28:58, zhong jiang wrote:
> >> On 2019/11/5 14:33, Michal Hocko wrote:
> >>> On Sat 02-11-19 15:36:55, zhong jiang wrote:
> >>>> On 2019/11/2 2:32, Michal Hocko wrote:
> >>> [...]
> >>>>> But I would really appreciate to add a comment for the BUG_ON and
> >>>>> explain why do we care about PageUnevictable so much when there is an
> >>>>> explicit page_evictable check in the reclaim path. In other words a
> >>>>> short summary of what Johannes explained in
> >>>>> http://lkml.kernel.org/r/20191030193307.GA48128@cmpxchg.org. Maybe in a
> >>>>> separate patch. Care to send one or should I send it?
> >>>> Hi,  Michal
> >>>>
> >>>> Actually,  I am not very clear about the words Johannes had said.   How the race to
> >>>> tirgger, it will result in an PgeMlocked page can be visible in shrink_page_list.
> >>>>
> >>>> Could you elaborate the race in detail further ?
> >>> I would go with the following comment
> >>>
> >>> 	/*
> >>> 	 * Page reclaim can see !page_evictable(), but it must not see pages that
> >>> 	 * have the PageUnevictable lru bit already set. See  __pagevec_lru_add_fn()
> >>> 	 * for more details.
> >>> 	 */
> >> But  the detail still confuses me in __pagevec_lru_add_fn()  to  see PageMlocked  in vmscan :-\ .
> > Which part does confuse you exactly?
> page reclaim can see !page_evictable()  means some race still exist in the kernel. Is there any race window .

Yes. mlock does this:

lock_page()
SetPageMlocked()
if (isolate_lru_page())
  putback_lru_page() // move to unevictable list
unlock_page()

and vmscan does this:

isolate_lru_pages()
for_each_page()
  if (!try_lock_page())
    continue
  if (!page_evictable())
    continue
putback_lru_pages()

It's possible that mlock locks the page and sets PG_mlocked, but
vmscan has the page already isolated and mlock cannot move it to the
unevictable list itself. In that case, vmscan will either fail to lock
the page or see !page_unevictable() and move the page on the
unevictable list on behalf of mlock.


  reply	other threads:[~2019-11-05 18:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 13:50 [PATCH v3] mm: fix trying to reclaim unevictable lru page when calling madvise_pageout zhong jiang
2019-11-01 14:46 ` Johannes Weiner
2019-11-01 15:08 ` Minchan Kim
2019-11-01 18:32 ` Michal Hocko
2019-11-02  7:36   ` zhong jiang
2019-11-05  6:33     ` Michal Hocko
2019-11-05 12:28       ` zhong jiang
2019-11-05 12:45         ` Michal Hocko
2019-11-05 14:10           ` zhong jiang
2019-11-05 18:48             ` Johannes Weiner [this message]
2019-11-07 13:31               ` zhong jiang

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=20191105184811.GA44848@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=mhocko@kernel.org \
    --cc=minchan@kernel.org \
    --cc=zhongjiang@huawei.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;
as well as URLs for NNTP newsgroup(s).