[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200122183113.GA98452@cmpxchg.org>
Date: Wed, 22 Jan 2020 13:31:13 -0500
From: Johannes Weiner <hannes@...xchg.org>
To: Alex Shi <alex.shi@...ux.alibaba.com>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, akpm@...ux-foundation.org,
mgorman@...hsingularity.net, tj@...nel.org, hughd@...gle.com,
khlebnikov@...dex-team.ru, daniel.m.jordan@...cle.com,
yang.shi@...ux.alibaba.com, willy@...radead.org,
shakeelb@...gle.com, Michal Hocko <mhocko@...nel.org>,
Vladimir Davydov <vdavydov.dev@...il.com>,
Roman Gushchin <guro@...com>,
Chris Down <chris@...isdown.name>,
Thomas Gleixner <tglx@...utronix.de>,
Vlastimil Babka <vbabka@...e.cz>, Qian Cai <cai@....pw>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Jérôme Glisse <jglisse@...hat.com>,
Andrea Arcangeli <aarcange@...hat.com>,
David Rientjes <rientjes@...gle.com>,
"Aneesh Kumar K.V" <aneesh.kumar@...ux.ibm.com>,
swkhack <swkhack@...il.com>,
"Potyra, Stefan" <Stefan.Potyra@...ktrobit.com>,
Mike Rapoport <rppt@...ux.vnet.ibm.com>,
Stephen Rothwell <sfr@...b.auug.org.au>,
Colin Ian King <colin.king@...onical.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Mauro Carvalho Chehab <mchehab+samsung@...nel.org>,
Peng Fan <peng.fan@....com>,
Nikolay Borisov <nborisov@...e.com>,
Ira Weiny <ira.weiny@...el.com>,
Kirill Tkhai <ktkhai@...tuozzo.com>,
Yafang Shao <laoar.shao@...il.com>
Subject: Re: [PATCH v8 03/10] mm/lru: replace pgdat lru_lock with lruvec lock
On Wed, Jan 22, 2020 at 08:01:29PM +0800, Alex Shi wrote:
> Yes I understand isolatation would exclusive by PageLRU, but forgive my
> stupid, I didn't figure out how a new page lruvec adding could be blocked.
I don't see why we would need this. Can you elaborate where you think
this is a problem?
If compaction races with charging for example, compaction doesn't need
to prevent a new page from being added to an lruvec. PageLRU is only
set after page->mem_cgroup is updated, so there are two race outcomes:
1) TestClearPageLRU() fails. That means the page isn't (fully) created
yet and cannot be migrated. We goto isolate_fail before even trying to
lock the lruvec.
2) TestClearPageLRU() succeeds. That means the page was fully created
and page->mem_cgroup has been set up. Anybody who now wants to change
page->mem_cgroup needs PageLRU, but we have it, so lruvec is stable.
I.e. cgroup charging does this:
page->mem_cgroup = new_group
lock(pgdat->lru_lock)
SetPageLRU()
add_page_to_lru_list()
unlock(pgdat->lru_lock)
and compaction currently does this:
lock(pgdat->lru_lock)
if (!PageLRU())
goto isolate_fail
// __isolate_lru_page:
if (!get_page_unless_zero())
goto isolate_fail
ClearPageLRU()
del_page_from_lru_list()
unlock(pgdat->lru_lock)
We can replace charging with this:
page->mem_cgroup = new_group
lock(lruvec->lru_lock)
add_page_to_lru_list()
unlock(lruvec->lru_lock)
SetPageLRU()
and the compaction sequence with something like this:
if (!get_page_unless_zero())
goto isolate_fail
if (!TestClearPageLRU())
goto isolate_fail_put
// We got PageLRU, so charging is complete and nobody
// can modify page->mem_cgroup until we set it again.
lruvec = mem_cgroup_page_lruvec(page, pgdat)
lock(lruvec->lru_lock)
del_page_from_lru_list()
unlock(lruvec->lru_lock)
Powered by blists - more mailing lists