From: Catalin Marinas <catalin.marinas@arm.com>
To: Peter Collingbourne <pcc@google.com>
Cc: andreyknvl@gmail.com, linux-mm@kvack.org,
kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com,
linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com,
will@kernel.org, eugenis@google.com
Subject: Re: [PATCH] kasan: call clear_page with a match-all tag instead of changing page tag
Date: Thu, 16 Feb 2023 14:27:47 +0000 [thread overview]
Message-ID: <Y+49Y4lD4GmDP8fc@arm.com> (raw)
In-Reply-To: <20230216064726.2724268-1-pcc@google.com>
On Wed, Feb 15, 2023 at 10:47:26PM -0800, Peter Collingbourne wrote:
> Instead of changing the page's tag solely in order to obtain a pointer
> with a match-all tag and then changing it back again, just convert the
> pointer that we get from kmap_atomic() into one with a match-all tag
> before passing it to clear_page().
>
> On a certain microarchitecture, this has been observed to cause a
> measurable improvement in microbenchmark performance, presumably as a
> result of being able to avoid the atomic operations on the page tag.
Yeah, this would likely break the write streaming mode on some ARM CPUs.
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Link: https://linux-review.googlesource.com/id/I0249822cc29097ca7a04ad48e8eb14871f80e711
> ---
> include/linux/highmem.h | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index 44242268f53b..bbfa546dd602 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -245,12 +245,10 @@ static inline void clear_highpage(struct page *page)
>
> static inline void clear_highpage_kasan_tagged(struct page *page)
> {
> - u8 tag;
> + void *kaddr = kmap_atomic(page);
>
> - tag = page_kasan_tag(page);
> - page_kasan_tag_reset(page);
> - clear_highpage(page);
> - page_kasan_tag_set(page, tag);
> + clear_page(kasan_reset_tag(kaddr));
> + kunmap_atomic(kaddr);
> }
Please don't add kmap_atomic() back. See commit d2c20e51e396
("mm/highmem: remove deprecated kmap_atomic"). I'd duplicate the
clear_highpage() logic in here and call clear_page() directly on the
address with the kasan tag reset.
--
Catalin
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Catalin Marinas <catalin.marinas@arm.com>
To: Peter Collingbourne <pcc@google.com>
Cc: andreyknvl@gmail.com, linux-mm@kvack.org,
kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com,
linux-arm-kernel@lists.infradead.org, vincenzo.frascino@arm.com,
will@kernel.org, eugenis@google.com
Subject: Re: [PATCH] kasan: call clear_page with a match-all tag instead of changing page tag
Date: Thu, 16 Feb 2023 14:27:47 +0000 [thread overview]
Message-ID: <Y+49Y4lD4GmDP8fc@arm.com> (raw)
In-Reply-To: <20230216064726.2724268-1-pcc@google.com>
On Wed, Feb 15, 2023 at 10:47:26PM -0800, Peter Collingbourne wrote:
> Instead of changing the page's tag solely in order to obtain a pointer
> with a match-all tag and then changing it back again, just convert the
> pointer that we get from kmap_atomic() into one with a match-all tag
> before passing it to clear_page().
>
> On a certain microarchitecture, this has been observed to cause a
> measurable improvement in microbenchmark performance, presumably as a
> result of being able to avoid the atomic operations on the page tag.
Yeah, this would likely break the write streaming mode on some ARM CPUs.
> Signed-off-by: Peter Collingbourne <pcc@google.com>
> Link: https://linux-review.googlesource.com/id/I0249822cc29097ca7a04ad48e8eb14871f80e711
> ---
> include/linux/highmem.h | 8 +++-----
> 1 file changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/highmem.h b/include/linux/highmem.h
> index 44242268f53b..bbfa546dd602 100644
> --- a/include/linux/highmem.h
> +++ b/include/linux/highmem.h
> @@ -245,12 +245,10 @@ static inline void clear_highpage(struct page *page)
>
> static inline void clear_highpage_kasan_tagged(struct page *page)
> {
> - u8 tag;
> + void *kaddr = kmap_atomic(page);
>
> - tag = page_kasan_tag(page);
> - page_kasan_tag_reset(page);
> - clear_highpage(page);
> - page_kasan_tag_set(page, tag);
> + clear_page(kasan_reset_tag(kaddr));
> + kunmap_atomic(kaddr);
> }
Please don't add kmap_atomic() back. See commit d2c20e51e396
("mm/highmem: remove deprecated kmap_atomic"). I'd duplicate the
clear_highpage() logic in here and call clear_page() directly on the
address with the kasan tag reset.
--
Catalin
next prev parent reply other threads:[~2023-02-16 14:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 6:47 [PATCH] kasan: call clear_page with a match-all tag instead of changing page tag Peter Collingbourne
2023-02-16 6:47 ` Peter Collingbourne
2023-02-16 14:27 ` Catalin Marinas [this message]
2023-02-16 14:27 ` Catalin Marinas
2023-02-16 20:04 ` Peter Collingbourne
2023-02-16 20:04 ` Peter Collingbourne
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=Y+49Y4lD4GmDP8fc@arm.com \
--to=catalin.marinas@arm.com \
--cc=andreyknvl@gmail.com \
--cc=eugenis@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mm@kvack.org \
--cc=pcc@google.com \
--cc=ryabinin.a.a@gmail.com \
--cc=vincenzo.frascino@arm.com \
--cc=will@kernel.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 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.