Commit 16d91faf authored by Peter Collingbourne's avatar Peter Collingbourne Committed by Andrew Morton

kasan: call clear_page with a match-all tag instead of changing page tag

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.

Link: https://lkml.kernel.org/r/20230216195924.3287772-1-pcc@google.comSigned-off-by: default avatarPeter Collingbourne <pcc@google.com>
Link: https://linux-review.googlesource.com/id/I0249822cc29097ca7a04ad48e8eb14871f80e711Reviewed-by: default avatarAndrey Konovalov <andreyknvl@gmail.com>
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Will Deacon <will@kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent af7df1c9
...@@ -243,12 +243,10 @@ static inline void clear_highpage(struct page *page) ...@@ -243,12 +243,10 @@ static inline void clear_highpage(struct page *page)
static inline void clear_highpage_kasan_tagged(struct page *page) static inline void clear_highpage_kasan_tagged(struct page *page)
{ {
u8 tag; void *kaddr = kmap_local_page(page);
tag = page_kasan_tag(page); clear_page(kasan_reset_tag(kaddr));
page_kasan_tag_reset(page); kunmap_local(kaddr);
clear_highpage(page);
page_kasan_tag_set(page, tag);
} }
#ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE #ifndef __HAVE_ARCH_TAG_CLEAR_HIGHPAGE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment