From: Vlastimil Babka <vbabka@suse.cz>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Cc: Alexander Duyck <alexander.duyck@gmail.com>,
Alex Shi <alex.shi@linux.alibaba.com>,
Hugh Dickins <hughd@google.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH] memcg: Optimise relock_page_lruvec functions
Date: Mon, 25 Oct 2021 12:44:05 +0200 [thread overview]
Message-ID: <c0335508-7174-ae03-ad90-82a65d35b6d6@suse.cz> (raw)
In-Reply-To: <20211019125034.2799438-1-willy@infradead.org>
On 10/19/21 14:50, Matthew Wilcox (Oracle) wrote:
> Leave interrupts disabled when we change which lru lock is held.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Assuming lockdep is fine with e.g.:
spin_lock_irqsave(A);
spin_unlock(A);
spin_lock(B);
spin_unlock_irqrestore(B);
(with A and B of same class).
> ---
> 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);
> }
>
>
next prev parent reply other threads:[~2021-10-25 10:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 12:50 [PATCH] memcg: Optimise relock_page_lruvec functions Matthew Wilcox (Oracle)
2021-10-25 10:44 ` Vlastimil Babka [this message]
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=c0335508-7174-ae03-ad90-82a65d35b6d6@suse.cz \
--to=vbabka@suse.cz \
--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=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=willy@infradead.org \
/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).