https://github.com/torvalds/linux
Revision 928501344fc645f80390afc12708c81b3595745d authored by Andrey Konovalov on 26 February 2021, 01:19:55 UTC, committed by Linus Torvalds on 26 February 2021, 17:41:02 UTC
Patch series "kasan: optimizations and fixes for HW_TAGS", v4.

This patchset makes the HW_TAGS mode more efficient, mostly by reworking
poisoning approaches and simplifying/inlining some internal helpers.

With this change, the overhead of HW_TAGS annotations excluding setting
and checking memory tags is ~3%.  The performance impact caused by tags
will be unknown until we have hardware that supports MTE.

As a side-effect, this patchset speeds up generic KASAN by ~15%.

This patch (of 13):

Currently KASAN saves allocation stacks in both kasan_slab_alloc() and
kasan_kmalloc() annotations.  This patch changes KASAN to save allocation
stacks for slab objects from kmalloc caches in kasan_kmalloc() only, and
stacks for other slab objects in kasan_slab_alloc() only.

This change requires ____kasan_kmalloc() knowing whether the object
belongs to a kmalloc cache.  This is implemented by adding a flag field to
the kasan_info structure.  That flag is only set for kmalloc caches via a
new kasan_cache_create_kmalloc() annotation.

Link: https://lkml.kernel.org/r/cover.1612546384.git.andreyknvl@google.com
Link: https://lkml.kernel.org/r/7c673ebca8d00f40a7ad6f04ab9a2bddeeae2097.1612546384.git.andreyknvl@google.com
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
Reviewed-by: Marco Elver <elver@google.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Vincenzo Frascino <vincenzo.frascino@arm.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Peter Collingbourne <pcc@google.com>
Cc: Evgenii Stepanov <eugenis@google.com>
Cc: Branislav Rankov <Branislav.Rankov@arm.com>
Cc: Kevin Brodsky <kevin.brodsky@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent d3a61f7
Raw File
Tip revision: 928501344fc645f80390afc12708c81b3595745d authored by Andrey Konovalov on 26 February 2021, 01:19:55 UTC
kasan, mm: don't save alloc stacks twice
Tip revision: 9285013
au88x0_eqdata.c
// SPDX-License-Identifier: GPL-2.0
/* Data structs */

static const u16 asEqCoefsZeros[50] = {
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};

static const u16 asEqCoefsPipes[64] = {
	0x0000, 0x0000,
	0x0000, 0x0666, 0x0000, 0x0000, 0x0666,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0666, 0x0000, 0x0000, 0x0666,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0666, 0x0000, 0x0000, 0x0666,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0666, 0x0000, 0x0000, 0x0666,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0666, 0x0000, 0x0000, 0x066a,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,

	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000
};

/* More coef sets can be found in the win2k "inf" file. */
static const auxxEqCoeffSet_t asEqCoefsNormal = {
	.LeftCoefs = {
		      0x7e60, 0xc19e, 0x0001, 0x0002, 0x0001,
		      0x7fa0, 0xc05f, 0x004f, 0x0000, 0xffb1,
		      0x7f3f, 0xc0bc, 0x00c2, 0x0000, 0xff3e,
		      0x7e78, 0xc177, 0x011f, 0x0000, 0xfee1,
		      0x7cd6, 0xc2e5, 0x025c, 0x0000, 0xfda4,
		      0x7949, 0xc5aa, 0x0467, 0x0000, 0xfb99,
		      0x7120, 0xcadf, 0x0864, 0x0000, 0xf79c,
		      0x5d33, 0xd430, 0x0f7e, 0x0000, 0xf082,
		      0x2beb, 0xe3ca, 0x1bd3, 0x0000, 0xe42d,
		      0xd740, 0xf01d, 0x2ac5, 0x0000, 0xd53b},

	.RightCoefs = {
		       0x7e60, 0xc19e, 0x0001, 0x0002, 0x0001,
		       0x7fa0, 0xc05f, 0x004f, 0x0000, 0xffb1,
		       0x7f3f, 0xc0bc, 0x00c2, 0x0000, 0xff3e,
		       0x7e78, 0xc177, 0x011f, 0x0000, 0xfee1,
		       0x7cd6, 0xc2e5, 0x025c, 0x0000, 0xfda4,
		       0x7949, 0xc5aa, 0x0467, 0x0000, 0xfb99,
		       0x7120, 0xcadf, 0x0864, 0x0000, 0xf79c,
		       0x5d33, 0xd430, 0x0f7e, 0x0000, 0xf082,
		       0x2beb, 0xe3ca, 0x1bd3, 0x0000, 0xe42d,
		       0xd740, 0xf01d, 0x2ac5, 0x0000, 0xd53b},

	.LeftGains = {
		      0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96,
		      0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96},
	.RightGains = {
		       0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96,
		       0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96}
};

static const u16 eq_gains_normal[20] = {
	0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96,
	0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96,
	0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96,
	0x3e96, 0x3e96, 0x3e96, 0x3e96, 0x3e96
};

/* _rodatab60 */
static const u16 eq_gains_zero[10] = {
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};

/* _rodatab7c:  ProgramPipe */
static const u16 eq_gains_current[12] = {
	0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff, 0x7fff,
	0x7fff,
	0x7fff, 0x7fff, 0x7fff
};

/* _rodatab78 */
static const u16 eq_states_zero[2] = { 0x0000, 0x0000 };

static const u16 asEqOutStateZeros[48] = {
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000
};

/*_rodataba0:*/
static const u16 eq_levels[64] = {
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
	0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000
};
back to top