All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: linux-mm@kvack.org
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Alexander Duyck <alexander.duyck@gmail.com>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	Hugh Dickins <hughd@google.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH] memcg: Optimise relock_page_lruvec functions
Date: Tue, 19 Oct 2021 13:50:34 +0100	[thread overview]
Message-ID: <20211019125034.2799438-1-willy@infradead.org> (raw)

Leave interrupts disabled when we change which lru lock is held.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
 include/linux/memcontrol.h | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 3096c9a0ee01..a6a90b00a22b 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1524,16 +1524,22 @@ static inline bool page_matches_lruvec(struct page *page, struct lruvec *lruvec)
 }
 
 /* Don't lock again iff page's lruvec locked */
-static inline struct lruvec *relock_page_lruvec_irq(struct page *page,
+static inline struct lruvec *relock_page_lruvec(struct page *page,
 		struct lruvec *locked_lruvec)
 {
-	if (locked_lruvec) {
-		if (page_matches_lruvec(page, locked_lruvec))
-			return locked_lruvec;
+	if (page_matches_lruvec(page, locked_lruvec))
+		return locked_lruvec;
 
-		unlock_page_lruvec_irq(locked_lruvec);
-	}
+	unlock_page_lruvec(locked_lruvec);
+	return lock_page_lruvec(page);
+}
 
+/* Don't lock again iff page's lruvec locked */
+static inline struct lruvec *relock_page_lruvec_irq(struct page *page,
+		struct lruvec *locked_lruvec)
+{
+	if (locked_lruvec)
+		return relock_page_lruvec(page, locked_lruvec);
 	return lock_page_lruvec_irq(page);
 }
 
@@ -1541,13 +1547,8 @@ static inline struct lruvec *relock_page_lruvec_irq(struct page *page,
 static inline struct lruvec *relock_page_lruvec_irqsave(struct page *page,
 		struct lruvec *locked_lruvec, unsigned long *flags)
 {
-	if (locked_lruvec) {
-		if (page_matches_lruvec(page, locked_lruvec))
-			return locked_lruvec;
-
-		unlock_page_lruvec_irqrestore(locked_lruvec, *flags);
-	}
-
+	if (locked_lruvec)
+		return relock_page_lruvec(page, locked_lruvec);
 	return lock_page_lruvec_irqsave(page, flags);
 }
 
-- 
2.32.0



             reply	other threads:[~2021-10-19 12:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-19 12:50 Matthew Wilcox (Oracle) [this message]
2021-10-25 10:44 ` [PATCH] memcg: Optimise relock_page_lruvec functions Vlastimil Babka
2021-10-25 11:16   ` Peter Zijlstra

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=20211019125034.2799438-1-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=alexander.duyck@gmail.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-mm@kvack.org \
    --cc=vbabka@suse.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.