From: Alex Shi <alex.shi@linux.alibaba.com>
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 <hannes@cmpxchg.org>,
Michal Hocko <mhocko@kernel.org>,
Vladimir Davydov <vdavydov.dev@gmail.com>,
Roman Gushchin <guro@fb.com>, Shakeel Butt <shakeelb@google.com>,
Chris Down <chris@chrisdown.name>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH v3 6/7] mm/lru: likely enhancement
Date: Sat, 16 Nov 2019 11:15:05 +0800 [thread overview]
Message-ID: <1573874106-23802-7-git-send-email-alex.shi@linux.alibaba.com> (raw)
In-Reply-To: <1573874106-23802-1-git-send-email-alex.shi@linux.alibaba.com>
Use likely() to remove speculations according to pagevec usage.
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Chris Down <chris@chrisdown.name>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
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;
}
--
1.8.3.1
next prev parent reply other threads:[~2019-11-16 3:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-16 3:14 [PATCH v3 0/8] per lruvec lru_lock for memcg Alex Shi
2019-11-16 3:15 ` [PATCH v3 1/7] mm/lru: add per lruvec lock " Alex Shi
2019-11-16 6:28 ` Shakeel Butt
2019-11-18 2:44 ` Alex Shi
2019-11-18 12:08 ` Matthew Wilcox
2019-11-18 12:37 ` Alex Shi
2019-11-19 10:05 ` Alex Shi
2019-11-16 3:15 ` [PATCH v3 2/7] mm/lruvec: add irqsave flags into lruvec struct Alex Shi
2019-11-16 6:31 ` Shakeel Butt
2019-11-18 2:52 ` Alex Shi
2019-11-22 6:46 ` Christoph Hellwig
2019-11-16 3:15 ` [PATCH v3 3/7] mm/lru: replace pgdat lru_lock with lruvec lock Alex Shi
2019-11-16 4:38 ` Matthew Wilcox
2019-11-18 11:55 ` Alex Shi
2019-11-18 12:14 ` Matthew Wilcox
2019-11-18 12:31 ` Alex Shi
2019-11-18 12:34 ` Matthew Wilcox
2019-11-19 10:14 ` Alex Shi
2019-11-16 7:03 ` Shakeel Butt
2019-11-18 12:23 ` Alex Shi
2019-11-18 12:31 ` Matthew Wilcox
2019-11-19 10:08 ` Alex Shi
2019-11-18 16:11 ` Johannes Weiner
2019-11-19 10:04 ` Alex Shi
2019-11-19 2:10 ` Daniel Jordan
2019-11-19 10:10 ` Alex Shi
2019-11-16 3:15 ` [PATCH v3 4/7] mm/lru: only change the lru_lock iff page's lruvec is different Alex Shi
2019-11-16 3:15 ` [PATCH v3 5/7] mm/pgdat: remove pgdat lru_lock Alex Shi
2019-11-16 3:15 ` Alex Shi [this message]
2019-11-16 3:15 ` [PATCH v3 7/7] mm/lru: revise the comments of lru_lock Alex Shi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1573874106-23802-7-git-send-email-alex.shi@linux.alibaba.com \
--to=alex.shi@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=chris@chrisdown.name \
--cc=daniel.m.jordan@oracle.com \
--cc=guro@fb.com \
--cc=hannes@cmpxchg.org \
--cc=hughd@google.com \
--cc=khlebnikov@yandex-team.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=mhocko@kernel.org \
--cc=shakeelb@google.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=vdavydov.dev@gmail.com \
--cc=willy@infradead.org \
--cc=yang.shi@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).