Re: Crash when CONFIG_FORCE_NR_CPUS is set and nr_cpus does not match

From: Linus Torvalds
Date: Tue Jun 18 2024 - 11:45:24 EST


On Tue, 18 Jun 2024 at 07:50, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
>
> I was confused to how rtpcp could be passing in a NULL pointer as it is
> a per cpu variable set up at boot. But I also noticed I was hitting
> this warning at boot up which I've been ignoring but now find it is
> related:
>
> [ 0.128523] ------------[ cut here ]------------
> [ 0.129275] WARNING: CPU: 0 PID: 0 at include/linux/cpumask.h:48 setup_nr_cpu_ids+0x11/0x30

Yeah, that warning very much means "you aren't running a valid config".

That said, I think FORCE_NR_CPUS was a mistake. It improves bitmask op
code generation a tiny bit (quite a lot actually on a micro level, but
not necessarily hugely noticeable in the big picture) by making
nr_cpu_ids a compile-time constant, but it's such a special-case
embedded-only (or "tuned for my particular machine") option that it's
just not worth it.

It's behind "EXPERT", and while that *should* mean that it doesn't get
enabled by default, I think the fact that many distros enable EXPERT
in their default distro config means that the whole thing has lost all
meaning.

If you start out with the distro config, you're magically an expert.
And when everybody is an expert, no one is.

Linus