From patchwork Sat Nov 16 03:15:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 11247445 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 15B801393 for ; Sat, 16 Nov 2019 03:16:13 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E082420700 for ; Sat, 16 Nov 2019 03:16:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E082420700 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 190186B0010; Fri, 15 Nov 2019 22:16:12 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0F3716B0266; Fri, 15 Nov 2019 22:16:12 -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 E60506B0269; Fri, 15 Nov 2019 22:16:11 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0109.hostedemail.com [216.40.44.109]) by kanga.kvack.org (Postfix) with ESMTP id D20E36B0010 for ; Fri, 15 Nov 2019 22:16:11 -0500 (EST) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 8D80C180AD837 for ; Sat, 16 Nov 2019 03:16:11 +0000 (UTC) X-FDA: 76160676942.24.cover24_18db11c76ae4a X-Spam-Summary: 2,0,0,57826b75fc03e2f0,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:willy@infradead.org:hannes@cmpxchg.org:mhocko@kernel.org:vdavydov.dev@gmail.com:guro@fb.com:shakeelb@google.com:chris@chrisdown.name:tglx@linutronix.de,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1261:1345:1359:1431:1437:1534:1542:1711:1730:1747:1777:1792:2393:2553:2559:2562:3138:3139:3140:3141:3142:3353:3867:3870:4321:4605:5007:6261:6737:7514:10004:11026:11658:11914:12043:12048:12296:12297:12438:12555:12895:13846:14096:14181:14394:14721:14915:21060:21080:21451:21627:30054:30064:30090,0,RBL:115.124.30.44:@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, X-HE-Tag: cover24_18db11c76ae4a X-Filterd-Recvd-Size: 4291 Received: from out30-44.freemail.mail.aliyun.com (out30-44.freemail.mail.aliyun.com [115.124.30.44]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Sat, 16 Nov 2019 03:16:10 +0000 (UTC) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R691e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04420;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0TiBsg6x_1573874111; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TiBsg6x_1573874111) by smtp.aliyun-inc.com(127.0.0.1); Sat, 16 Nov 2019 11:15:11 +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, willy@infradead.org Cc: Johannes Weiner , Michal Hocko , Vladimir Davydov , Roman Gushchin , Shakeel Butt , Chris Down , Thomas Gleixner Subject: [PATCH v3 6/7] mm/lru: likely enhancement Date: Sat, 16 Nov 2019 11:15:05 +0800 Message-Id: <1573874106-23802-7-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1573874106-23802-1-git-send-email-alex.shi@linux.alibaba.com> References: <1573874106-23802-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: Use likely() to remove speculations according to pagevec usage. Signed-off-by: Alex Shi Cc: Johannes Weiner Cc: Michal Hocko Cc: Vladimir Davydov Cc: Andrew Morton Cc: Roman Gushchin Cc: Shakeel Butt Cc: Chris Down Cc: Tejun Heo Cc: Thomas Gleixner Cc: linux-kernel@vger.kernel.org Cc: cgroups@vger.kernel.org Cc: linux-mm@kvack.org --- include/linux/memcontrol.h | 8 ++++---- mm/memcontrol.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index eaec01fb627f..5c49fe1ee9fe 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1297,12 +1297,12 @@ static inline struct lruvec *relock_page_lruvec_irq(struct page *page, struct pglist_data *pgdat = page_pgdat(page); struct lruvec *lruvec; - if (!locked_lruvec) + if (unlikely(!locked_lruvec)) goto lock; lruvec = mem_cgroup_page_lruvec(page, pgdat); - if (locked_lruvec == lruvec) + if (likely(locked_lruvec == lruvec)) return lruvec; spin_unlock_irq(&locked_lruvec->lru_lock); @@ -1319,12 +1319,12 @@ static inline struct lruvec *relock_page_lruvec_irqsave(struct page *page, struct pglist_data *pgdat = page_pgdat(page); struct lruvec *lruvec; - if (!locked_lruvec) + if (unlikely(!locked_lruvec)) goto lock; lruvec = mem_cgroup_page_lruvec(page, pgdat); - if (locked_lruvec == lruvec) + if (likely(locked_lruvec == lruvec)) return lruvec; spin_unlock_irqrestore(&locked_lruvec->lru_lock, locked_lruvec->irqflags); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index cf274739e619..75b8480bed69 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1256,7 +1256,7 @@ struct lruvec *lock_page_lruvec_irq(struct page *page, spin_lock_irq(&lruvec->lru_lock); /* lruvec may changed in commit_charge() */ - if (lruvec != mem_cgroup_page_lruvec(page, pgdat)) { + if (unlikely(lruvec != mem_cgroup_page_lruvec(page, pgdat))) { spin_unlock_irq(&lruvec->lru_lock); goto again; } @@ -1274,7 +1274,7 @@ struct lruvec *lock_page_lruvec_irqsave(struct page *page, spin_lock_irqsave(&lruvec->lru_lock, lruvec->irqflags); /* lruvec may changed in commit_charge() */ - if (lruvec != mem_cgroup_page_lruvec(page, pgdat)) { + if (unlikely(lruvec != mem_cgroup_page_lruvec(page, pgdat))) { spin_unlock_irqrestore(&lruvec->lru_lock, lruvec->irqflags); goto again; }