From: "Chen, Yu C" <yu.c.chen@intel.com>
To: kernel test robot <oliver.sang@intel.com>,
Ingo Molnar <mingo@kernel.org>
Cc: <oe-lkp@lists.linux.dev>, <lkp@intel.com>,
<linux-kernel@vger.kernel.org>, <x86@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Juri Lelli <juri.lelli@redhat.com>,
"Linus Torvalds" <torvalds@linux-foundation.org>,
Mel Gorman <mgorman@suse.de>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Shrikanth Hegde <sshegde@linux.ibm.com>,
Steven Rostedt <rostedt@goodmis.org>,
"Valentin Schneider" <vschneid@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
<aubrey.li@linux.intel.com>
Subject: Re: [tip:sched/core] [sched/smp] 06ddd17521: BUG:using_smp_processor_id()in_preemptible
Date: Thu, 10 Jul 2025 11:18:29 +0800 [thread overview]
Message-ID: <6cf071f3-ff5b-4025-8ce7-2f2cceb03984@intel.com> (raw)
In-Reply-To: <202507100448.6b88d6f1-lkp@intel.com>
On 7/10/2025 10:58 AM, kernel test robot wrote:
>
>
> Hello,
>
> kernel test robot noticed "BUG:using_smp_processor_id()in_preemptible" on:
>
> commit: 06ddd17521bf11a3e7f59dafdf5c148f29467d2c ("sched/smp: Always define is_percpu_thread() and scheduler_ipi()")
> https://git.kernel.org/cgit/linux/kernel/git/tip/tip.git sched/core
>
> [test failed on linux-next/master 835244aba90de290b4b0b1fa92b6734f3ee7b3d9]
>
> in testcase: boot
>
> config: x86_64-randconfig-123-20250702
> compiler: gcc-12
> test machine: qemu-system-x86_64 -enable-kvm -cpu SandyBridge -smp 2 -m 16G
>
> (please refer to attached dmesg/kmsg for entire log/backtrace)
>
>
> +----------------------------------------------------------+------------+------------+
> | | cac5cefbad | 06ddd17521 |
> +----------------------------------------------------------+------------+------------+
> | boot_successes | 20 | 0 |
> | boot_failures | 0 | 18 |
> | BUG:using_smp_processor_id()in_preemptible | 0 | 18 |
> | BUG:using__this_cpu_write()in_preemptible[#]code:swapper | 0 | 18 |
> | BUG:using__this_cpu_read()in_preemptible | 0 | 18 |
> +----------------------------------------------------------+------------+------------+
>
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <oliver.sang@intel.com>
> | Closes: https://lore.kernel.org/oe-lkp/202507100448.6b88d6f1-lkp@intel.com
>
>
> [ 25.232998][ T1] BUG: using smp_processor_id() in preemptible [00000000] code: swapper/0/1
> [ 25.233645][ T1] caller is __kvm_is_vmx_supported (arch/x86/include/asm/cpuid/api.h:74 arch/x86/include/asm/cpuid/api.h:113 arch/x86/kvm/vmx/vmx.c:2789)
> [ 25.234128][ T1] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.16.0-rc1-00023-g06ddd17521bf #1 PREEMPT(lazy)
> [ 25.234931][ T1] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.16.2-debian-1.16.2-1 04/01/2014
> [ 25.235357][ T1] Call Trace:
> [ 25.235357][ T1] <TASK>
> [ 25.235357][ T1] dump_stack_lvl (lib/dump_stack.c:123 (discriminator 1))
> [ 25.235357][ T1] check_preemption_disabled (arch/x86/include/asm/preempt.h:85 lib/smp_processor_id.c:53)
> [ 25.235357][ T1] __kvm_is_vmx_supported (arch/x86/include/asm/cpuid/api.h:74 arch/x86/include/asm/cpuid/api.h:113 arch/x86/kvm/vmx/vmx.c:2789)
> [ 25.235357][ T1] ? __cpuid (arch/x86/include/asm/paravirt.h:179)
> [ 25.235357][ T1] ? __sanitizer_cov_trace_pc (kernel/kcov.c:217)
> [ 25.235357][ T1] ? ftrace_likely_update (arch/x86/include/asm/smap.h:53 kernel/trace/trace_branch.c:223)
> [ 25.235357][ T1] ? __sanitizer_cov_trace_pc (kernel/kcov.c:217)
> [ 25.235357][ T1] ? ftrace_likely_update (arch/x86/include/asm/smap.h:53 kernel/trace/trace_branch.c:223)
> [ 25.235357][ T1] ? __sanitizer_cov_trace_pc (kernel/kcov.c:217)
> [ 25.235357][ T1] ? ftrace_likely_update (arch/x86/include/asm/smap.h:53 kernel/trace/trace_branch.c:223)
> [ 25.235357][ T1] vmx_init (arch/x86/kvm/vmx/vmx.c:2808 arch/x86/kvm/vmx/vmx.c:8653)
> [ 25.235357][ T1] vt_init (arch/x86/kvm/vmx/main.c:1072)
> [ 25.235357][ T1] ? pi_init_cpu (arch/x86/kvm/vmx/main.c:1067)
> [ 25.235357][ T1] do_one_initcall (init/main.c:1273)
> [ 25.235357][ T1] ? trace_initcall_level (init/main.c:1264)
> [ 25.235357][ T1] ? __sanitizer_cov_trace_pc (kernel/kcov.c:217)
> [ 25.235357][ T1] ? ftrace_likely_update (arch/x86/include/asm/smap.h:53 kernel/trace/trace_branch.c:223)
> [ 25.235357][ T1] ? __sanitizer_cov_trace_pc (kernel/kcov.c:217)
> [ 25.235357][ T1] ? ftrace_likely_update (arch/x86/include/asm/smap.h:53 kernel/trace/trace_branch.c:223)
> [ 25.235357][ T1] do_initcalls (init/main.c:1334 init/main.c:1351)
> [ 25.235357][ T1] kernel_init_freeable (init/main.c:1587)
> [ 25.235357][ T1] ? rest_init (init/main.c:1465)
> [ 25.235357][ T1] kernel_init (init/main.c:1475)
> [ 25.235357][ T1] ? rest_init (init/main.c:1465)
> [ 25.235357][ T1] ret_from_fork (arch/x86/kernel/process.c:154)
> [ 25.235357][ T1] ? rest_init (init/main.c:1465)
> [ 25.235357][ T1] ret_from_fork_asm (arch/x86/entry/entry_64.S:255)
> [ 25.235357][ T1] </TASK>
>
I took a glance at the warning, before this patch,
is_percpu_thread() always return true when CONFIG_SMP is not set.
After this patch,
is_percpu_thread() checks the current task's CPU affinity.
So debug_smp_processor_id() -> check_preemption_disabled() ->
is_percpu_thread() might not always return true anymore, which caused
the warning.
Actually the issue is in __kvm_is_vmx_supported(), should
we use something like this below:
diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
index 5c5766467a61..9cba7b061892 100644
--- a/arch/x86/kvm/vmx/vmx.c
+++ b/arch/x86/kvm/vmx/vmx.c
@@ -2787,19 +2787,22 @@ static int setup_vmcs_config(struct vmcs_config
*vmcs_conf,
static bool __kvm_is_vmx_supported(void)
{
- int cpu = smp_processor_id();
+ int cpu = get_cpu();
if (!(cpuid_ecx(1) & feature_bit(VMX))) {
pr_err("VMX not supported by CPU %d\n", cpu);
+ put_cpu();
return false;
}
if (!this_cpu_has(X86_FEATURE_MSR_IA32_FEAT_CTL) ||
!this_cpu_has(X86_FEATURE_VMX)) {
pr_err("VMX not enabled (by BIOS) in MSR_IA32_FEAT_CTL
on CPU %d\n", cpu);
+ put_cpu();
return false;
}
+ put_cpu();
return true;
}
thanks,
Chenyu
next prev parent reply other threads:[~2025-07-10 3:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 2:58 kernel test robot
2025-07-10 3:18 ` Chen, Yu C [this message]
2025-07-10 6:25 ` Sebastian Andrzej Siewior
2025-07-10 8:00 ` Chen, Yu C
2025-07-10 8:11 ` Sebastian Andrzej Siewior
2025-07-10 8:27 ` [PATCH] lib/smp_processor_id: Make migration check unconditional of SMP Sebastian Andrzej Siewior
2025-07-10 8:32 ` Chen, Yu C
2025-07-10 10:13 ` Peter Zijlstra
2025-07-11 12:41 ` [tip: sched/core] " tip-bot2 for Sebastian Andrzej Siewior
2025-07-10 8:29 ` [tip:sched/core] [sched/smp] 06ddd17521: BUG:using_smp_processor_id()in_preemptible Chen, Yu C
2025-07-10 10:47 ` Sebastian Andrzej Siewior
2025-07-10 11:31 ` Chen, Yu C
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=6cf071f3-ff5b-4025-8ce7-2f2cceb03984@intel.com \
--to=yu.c.chen@intel.com \
--cc=aubrey.li@linux.intel.com \
--cc=bigeasy@linutronix.de \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mgorman@suse.de \
--cc=mingo@kernel.org \
--cc=oe-lkp@lists.linux.dev \
--cc=oliver.sang@intel.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=sshegde@linux.ibm.com \
--cc=torvalds@linux-foundation.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=x86@kernel.org \
/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
all inboxes | Powered by JetHome®