From: Mateusz Guzik <mjguzik@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: yuzhao@google.com, akpm@linux-foundation.org,
willy@infradead.org, linux-kernel@vger.kernel.org,
linux-mm@kvack.org
Subject: Re: [PATCH] mm: remove an avoidable load of page refcount in page_ref_add_unless
Date: Mon, 9 Dec 2024 15:30:13 +0100 [thread overview]
Message-ID: <CAGudoHGUwS_zY1KWStMtKoy=eogLigy7ucpEQXzTZGANU=35Jw@mail.gmail.com> (raw)
In-Reply-To: <f5a65bf5-5105-4376-9c1c-164a15a4ab79@redhat.com>
On Mon, Dec 9, 2024 at 3:22 PM David Hildenbrand <david@redhat.com> wrote:
>
> On 09.12.24 13:33, Mateusz Guzik wrote:
> > That is to say I think this thread just about exhausted the time
> > warranted by this patch. No hard feelz if it gets dropped, but then I
> > do strongly suggest adding a justification to the extra load.
>
> Maybe it's sufficient for now to simply do your change with a comment:
>
> diff --git a/include/linux/page_ref.h b/include/linux/page_ref.h
> index 8c236c651d1d6..1efc992ad5687 100644
> --- a/include/linux/page_ref.h
> +++ b/include/linux/page_ref.h
> @@ -234,7 +234,13 @@ static inline bool page_ref_add_unless(struct page *page, int nr, int u)
>
> rcu_read_lock();
> /* avoid writing to the vmemmap area being remapped */
> - if (!page_is_fake_head(page) && page_ref_count(page) != u)
> + if (!page_is_fake_head(page))
> + /*
> + * atomic_add_unless() will currently never modify the value
> + * if it already is u. If that ever changes, we'd have to have
> + * a separate check here, such that we won't be writing to
> + * write-protected vmemmap areas.
> + */
> ret = atomic_add_unless(&page->_refcount, nr, u);
> rcu_read_unlock();
>
>
> It would bail out during testing ... hopefully, such that we can detect any such change.
>
Not my call to make, but looks good. ;)
fwiw I don't need any credit and I would be more than happy if you
just submitted the thing as your own without me being mentioned. *No*
cc would also be appreciated.
--
Mateusz Guzik <mjguzik gmail.com>
next prev parent reply other threads:[~2024-12-09 14:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-07 8:29 Mateusz Guzik
2024-12-09 9:28 ` David Hildenbrand
2024-12-09 10:25 ` Mateusz Guzik
2024-12-09 10:56 ` David Hildenbrand
2024-12-09 12:33 ` Mateusz Guzik
2024-12-09 14:22 ` David Hildenbrand
2024-12-09 14:30 ` Mateusz Guzik [this message]
2024-12-09 14:46 ` David Hildenbrand
2025-01-07 4:41 ` Yu Zhao
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='CAGudoHGUwS_zY1KWStMtKoy=eogLigy7ucpEQXzTZGANU=35Jw@mail.gmail.com' \
--to=mjguzik@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.org \
--cc=yuzhao@google.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