aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/smp.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/kernel/smp.c b/kernel/smp.c
index 9910744f0856..aaeee20c5634 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -491,14 +491,15 @@ void smp_call_function_many(const struct cpumask *mask,
491 cpumask_clear_cpu(this_cpu, data->cpumask); 491 cpumask_clear_cpu(this_cpu, data->cpumask);
492 492
493 /* 493 /*
494 * To ensure the interrupt handler gets an complete view 494 * We reuse the call function data without waiting for any grace
495 * we order the cpumask and refs writes and order the read 495 * period after some other cpu removes it from the global queue.
496 * of them in the interrupt handler. In addition we may 496 * This means a cpu might find our data block as it is writen.
497 * only clear our own cpu bit from the mask. 497 * The interrupt handler waits until it sees refs filled out
498 * while its cpu mask bit is set; here we may only clear our
499 * own cpu mask bit, and must wait to set refs until we are sure
500 * previous writes are complete and we have obtained the lock to
501 * add the element to the queue.
498 */ 502 */
499 smp_wmb();
500
501 atomic_set(&data->refs, cpumask_weight(data->cpumask));
502 503
503 raw_spin_lock_irqsave(&call_function.lock, flags); 504 raw_spin_lock_irqsave(&call_function.lock, flags);
504 /* 505 /*
@@ -507,6 +508,11 @@ void smp_call_function_many(const struct cpumask *mask,
507 * will not miss any other list entries: 508 * will not miss any other list entries:
508 */ 509 */
509 list_add_rcu(&data->csd.list, &call_function.queue); 510 list_add_rcu(&data->csd.list, &call_function.queue);
511 /*
512 * We rely on the wmb() in list_add_rcu to order the writes
513 * to func, data, and cpumask before this write to refs.
514 */
515 atomic_set(&data->refs, cpumask_weight(data->cpumask));
510 raw_spin_unlock_irqrestore(&call_function.lock, flags); 516 raw_spin_unlock_irqrestore(&call_function.lock, flags);
511 517
512 /* 518 /*