[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CA+fCnZcBGhToB+pOhn+ACahyqVLWJ_7cnqBNZC5ob77wZD5iJw@mail.gmail.com>
Date: Sat, 6 Sep 2025 19:18:41 +0200
From: Andrey Konovalov <andreyknvl@...il.com>
To: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
Cc: sohil.mehta@...el.com, baohua@...nel.org, david@...hat.com,
kbingham@...nel.org, weixugc@...gle.com, Liam.Howlett@...cle.com,
alexandre.chartre@...cle.com, kas@...nel.org, mark.rutland@....com,
trintaeoitogc@...il.com, axelrasmussen@...gle.com, yuanchu@...gle.com,
joey.gouly@....com, samitolvanen@...gle.com, joel.granados@...nel.org,
graf@...zon.com, vincenzo.frascino@....com, kees@...nel.org, ardb@...nel.org,
thiago.bauermann@...aro.org, glider@...gle.com, thuth@...hat.com,
kuan-ying.lee@...onical.com, pasha.tatashin@...een.com,
nick.desaulniers+lkml@...il.com, vbabka@...e.cz, kaleshsingh@...gle.com,
justinstitt@...gle.com, catalin.marinas@....com,
alexander.shishkin@...ux.intel.com, samuel.holland@...ive.com,
dave.hansen@...ux.intel.com, corbet@....net, xin@...or.com,
dvyukov@...gle.com, tglx@...utronix.de, scott@...amperecomputing.com,
jason.andryuk@....com, morbo@...gle.com, nathan@...nel.org,
lorenzo.stoakes@...cle.com, mingo@...hat.com, brgerst@...il.com,
kristina.martsenko@....com, bigeasy@...utronix.de, luto@...nel.org,
jgross@...e.com, jpoimboe@...nel.org, urezki@...il.com, mhocko@...e.com,
ada.coupriediaz@....com, hpa@...or.com, leitao@...ian.org,
peterz@...radead.org, wangkefeng.wang@...wei.com, surenb@...gle.com,
ziy@...dia.com, smostafa@...gle.com, ryabinin.a.a@...il.com,
ubizjak@...il.com, jbohac@...e.cz, broonie@...nel.org,
akpm@...ux-foundation.org, guoweikang.kernel@...il.com, rppt@...nel.org,
pcc@...gle.com, jan.kiszka@...mens.com, nicolas.schier@...ux.dev,
will@...nel.org, jhubbard@...dia.com, bp@...en8.de, x86@...nel.org,
linux-doc@...r.kernel.org, linux-mm@...ck.org, llvm@...ts.linux.dev,
linux-kbuild@...r.kernel.org, kasan-dev@...glegroups.com,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v5 12/19] x86: Minimal SLAB alignment
On Mon, Aug 25, 2025 at 10:29 PM Maciej Wieczor-Retman
<maciej.wieczor-retman@...el.com> wrote:
>
> 8 byte minimal SLAB alignment interferes with KASAN's granularity of 16
> bytes. It causes a lot of out-of-bounds errors for unaligned 8 byte
> allocations.
>
> Compared to a kernel with KASAN disabled, the memory footprint increases
> because all kmalloc-8 allocations now are realized as kmalloc-16, which
> has twice the object size. But more meaningfully, when compared to a
> kernel with generic KASAN enabled, there is no difference. Because of
> redzones in generic KASAN, kmalloc-8' and kmalloc-16' object size is the
> same (48 bytes). So changing the minimal SLAB alignment of the tag-based
> mode doesn't have any negative impact when compared to the other
> software KASAN mode.
>
> Adjust x86 minimal SLAB alignment to match KASAN granularity size.
>
> Signed-off-by: Maciej Wieczor-Retman <maciej.wieczor-retman@...el.com>
> ---
> Changelog v4:
> - Extend the patch message with some more context and impact
> information.
>
> Changelog v3:
> - Fix typo in patch message 4 -> 16.
> - Change define location to arch/x86/include/asm/cache.c.
>
> arch/x86/include/asm/cache.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
> index 69404eae9983..3232583b5487 100644
> --- a/arch/x86/include/asm/cache.h
> +++ b/arch/x86/include/asm/cache.h
> @@ -21,4 +21,8 @@
> #endif
> #endif
>
> +#ifdef CONFIG_KASAN_SW_TAGS
> +#define ARCH_SLAB_MINALIGN (1ULL << KASAN_SHADOW_SCALE_SHIFT)
> +#endif
> +
> #endif /* _ASM_X86_CACHE_H */
> --
> 2.50.1
>
Reviewed-by: Andrey Konovalov <andreyknvl@...il.com>
Powered by blists - more mailing lists