linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Minchan Kim <minchan.kim@gmail.com>,
	Rik van Riel <riel@redhat.com>, Shaohua Li <shaohua.li@intel.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Michel Lespinasse <walken@google.com>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH 2/2] SHM_UNLOCK: fix Unevictable pages stranded after swap
Date: Mon, 9 Jan 2012 14:25:06 -0800 (PST)	[thread overview]
Message-ID: <alpine.LSU.2.00.1201091342300.1272@eggly.anvils> (raw)
In-Reply-To: <4F0B5146.6090200@gmail.com>

On Mon, 9 Jan 2012, KOSAKI Motohiro wrote:
> 2012/1/6 Hugh Dickins <hughd@google.com>:

[ check_move_unevictable_page(s) ]

> > 
> > Leave out the "rotate unevictable list" block: that's a leftover
> > from when this was used for /proc/sys/vm/scan_unevictable_pages,
> > whose flawed handling involved looking at pages at tail of LRU.
> > 
> > Was there significance to the sequence first ClearPageUnevictable,
> > then test page_evictable, then SetPageUnevictable here?  I think
> > not, we're under LRU lock, and have no barriers between those.
> 
> If I understand correctly, this is not exactly correct. Because of,

Thank you for giving it serious thought:
such races are hard work to think about.

> PG_mlocked operation is not protected by LRU lock. So, I think we

Right.  But I don't see that I've made a significant change there.

I may be being lazy, and rushing back to answer you, without giving
constructive thought to what the precise race is that you see, and
how we might fix it.  If the case you have in mind is easy for you
to describe in detail, please do so; but don't hesitate to tell me
to my own work for myself!

Since the original code didn't have any barriers in it (in the
!page_evictable path, in the global case: I think that's true of the
memcg case also, but that is more complicated), how did it differ from

retry:
	if (page_evictable)
		blah blah blah;
	else if (page_evictable)
		goto retry;

which could be made even "safer" ;) if it were replaced by

retry:
	if (page_evictable)
		blah blah blah;
	else if (page_evictable)
		goto retry;
	else if (page_evictable)
		goto retry;

putback_lru_page() goes through similar doubts as to whether it's made
the right decision ("Oh, did I leave the oven on?"), but it does contain
an explicit smp_mb() and comment.

I am being lazy, I haven't even stopped to convince myself that that
smp_mb() is correctly placed (I'm not saying it isn't, I just haven't
done the thinking).

> have three choice.
> 
> 1) check_move_unevictable_pages() aimed retry logic and put pages back
>    into correct lru.

I think we'd need more than just the old retry.

> 2) check_move_unevictable_pages() unconditionally move the pages into
>    evictable lru, and vmacan put them back into correct lru later.

That's a good thought: these are all pages which we allowed to be found
Unevictable lazily in the first place, so why should be so anxious to
assign them right now.  Ah, but if they are still unevictable, then it's
because they're Mlocked, and we do make much more effort to account the
Mlocked pages right.  We'd probably best keep on trying.

> 3) To protect PG_mlock operation by lru lock.

Surely not if we can avoid it.  Certainly not to bolster my cleanup.

> 
> other parts looks fine to me.

Thanks,
Hugh

  reply	other threads:[~2012-01-09 22:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06 21:10 [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section Hugh Dickins
2012-01-06 21:12 ` [PATCH 2/2] SHM_UNLOCK: fix Unevictable pages stranded after swap Hugh Dickins
2012-01-09 20:42   ` KOSAKI Motohiro
2012-01-09 22:25     ` Hugh Dickins [this message]
2012-01-09 23:09       ` KOSAKI Motohiro
2012-01-09 23:56         ` Hugh Dickins
2012-01-15  0:20   ` Hugh Dickins
2012-01-07  8:28 ` [PATCH 1/2] SHM_UNLOCK: fix long unpreemptible section KOSAKI Motohiro
2012-01-15  0:18 ` Hugh Dickins
2012-01-18 22:37   ` Andrew Morton
2012-01-18 23:26     ` Hugh Dickins

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=alpine.LSU.2.00.1201091342300.1272@eggly.anvils \
    --to=hughd@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=eric.dumazet@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=kosaki.motohiro@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan.kim@gmail.com \
    --cc=riel@redhat.com \
    --cc=shaohua.li@intel.com \
    --cc=walken@google.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).