From patchwork Mon Dec 16 09:26:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11293653 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0893B13B6 for ; Mon, 16 Dec 2019 09:28:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CFC43206D3 for ; Mon, 16 Dec 2019 09:28:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CFC43206D3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1A24E8E0010; Mon, 16 Dec 2019 04:28:17 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 152B08E000C; Mon, 16 Dec 2019 04:28:17 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 041BC8E0010; Mon, 16 Dec 2019 04:28:16 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id E1C1F8E000C for ; Mon, 16 Dec 2019 04:28:16 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 9E1669407 for ; Mon, 16 Dec 2019 09:28:16 +0000 (UTC) X-FDA: 76270478592.08.jail56_482a759d22636 X-Spam-Summary: 2,0,0,c3a1129b9c205da8,d41d8cd98f00b204,alex.shi@linux.alibaba.com,:cgroups@vger.kernel.org:linux-kernel@vger.kernel.org::akpm@linux-foundation.org:mgorman@techsingularity.net:tj@kernel.org:hughd@google.com:khlebnikov@yandex-team.ru:daniel.m.jordan@oracle.com:yang.shi@linux.alibaba.com:willy@infradead.org:shakeelb@google.com:hannes@cmpxchg.org:alex.shi@linux.alibaba.com:mhocko@kernel.org:vdavydov.dev@gmail.com,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1261:1345:1359:1431:1437:1534:1541:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3866:3867:3871:3872:5007:6261:6737:7514:8957:10004:11026:11473:11658:11914:12043:12048:12296:12297:12438:12555:12895:13069:13311:13357:13846:14096:14181:14384:14394:14721:14915:21060:21080:21451:21627:30054:30070,0,RBL:115.124.30.54:@linux.alibaba.com:.lbl8.mailshell.net-62.20.2.100 64.201.201.201,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,C ustom_ru X-HE-Tag: jail56_482a759d22636 X-Filterd-Recvd-Size: 3379 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 16 Dec 2019 09:28:15 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e07417;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0Tl3i.ek_1576488441; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Tl3i.ek_1576488441) by smtp.aliyun-inc.com(127.0.0.1); Mon, 16 Dec 2019 17:27:21 +0800 From: Alex Shi To: cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, mgorman@techsingularity.net, tj@kernel.org, hughd@google.com, khlebnikov@yandex-team.ru, daniel.m.jordan@oracle.com, yang.shi@linux.alibaba.com, willy@infradead.org, shakeelb@google.com, hannes@cmpxchg.org Cc: Alex Shi , Michal Hocko , Vladimir Davydov Subject: [PATCH v6 09/10] mm/memcg: fold lock in lock_page_lru Date: Mon, 16 Dec 2019 17:26:25 +0800 Message-Id: <1576488386-32544-10-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1576488386-32544-1-git-send-email-alex.shi@linux.alibaba.com> References: <1576488386-32544-1-git-send-email-alex.shi@linux.alibaba.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Andrew Morton Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org Cc: linux-kernel@vger.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,