From patchwork Tue Nov 12 14:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11239375 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 B5453159A for ; Tue, 12 Nov 2019 14:07:22 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 7F14B21783 for ; Tue, 12 Nov 2019 14:07:22 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F14B21783 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 7D4D46B0266; Tue, 12 Nov 2019 09:07:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 785696B0269; Tue, 12 Nov 2019 09:07:21 -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 6C1D06B026A; Tue, 12 Nov 2019 09:07:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id 569326B0266 for ; Tue, 12 Nov 2019 09:07:21 -0500 (EST) Received: from smtpin01.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 189092AAE for ; Tue, 12 Nov 2019 14:07:21 +0000 (UTC) X-FDA: 76147802682.01.cup78_5d08754d40b3b X-Spam-Summary: 2,0,0,110d454e82adb348,d41d8cd98f00b204,alex.shi@linux.alibaba.com,: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:hannes@cmpxchg.org:guro@fb.com:shakeelb@google.com:chris@chrisdown.name:tglx@linutronix.de,RULES_HIT:41:69:355:379:541:800:960:968:973:988:989:1260:1261:1345:1359:1431:1437:1534:1542:1711:1730:1747:1777:1792:2194:2199:2393:2559:2562:3138:3139:3140:3141:3142:3353:3865:3867:3871:4321:4419:5007:6261:6737:9592:10004:11026:11658:11914:12043:12048:12050:12296:12297:12438:12555:12895:13161:13221:13229:13846:14096:14181:14394:14721:14915:21060:21080:21324:21451:21627:30054:30055:30064:30075,0,RBL:115.124.30.133:@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,MSB L:0,DNSB X-HE-Tag: cup78_5d08754d40b3b X-Filterd-Recvd-Size: 3874 Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) by imf14.hostedemail.com (Postfix) with ESMTP for ; Tue, 12 Nov 2019 14:07:18 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=16;SR=0;TI=SMTPD_---0Thuhzkb_1573567601; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0Thuhzkb_1573567601) by smtp.aliyun-inc.com(127.0.0.1); Tue, 12 Nov 2019 22:06:41 +0800 From: Alex Shi To: alex.shi@linux.alibaba.com, 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 Cc: Johannes Weiner , Roman Gushchin , Shakeel Butt , Chris Down , Thomas Gleixner Subject: [PATCH v2 6/8] mm/lru: remove rcu_read_lock to fix performance regression Date: Tue, 12 Nov 2019 22:06:26 +0800 Message-Id: <1573567588-47048-7-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573567588-47048-1-git-send-email-alex.shi@linux.alibaba.com> References: <1573567588-47048-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: Intel 0day report there are performance regression on this patchset. The detailed info points to rcu_read_lock + PROVE_LOCKING which causes queued_spin_lock_slowpath waiting too long time to get lock. Remove rcu_read_lock is safe here since we had a spinlock hold. Reported-by: kbuild test robot Signed-off-by: Alex Shi Cc: Andrew Morton Cc: Johannes Weiner Cc: Roman Gushchin Cc: Shakeel Butt Cc: Chris Down Cc: Tejun Heo Cc: Thomas Gleixner Cc: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Alex Shi --- include/linux/memcontrol.h | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index 2421b720d272..f869897a68f0 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1307,20 +1307,18 @@ static inline struct lruvec *relock_page_lruvec_irq(struct page *page, struct pglist_data *pgdat = page_pgdat(page); struct lruvec *lruvec; - rcu_read_lock(); + if (!locked_lruvec) + goto lock; + lruvec = mem_cgroup_page_lruvec(page, pgdat); - if (locked_lruvec == lruvec) { - rcu_read_unlock(); + if (locked_lruvec == lruvec) return lruvec; - } - rcu_read_unlock(); - if (locked_lruvec) - spin_unlock_irq(&locked_lruvec->lru_lock); + spin_unlock_irq(&locked_lruvec->lru_lock); +lock: lruvec = lock_page_lruvec_irq(page, pgdat); - return lruvec; } @@ -1331,21 +1329,18 @@ static inline struct lruvec *relock_page_lruvec_irqsave(struct page *page, struct pglist_data *pgdat = page_pgdat(page); struct lruvec *lruvec; - rcu_read_lock(); + if (!locked_lruvec) + goto lock; + lruvec = mem_cgroup_page_lruvec(page, pgdat); - if (locked_lruvec == lruvec) { - rcu_read_unlock(); + if (locked_lruvec == lruvec) return lruvec; - } - rcu_read_unlock(); - if (locked_lruvec) - spin_unlock_irqrestore(&locked_lruvec->lru_lock, - locked_lruvec->flags); + spin_unlock_irqrestore(&locked_lruvec->lru_lock, locked_lruvec->flags); +lock: lruvec = lock_page_lruvec_irqsave(page, pgdat); - return lruvec; }