[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZhecyLQsGZ9Iv8wU@gmail.com>
Date: Thu, 11 Apr 2024 10:18:16 +0200
From: Ingo Molnar <mingo@...nel.org>
To: Josh Poimboeuf <jpoimboe@...nel.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
Linus Torvalds <torvalds@...ux-foundation.org>,
Daniel Sneddon <daniel.sneddon@...ux.intel.com>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Thomas Gleixner <tglx@...utronix.de>,
Alexandre Chartre <alexandre.chartre@...cle.com>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Peter Zijlstra <peterz@...radead.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Sean Christopherson <seanjc@...gle.com>,
Andrew Cooper <andrew.cooper3@...rix.com>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Nikolay Borisov <nik.borisov@...e.com>,
KP Singh <kpsingh@...nel.org>, Waiman Long <longman@...hat.com>,
Borislav Petkov <bp@...en8.de>
Subject: Re: [PATCH 7/7] x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with
CONFIG_MITIGATION_SPECTRE_BHI
* Ingo Molnar <mingo@...nel.org> wrote:
> > static enum bhi_mitigations bhi_mitigation __ro_after_init =
> > - IS_ENABLED(CONFIG_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF;
> > + IS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI_ON) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF;
>
> Uhm, after this patch there's no CONFIG_MITIGATION_SPECTRE_BHI_ON
> anymore, which is kindof nasty, as IS_ENABLED() doesn't generate a build
> failure for non-existent Kconfig variables IIRC ...
>
> So AFAICT this patch turns on BHI unconditionally.
BTW., this is why IS_ENABLED() is a bad primitive IMO:
kepler:~/tip> for N in $(git grep -w IS_ENABLED arch/x86/ | sed 's/.*IS_ENABLED(//g' | sed 's/).*//g' | sort | uniq | sed 's/^CONFIG_//g'); do printf "# %40s: " $N; git grep -E "^config $N$" -- '**Kconfig**' | wc -l; done | grep -w 0
# RESCTRL_RMID_DEPENDS_ON_CLOSID: 0
# NODE_NOT_IN_PAGE_FLAGS: 0
1)
CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID doesn't exist anymore, but is used
widely:
kepler:~/tip> git grep RESCTRL_RMID_DEPENDS_ON_CLOSID
arch/x86/kernel/cpu/resctrl/monitor.c: * Only allocated when CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID is defined.
arch/x86/kernel/cpu/resctrl/monitor.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
arch/x86/kernel/cpu/resctrl/monitor.c: if (!IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
arch/x86/kernel/cpu/resctrl/monitor.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID))
arch/x86/kernel/cpu/resctrl/monitor.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
arch/x86/kernel/cpu/resctrl/monitor.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
arch/x86/kernel/cpu/resctrl/monitor.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
arch/x86/kernel/cpu/resctrl/rdtgroup.c: if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) {
Each of those uses is bogus, as the Kconfig symbol doesn't exist. (!)
AFAICT CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID was never defined within the
upstream kernel (!!).
AFAICT the first bogus CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID use was
introduced in this recent commit:
b30a55df60c3 ("x86/resctrl: Track the number of dirty RMID a CLOSID has")
.. and was cargo-cult copied in other patches. It was never explained in
the changelog why it's used without a Kconfig entry anywhere.
Maybe in the future some other arch might (or might not) introduce
RESCTRL_RMID_DEPENDS_ON_CLOSID, but that doesn't justify this bad pattern
of dead code ...
2)
The NODE_NOT_IN_PAGE_FLAGS use is borderline correct:
kepler:~/tip> git grep -w NODE_NOT_IN_PAGE_FLAGS arch/x86
arch/x86/mm/numa.c: if (IS_ENABLED(NODE_NOT_IN_PAGE_FLAGS)) {
As NODE_NOT_IN_PAGE_FLAGS is not a Kconfig symbol, but a flag defined by
the VM:
include/linux/page-flags-layout.h:#define NODE_NOT_IN_PAGE_FLAGS 1
.. which happens to work with how IS_ENABLED() is defined. No other user
of NODE_NOT_IN_PAGE_FLAGS uses the IS_ENABLED() pattern.
Thanks,
Ingo
Powered by blists - more mailing lists