Hi Wenchao,
Thanks for your patch.
Please subscribe the kernel@openeuler.org mailing list first, and then resend this patch again, or your patch would be blocked. Others who in the mailing list could not receive the emails.
Click this link for subscribe mailing list: https://openeuler.org/zh/community/mailing-list/
On 2021/9/17 17:16, Wenchao Qin wrote:
hulk inclusion category: bugfix bugzilla: N/A CVE: N/A
When we are in the arch_get_cpu_freq func for the first time, after arch_probe_cpu_freq is excuted, the return of smp_processor_id() will change due to preemption while cpu_freq get the freq belong to original processor id, so pr_info will print the freq with wrong processor id like below table from dmesg:
[ 1.713211] NMI watchdog: CPU1 freq probed as 2189072384 HZ. [ 1.810819] NMI watchdog: CPU1 freq probed as 2192003108 HZ. [ 1.909910] NMI watchdog: CPU2 freq probed as 2191345967 HZ. [ 2.015327] NMI watchdog: CPU3 freq probed as 2189460398 HZ.
Actually, the first line should print the freq of CPU0, this bu can occur in virtual machine with less then 17 vCPUs.
Changing smp_processor_id() to cpu will fix the bug
Signed-off-by: Wenchao Qin qinwenchao@cmss.chinamobile.com
arch/arm64/kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index fe56277..d685a27 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -1457,7 +1457,7 @@ static u64 arch_get_cpu_freq(void) if (!cpu_freq) { cpu_freq = arch_probe_cpu_freq(); pr_info("NMI watchdog: CPU%u freq probed as %llu HZ.\n",
smp_processor_id(), cpu_freq);
cpu, cpu_freq);
arch_probe_cpu_freq() 一样也会调用 smp_processor_id(),也可能存在被抢占的情况。 是不是需要关抢占?
if (!cpu_freq) cpu_freq = -1; per_cpu(cpu_freq_probed, cpu) = cpu_freq;