Skip to contentSkip to conversation

smp: Fix offline cpu check in flush_smp_call_function_queue

PATCH Applied Nadav Amit 2 participants 2 messages Mar 19, 2022 – Apr 13, 2022

lore
Share & tools
lore

Nadav Amit

author
#0 lore raw

PATCH 1/1 smp: Fix offline cpu check in flush_smp_call_function_queue

From: Nadav Amit <[email protected]>

The check in flush_smp_call_function_queue() for callbacks that are sent to offline CPUs currently checks whether the queue is empty.

However, flush_smp_call_function_queue() has just deleted all the callbacks from the queue and moved all the entries into a local list. This checks would only be positive if some callbacks were added in the short time after llist_del_all() was called. This does not seem to be the intention of this check.

Change the check to look at the local list to which the entries were moved instead of the queue from which all the callbacks were just removed.

Cc Thomas Gleixner <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Srivatsa S. Bhat <[email protected]>
Fixes 8d056c48e4862 ("CPU hotplug, smp: flush any pending IPI callbacks before CPU offline")
---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +1 -1
index d82439bac401..eb275b69d5f3 100644
@@ -582,7 +582,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline)
 
 	/* There shouldn't be any pending callbacks on an offline CPU. */
 	if (unlikely(warn_cpu_offline && !cpu_online(smp_processor_id()) &&
-		     !warned && !llist_empty(head))) {
+		     !warned && entry != NULL)) {
 		warned = true;
 		WARN(1, "IPI on offline CPU %d\n", smp_processor_id());
 
Signature · 1 line
2.25.1
merge bot Applied
#1 lore raw

[tip: smp/urgent] smp: Fix offline cpu check in flush_smp_call_function_queue()

The following commit has been merged into the smp/urgent branch of tip:

The following commit has been merged into the smp/urgent branch of tip:

Commit-ID:     9e949a3886356fe9112c6f6f34a6e23d1d35407f
Gitweb:        https://git.kernel.org/tip/9e949a3886356fe9112c6f6f34a6e23d1d35407f
Author:        Nadav Amit <[email protected]>
AuthorDate:    Sat, 19 Mar 2022 00:20:15 -07:00
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Wed, 13 Apr 2022 18:44:35 +02:00

smp: Fix offline cpu check in flush_smp_call_function_queue()

The check in flush_smp_call_function_queue() for callbacks that are sent to offline CPUs currently checks whether the queue is empty.

However, flush_smp_call_function_queue() has just deleted all the callbacks from the queue and moved all the entries into a local list. This checks would only be positive if some callbacks were added in the short time after llist_del_all() was called. This does not seem to be the intention of this check.

Change the check to look at the local list to which the entries were moved instead of the queue from which all the callbacks were just removed.

Fixes 8d056c48e4862 ("CPU hotplug, smp: flush any pending IPI callbacks before CPU offline")
---
 kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/smp.c +1 -1
index 01a7c17..65a630f 100644
@@ -579,7 +579,7 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline)
 
 	/* There shouldn't be any pending callbacks on an offline CPU. */
 	if (unlikely(warn_cpu_offline && !cpu_online(smp_processor_id()) &&
-		     !warned && !llist_empty(head))) {
+		     !warned && entry != NULL)) {
 		warned = true;
 		WARN(1, "IPI on offline CPU %d\n", smp_processor_id());