Skip to content

Commit 16bf5a5

Browse files
committed
smp: Rename flush_smp_call_function_from_idle()
This is invoked from the stopper thread too, which is definitely not idle. Rename it to flush_smp_call_function_queue() and fixup the callers. Signed-off-by: Thomas Gleixner <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d664e39 commit 16bf5a5

File tree

4 files changed

+24
-11
lines changed

4 files changed

+24
-11
lines changed

kernel/sched/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,7 @@ static int migration_cpu_stop(void *data)
24112411
* __migrate_task() such that we will not miss enforcing cpus_ptr
24122412
* during wakeups, see set_cpus_allowed_ptr()'s TASK_WAKING test.
24132413
*/
2414-
flush_smp_call_function_from_idle();
2414+
flush_smp_call_function_queue();
24152415

24162416
raw_spin_lock(&p->pi_lock);
24172417
rq_lock(rq, &rf);

kernel/sched/idle.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void do_idle(void)
327327
* RCU relies on this call to be done outside of an RCU read-side
328328
* critical section.
329329
*/
330-
flush_smp_call_function_from_idle();
330+
flush_smp_call_function_queue();
331331
schedule_idle();
332332

333333
if (unlikely(klp_patch_pending(current)))

kernel/sched/smp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ extern void sched_ttwu_pending(void *arg);
99
extern void send_call_function_single_ipi(int cpu);
1010

1111
#ifdef CONFIG_SMP
12-
extern void flush_smp_call_function_from_idle(void);
12+
extern void flush_smp_call_function_queue(void);
1313
#else
14-
static inline void flush_smp_call_function_from_idle(void) { }
14+
static inline void flush_smp_call_function_queue(void) { }
1515
#endif

kernel/smp.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static DEFINE_PER_CPU_ALIGNED(struct call_function_data, cfd_data);
9696

9797
static DEFINE_PER_CPU_SHARED_ALIGNED(struct llist_head, call_single_queue);
9898

99-
static void flush_smp_call_function_queue(bool warn_cpu_offline);
99+
static void __flush_smp_call_function_queue(bool warn_cpu_offline);
100100

101101
int smpcfd_prepare_cpu(unsigned int cpu)
102102
{
@@ -141,7 +141,7 @@ int smpcfd_dying_cpu(unsigned int cpu)
141141
* ensure that the outgoing CPU doesn't go offline with work
142142
* still pending.
143143
*/
144-
flush_smp_call_function_queue(false);
144+
__flush_smp_call_function_queue(false);
145145
irq_work_run();
146146
return 0;
147147
}
@@ -541,11 +541,11 @@ void generic_smp_call_function_single_interrupt(void)
541541
{
542542
cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->gotipi, CFD_SEQ_NOCPU,
543543
smp_processor_id(), CFD_SEQ_GOTIPI);
544-
flush_smp_call_function_queue(true);
544+
__flush_smp_call_function_queue(true);
545545
}
546546

547547
/**
548-
* flush_smp_call_function_queue - Flush pending smp-call-function callbacks
548+
* __flush_smp_call_function_queue - Flush pending smp-call-function callbacks
549549
*
550550
* @warn_cpu_offline: If set to 'true', warn if callbacks were queued on an
551551
* offline CPU. Skip this check if set to 'false'.
@@ -558,7 +558,7 @@ void generic_smp_call_function_single_interrupt(void)
558558
* Loop through the call_single_queue and run all the queued callbacks.
559559
* Must be called with interrupts disabled.
560560
*/
561-
static void flush_smp_call_function_queue(bool warn_cpu_offline)
561+
static void __flush_smp_call_function_queue(bool warn_cpu_offline)
562562
{
563563
call_single_data_t *csd, *csd_next;
564564
struct llist_node *entry, *prev;
@@ -681,7 +681,20 @@ static void flush_smp_call_function_queue(bool warn_cpu_offline)
681681
smp_processor_id(), CFD_SEQ_HDLEND);
682682
}
683683

684-
void flush_smp_call_function_from_idle(void)
684+
685+
/**
686+
* flush_smp_call_function_queue - Flush pending smp-call-function callbacks
687+
* from task context (idle, migration thread)
688+
*
689+
* When TIF_POLLING_NRFLAG is supported and a CPU is in idle and has it
690+
* set, then remote CPUs can avoid sending IPIs and wake the idle CPU by
691+
* setting TIF_NEED_RESCHED. The idle task on the woken up CPU has to
692+
* handle queued SMP function calls before scheduling.
693+
*
694+
* The migration thread has to ensure that an eventually pending wakeup has
695+
* been handled before it migrates a task.
696+
*/
697+
void flush_smp_call_function_queue(void)
685698
{
686699
unsigned long flags;
687700

@@ -691,7 +704,7 @@ void flush_smp_call_function_from_idle(void)
691704
cfd_seq_store(this_cpu_ptr(&cfd_seq_local)->idle, CFD_SEQ_NOCPU,
692705
smp_processor_id(), CFD_SEQ_IDLE);
693706
local_irq_save(flags);
694-
flush_smp_call_function_queue(true);
707+
__flush_smp_call_function_queue(true);
695708
if (local_softirq_pending())
696709
do_softirq();
697710

0 commit comments

Comments
 (0)