Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp473044ybc; Tue, 19 Nov 2019 04:26:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxBkUNf75bLSlz66frTzIIrOtWjwXYwR61a3hzzsbGZ05sFEyjOfmk/8D94ibp5iBSwuquJ X-Received: by 2002:a17:906:970a:: with SMTP id k10mr5021734ejx.314.1574166363080; Tue, 19 Nov 2019 04:26:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574166363; cv=none; d=google.com; s=arc-20160816; b=etQUBNGEw12+UOgZpbCk/POr4U3LqRVimlyY+KOhc3RG3VBgoyulunYv3ROZghywx3 lclIu3E31ZoZ1Z3ni4DZn4ZYudOGGNrDPefavz11Lt5vmzJPFqIQ7iGfS6DLu9M4jjWZ R3aPXpHLoDNs8ZsQK+JApL9k2hSkrFjVvQ4xfP7XFVa7NHemDkgrJW++odezmIFV2vZZ gCT6CKFFAigrYssY+PJijLHpnV1oG9dmScqtxJB5E8lj7atzdePd+YlzQSZSi0WynlsB ZN33pJ50EbD+KPRcOF4gYO0VYfP3DF3fHr3AYFmxnDE616SMICmZco7m/VGckTvI+ccw eK7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=Zn+GnsJI4yjYIfPltBZiFYuGkZVJtv5Ex7qZEUNca9w=; b=zfHNcVoNN2uayZ+pDuNLJtAGinIozCzXqHJp3+BlYqGXbDDiXFTCiav/2S5nPsRXPz 6N/M+m8OVnMUlF6fw4xI5Xjq+mTkZyoyMW8g9O3s1cXEYqKJ61qmGsnmmI0JaGaKI5mB MRLRaFEIuLklQ+bLKk0AacQ2sWJG61qb65IBJ1HOybK014tuCO0WLseZypUEUmNGnjnX PnANIviMe0UV4qCaC3IkuK4C/s3jusTQ3N8TJ6nq+FKY6og+Xu6EfZl8u8Fm4R8sv1Qc 2wHFaurblUGyqCvwVp38UDKpkHbEys0FxIWAwZSpyJug1e/xDqYBqPxgibIVIo6yKVEV ZweA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c1si14612243eds.170.2019.11.19.04.25.39; Tue, 19 Nov 2019 04:26:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbfKSMYV (ORCPT + 99 others); Tue, 19 Nov 2019 07:24:21 -0500 Received: from out30-132.freemail.mail.aliyun.com ([115.124.30.132]:60190 "EHLO out30-132.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfKSMYT (ORCPT ); Tue, 19 Nov 2019 07:24:19 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R151e4;CH=green;DM=||false|;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04446;MF=alex.shi@linux.alibaba.com;NM=1;PH=DS;RN=19;SR=0;TI=SMTPD_---0TiZ64Cj_1574166248; Received: from localhost(mailfrom:alex.shi@linux.alibaba.com fp:SMTPD_---0TiZ64Cj_1574166248) by smtp.aliyun-inc.com(127.0.0.1); Tue, 19 Nov 2019 20:24:08 +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 , Roman Gushchin , Chris Down , Thomas Gleixner Subject: [PATCH v4 8/9] mm/lru: likely enhancement Date: Tue, 19 Nov 2019 20:23:22 +0800 Message-Id: <1574166203-151975-9-git-send-email-alex.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1574166203-151975-1-git-send-email-alex.shi@linux.alibaba.com> References: <1574166203-151975-1-git-send-email-alex.shi@linux.alibaba.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 19ff453e2822..1787bbc4b059 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h @@ -1298,12 +1298,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); @@ -1320,12 +1320,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, *flags); diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 7e6387ad01f0..8c3ba90bdefc 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1257,7 +1257,7 @@ struct lruvec *lock_page_lruvec_irq(struct page *page, rcu_read_unlock(); /* 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; } @@ -1277,7 +1277,7 @@ struct lruvec *lock_page_lruvec_irqsave(struct page *page, rcu_read_unlock(); /* 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, *flags); goto again; } -- 1.8.3.1