[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1576488386-32544-10-git-send-email-alex.shi@linux.alibaba.com>
Date: Mon, 16 Dec 2019 17:26:25 +0800
From: Alex Shi <alex.shi@...ux.alibaba.com>
To: 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, hannes@...xchg.org
Cc: Alex Shi <alex.shi@...ux.alibaba.com>,
Michal Hocko <mhocko@...nel.org>,
Vladimir Davydov <vdavydov.dev@...il.com>
Subject: [PATCH v6 09/10] 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
---
mm/memcontrol.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 138f298b694f..f8e279487e1d 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -2621,9 +2621,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));
@@ -2637,17 +2638,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,
--
1.8.3.1
Powered by blists - more mailing lists