[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <b86dc335-fad6-01a1-77ba-3d2a9d5c4c22@linux.alibaba.com>
Date: Wed, 11 Dec 2019 11:51:47 +0800
From: Alex Shi <alex.shi@...ux.alibaba.com>
To: Matthew Wilcox <willy@...radead.org>
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, shakeelb@...gle.com,
hannes@...xchg.org, 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 v5 2/8] mm/lru: replace pgdat lru_lock with lruvec lock
在 2019/12/10 下午9:41, Matthew Wilcox 写道:
> On Tue, Dec 10, 2019 at 07:46:18PM +0800, Alex Shi wrote:
>> -static void lock_page_lru(struct page *page, int *isolated)
>> +static struct lruvec *lock_page_lru(struct page *page, int *isolated)
>> {
>> - pg_data_t *pgdat = page_pgdat(page);
>> + struct lruvec *lruvec = lock_page_lruvec_irq(page);
>>
>> - spin_lock_irq(&pgdat->lru_lock);
>> if (PageLRU(page)) {
>> - struct lruvec *lruvec;
>>
>> - lruvec = mem_cgroup_page_lruvec(page, pgdat);
>> ClearPageLRU(page);
>> del_page_from_lru_list(page, lruvec, page_lru(page));
>> *isolated = 1;
>> } else
>> *isolated = 0;
>> +
>> + return lruvec;
>> }
>
> I still don't understand how this is supposed to work for !PageLRU
> pages. Which lruvec have you locked if this page isn't on an LRU?
>
Good question. We could just fold it under PageLRU and no meaning changes.
Is this better to has this patch?
Thanks
Alex
commit 0f4b66d4a42397d57638352b738c3f9658003e44
Author: Alex Shi <alex.shi@...ux.alibaba.com>
Date: Wed Dec 11 11:31:53 2019 +0800
mm/memcg: fold lock in lock_page_lru
According to the calling path of commit_charge, the lrucare is bound
with PageLRU, so we could just fold it under PageLRU. This has no
functional change.
Signed-off-by: Alex Shi <alex.shi@...ux.alibaba.com>
Cc: Johannes Weiner <hannes@...xchg.org>
Cc: Michal Hocko <mhocko@...nel.org>
Cc: Vladimir Davydov <vdavydov.dev@...il.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
Cc: cgroups@...r.kernel.org
Cc: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 833df0ce1bc1..4fe2252cf437 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2622,9 +2622,10 @@ static void cancel_charge(struct mem_cgroup *memcg, unsigned int nr_pages)
static struct lruvec *lock_page_lru(struct page *page, int *isolated)
{
- struct lruvec *lruvec = lock_page_lruvec_irq(page);
+ struct lruvec *lruvec = NULL;
if (PageLRU(page)) {
+ lruvec = lock_page_lruvec_irq(page);
ClearPageLRU(page);
del_page_from_lru_list(page, lruvec, page_lru(page));
@@ -2638,17 +2639,18 @@ static struct lruvec *lock_page_lru(struct page *page, int *isolated)
static void unlock_page_lru(struct page *page, int isolated,
struct lruvec *locked_lruvec)
{
- struct lruvec *lruvec;
+ if (isolated) {
+ struct lruvec *lruvec;
- unlock_page_lruvec_irq(locked_lruvec);
- lruvec = lock_page_lruvec_irq(page);
+ if (locked_lruvec)
+ unlock_page_lruvec_irq(locked_lruvec);
+ lruvec = lock_page_lruvec_irq(page);
- if (isolated) {
VM_BUG_ON_PAGE(PageLRU(page), page);
SetPageLRU(page);
add_page_to_lru_list(page, lruvec, page_lru(page));
+ unlock_page_lruvec_irq(lruvec);
}
- unlock_page_lruvec_irq(lruvec);
}
static void commit_charge(struct page *page, struct mem_cgroup *memcg,
Powered by blists - more mailing lists