mm: alloc_tag: change the KASAN_TAG_WIDTH for HW_TAGS
Subsystems (2)
PATCH 1/1 mm: alloc_tag: change the KASAN_TAG_WIDTH for HW_TAGS
the KASAN_TAG_WIDTH is 8 bits for both (HW_TAGS and SW_TAGS), but for HW_TAGS the KASAN_TAG_WIDTH can be 4 bits bits because due to the design of the MTE the memory words for storing metadata only need 4 bits. Change the preprocessor define KASAN_TAG_WIDTH for check if SW_TAGS is define, so KASAN_TAG_WIDTH should be 8 bits, but if HW_TAGS is define, so KASAN_TAG_WIDTH should be 4 bits.
--- include/linux/page-flags-layout.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/page-flags-layout.h +3 -1
@@ -72,8 +72,10 @@#define NODE_NOT_IN_PAGE_FLAGS 1#endif -#if defined(CONFIG_KASAN_SW_TAGS ) || defined(CONFIG_KASAN_HW_TAGS ) +#if defined(CONFIG_KASAN_SW_TAGS )#define KASAN_TAG_WIDTH 8 +#elif defined(CONFIG_KASAN_HW_TAGS ) +#define KASAN_TAG_WIDTH 4#else #define KASAN_TAG_WIDTH 0#endif
Signature · 1 line
2.34.1
Andrew Morton
maintainerQuoted 6 lines · On Sat, 26 Apr 2025 15:08:37 -0300 Guilherme Giacomo Simoes…
the
KASAN_TAG_WIDTHis 8 bits for both (HW_TAGSandSW_TAGS), but forHW_TAGStheKASAN_TAG_WIDTHcan be 4 bits bits because due to the design of the MTE the memory words for storing metadata only need 4 bits. Change the preprocessor defineKASAN_TAG_WIDTHfor check ifSW_TAGSis define, soKASAN_TAG_WIDTHshould be 8 bits, but ifHW_TAGSis define, soKASAN_TAG_WIDTHshould be 4 bits.
Why?
I assume the effect is to save a few flags bits under some circumstances? But that's just me guessing - please fully describe the motivation and effects within changelogs.
Quoted 7 lines · Andrew Morton
Quoted 6 lines
the
KASAN_TAG_WIDTHis 8 bits for both (HW_TAGSandSW_TAGS), but forHW_TAGStheKASAN_TAG_WIDTHcan be 4 bits bits because due to the design of the MTE the memory words for storing metadata only need 4 bits. Change the preprocessor defineKASAN_TAG_WIDTHfor check ifSW_TAGSis define, soKASAN_TAG_WIDTHshould be 8 bits, but ifHW_TAGSis define, soKASAN_TAG_WIDTHshould be 4 bits.
Quoted 5 lines
Why?
I assume the effect is to save a few flags bits under some circumstances? But that's just me guessing - please fully describe the motivation and effects within changelogs.
Ok, I will change the commit message with the "why", and send a v2.
Thanks.