From: Arnd Bergmann <arnd@kernel.org>
To: Dennis Zhou <dennis@kernel.org>, Tejun Heo <tj@kernel.org>,
Christoph Lameter <cl@linux.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <will@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>, kernel test robot <lkp@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Kent Overstreet <kent.overstreet@linux.dev>,
Hou Tao <houtao1@huawei.com>, Jan Kara <jack@suse.cz>,
Jianhui Zhou <912460177@qq.com>,
Yury Norov <yury.norov@gmail.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH] preempt_rt: increase PERCPU_DYNAMIC_SIZE_SHIFT for slab randomization
Date: Fri, 4 Oct 2024 09:56:56 +0000 [thread overview]
Message-ID: <20241004095702.637528-1-arnd@kernel.org> (raw)
From: Arnd Bergmann <arnd@arndb.de>
When both PREEMPT_RT and RANDOM_KMALLOC_CACHES are enabled, the slub allocator
runs into a build time failure:
In file included from <command-line>:
In function 'alloc_kmem_cache_cpus',
inlined from 'do_kmem_cache_create' at mm/slub.c:6041:7:
include/linux/compiler_types.h:517:45: error: call to '__compiletime_assert_598' declared with attribute error: BUILD_BUG_ON failed: PERCPU_DYNAMIC_EARLY_SIZE < NR_KMALLOC_TYPES * KMALLOC_SHIFT_HIGH * sizeof(struct kmem_cache_cpu)
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
include/linux/compiler_types.h:498:25: note: in definition of macro '__compiletime_assert'
498 | prefix ## suffix(); \
| ^~~~~~
include/linux/compiler_types.h:517:9: note: in expansion of macro '_compiletime_assert'
517 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:9: note: in expansion of macro 'BUILD_BUG_ON_MSG'
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
mm/slub.c:5133:9: note: in expansion of macro 'BUILD_BUG_ON'
5133 | BUILD_BUG_ON(PERCPU_DYNAMIC_EARLY_SIZE <
| ^~~~~~~~~~~~
The problem is the additional size overhead from local_lock in
struct kmem_cache_cpu. Avoid this by preallocating a larger area.
Fixes: d8fccd9ca5f9 ("arm64: Allow to enable PREEMPT_RT.")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410020326.iaZIteIx-lkp@intel.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
There is a good chance that there is a better way to address this, this
version was the first I came up with and I verified that it fixes all of
the broken configs.
See https://pastebin.com/raw/tuPgfPzu for a .config from a failing
randconfig build on 6.12-rc1.
---
include/linux/percpu.h | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/include/linux/percpu.h b/include/linux/percpu.h
index b6321fc49159..4083295da27f 100644
--- a/include/linux/percpu.h
+++ b/include/linux/percpu.h
@@ -41,7 +41,11 @@
PCPU_MIN_ALLOC_SHIFT)
#ifdef CONFIG_RANDOM_KMALLOC_CACHES
+#ifdef CONFIG_PREEMPT_RT
+#define PERCPU_DYNAMIC_SIZE_SHIFT 13
+#else
#define PERCPU_DYNAMIC_SIZE_SHIFT 12
+#endif
#else
#define PERCPU_DYNAMIC_SIZE_SHIFT 10
#endif
--
2.39.2
next reply other threads:[~2024-10-04 9:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-04 9:56 Arnd Bergmann [this message]
2024-10-07 10:43 ` [PATCH] preempt_rt: increase PERCPU_DYNAMIC_SIZE_SHIFT for slab randomization Sebastian Andrzej Siewior
2024-10-07 10:59 ` Arnd Bergmann
2024-10-07 12:22 ` Sebastian Andrzej Siewior
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241004095702.637528-1-arnd@kernel.org \
--to=arnd@kernel.org \
--cc=912460177@qq.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=bigeasy@linutronix.de \
--cc=cl@linux.com \
--cc=dennis@kernel.org \
--cc=houtao1@huawei.com \
--cc=jack@suse.cz \
--cc=kent.overstreet@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lkp@intel.com \
--cc=surenb@google.com \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=will@kernel.org \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).