From: Vlastimil Babka <vbabka@suse.cz>
To: Minchan Kim <minchan@kernel.org>
Cc: jlayton@poochiereds.net, Rik van Riel <riel@redhat.com>,
YiPing Xu <xuyiping@hisilicon.com>,
aquini@redhat.com, rknize@motorola.com,
Sergey Senozhatsky <sergey.senozhatsky@gmail.com>,
Chan Gyun Jeong <chan.jeong@lge.com>,
Hugh Dickins <hughd@google.com>,
linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
virtualization@lists.linux-foundation.org, bfields@fieldses.org,
linux-mm@kvack.org, Gioh Kim <gurugio@hanmail.net>,
Gioh Kim <gi-oh.kim@profitbricks.com>,
Mel Gorman <mgorman@suse.de>, Sangseok Lee <sangseok.lee@lge.com>,
Andrew Morton <akpm@linux-foundation.org>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
koct9i@gmail.com, Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCH v3 02/16] mm/compaction: support non-lru movable page migration
Date: Mon, 4 Apr 2016 15:24:34 +0200 [thread overview]
Message-ID: <57026B12.6060000@suse.cz> (raw)
In-Reply-To: <20160404051225.GA6838@bbox>
On 04/04/2016 07:12 AM, Minchan Kim wrote:
> On Fri, Apr 01, 2016 at 11:29:14PM +0200, Vlastimil Babka wrote:
>> Might have been better as a separate migration patch and then a
>> compaction patch. It's prefixed mm/compaction, but most changed are
>> in mm/migrate.c
>
> Indeed. The title is rather misleading but not sure it's a good idea
> to separate compaction and migration part.
Guess it's better to see the new functions together with its user after
all, OK.
> I will just resend to change the tile from "mm/compaction" to
> "mm/migration".
OK!
>> Also I'm a bit uncomfortable how isolate_movable_page() blindly expects that
>> page->mapping->a_ops->isolate_page exists for PageMovable() pages.
>> What if it's a false positive on a PG_reclaim page? Can we rely on
>> PG_reclaim always (and without races) implying PageLRU() so that we
>> don't even attempt isolate_movable_page()?
>
> For now, we shouldn't have such a false positive because PageMovable
> checks page->_mapcount == PAGE_MOVABLE_MAPCOUNT_VALUE as well as PG_movable
> under PG_lock.
>
> But I read your question about user-mapped drvier pages so we cannot
> use _mapcount anymore so I will find another thing. A option is this.
>
> static inline int PageMovable(struct page *page)
> {
> int ret = 0;
> struct address_space *mapping;
> struct address_space_operations *a_op;
>
> if (!test_bit(PG_movable, &(page->flags))
> goto out;
>
> mapping = page->mapping;
> if (!mapping)
> goto out;
>
> a_op = mapping->a_op;
> if (!aop)
> goto out;
> if (a_op->isolate_page)
> ret = 1;
> out:
> return ret;
>
> }
>
> It works under PG_lock but with this, we need trylock_page to peek
> whether it's movable non-lru or not for scanning pfn.
Hm I hoped that with READ_ONCE() we could do the peek safely without
trylock_page, if we use it only as a heuristic. But I guess it would
require at least RCU-level protection of the
page->mapping->a_op->isolate_page chain.
> For avoiding that, we need another function to peek which just checks
> PG_movable bit instead of all things.
>
>
> /*
> * If @page_locked is false, we cannot guarantee page->mapping's stability
> * so just the function checks with PG_movable which could be false positive
> * so caller should check it again under PG_lock to check a_ops->isolate_page.
> */
> static inline int PageMovable(struct page *page, bool page_locked)
> {
> int ret = 0;
> struct address_space *mapping;
> struct address_space_operations *a_op;
>
> if (!test_bit(PG_movable, &(page->flags))
> goto out;
>
> if (!page_locked) {
> ret = 1;
> goto out;
> }
>
> mapping = page->mapping;
> if (!mapping)
> goto out;
>
> a_op = mapping->a_op;
> if (!aop)
> goto out;
> if (a_op->isolate_page)
> ret = 1;
> out:
> return ret;
> }
I wouldn't put everything into single function, but create something
like __PageMovable() just for the unlocked peek. Unlike the
zone->lru_lock, we don't keep page_lock() across iterations in
isolate_migratepages_block(), as obviously each page has different lock.
So the page_locked parameter would be always passed as constant, and at
that point it's better to have separate functions.
So I guess the question is how many false positives from overlap with
PG_reclaim the scanner will hit if we give up on
PAGE_MOVABLE_MAPCOUNT_VALUE, as that will increase number of page locks
just to realize that it's not actual PageMovable() page...
> Thanks for detail review, Vlastimil!
> I will resend new versions after vacation in this week.
You're welcome, great!
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-04-04 13:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1459321935-3655-1-git-send-email-minchan@kernel.org>
2016-03-30 7:12 ` [PATCH v3 02/16] mm/compaction: support non-lru movable page migration Minchan Kim
2016-04-01 21:29 ` Vlastimil Babka
2016-04-04 5:12 ` Minchan Kim
2016-04-04 13:24 ` Vlastimil Babka [this message]
2016-04-07 2:35 ` Minchan Kim
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=57026B12.6060000@suse.cz \
--to=vbabka@suse.cz \
--cc=akpm@linux-foundation.org \
--cc=aquini@redhat.com \
--cc=bfields@fieldses.org \
--cc=chan.jeong@lge.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gi-oh.kim@profitbricks.com \
--cc=gurugio@hanmail.net \
--cc=hughd@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=jlayton@poochiereds.net \
--cc=koct9i@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan@kernel.org \
--cc=riel@redhat.com \
--cc=rknize@motorola.com \
--cc=sangseok.lee@lge.com \
--cc=sergey.senozhatsky@gmail.com \
--cc=viro@ZenIV.linux.org.uk \
--cc=virtualization@lists.linux-foundation.org \
--cc=xuyiping@hisilicon.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