]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled
authorSuren Baghdasaryan <surenb@google.com>
Thu, 26 Dec 2024 21:16:38 +0000 (13:16 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 8 Feb 2025 09:02:05 +0000 (10:02 +0100)
commit7cb6f64d7c1ecec52ecdedc8f6126ea8b4c420cf
tree9178e102997b2e56751331115935544ff1293218
parent481136234dfe96c7f92770829bec6111c7c5f5dd
alloc_tag: avoid current->alloc_tag manipulations when profiling is disabled

[ Upstream commit 07438779313caafe52ac1a1a6958d735a5938988 ]

When memory allocation profiling is disabled there is no need to update
current->alloc_tag and these manipulations add unnecessary overhead.  Fix
the overhead by skipping these extra updates.

I ran comprehensive testing on Pixel 6 on Big, Medium and Little cores:

                 Overhead before fixes            Overhead after fixes
                 slab alloc      page alloc          slab alloc      page alloc
Big               6.21%           5.32%                3.31%          4.93%
Medium            4.51%           5.05%                3.79%          4.39%
Little            7.62%           1.82%                6.68%          1.02%

This is an allocation microbenchmark doing allocations in a tight loop.
Not a really realistic scenario and useful only to make performance
comparisons.

Link: https://lkml.kernel.org/r/20241226211639.1357704-1-surenb@google.com
Fixes: b951aaff5035 ("mm: enable page allocation tagging")
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: David Wang <00107082@163.com>
Cc: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Yu Zhao <yuzhao@google.com>
Cc: Zhenhua Huang <quic_zhenhuah@quicinc.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/alloc_tag.h
lib/alloc_tag.c