Skip to content

Commit

Permalink
smp: Implement kick_all_cpus_sync()
Browse files Browse the repository at this point in the history
Will replace the misnomed cpu_idle_wait() function which is copied a
gazillion times all over arch/*

Signed-off-by: Thomas Gleixner <[email protected]>
Acked-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
  • Loading branch information
KAGA-KOKO committed May 8, 2012
1 parent 9cd75e1 commit f37f435
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/linux/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ void __smp_call_function_single(int cpuid, struct call_single_data *data,
int smp_call_function_any(const struct cpumask *mask,
smp_call_func_t func, void *info, int wait);

void kick_all_cpus_sync(void);

/*
* Generic and arch helpers
*/
Expand Down Expand Up @@ -192,6 +194,8 @@ smp_call_function_any(const struct cpumask *mask, smp_call_func_t func,
return smp_call_function_single(0, func, info, wait);
}

static inline void kick_all_cpus_sync(void) { }

#endif /* !SMP */

/*
Expand Down
23 changes: 23 additions & 0 deletions kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,3 +795,26 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
}
}
EXPORT_SYMBOL(on_each_cpu_cond);

static void do_nothing(void *unused)
{
}

/**
* kick_all_cpus_sync - Force all cpus out of idle
*
* Used to synchronize the update of pm_idle function pointer. It's
* called after the pointer is updated and returns after the dummy
* callback function has been executed on all cpus. The execution of
* the function can only happen on the remote cpus after they have
* left the idle function which had been called via pm_idle function
* pointer. So it's guaranteed that nothing uses the previous pointer
* anymore.
*/
void kick_all_cpus_sync(void)
{
/* Make sure the change is visible before we kick the cpus */
smp_mb();
smp_call_function(do_nothing, NULL, 1);
}
EXPORT_SYMBOL_GPL(kick_all_cpus_sync);

0 comments on commit f37f435

Please sign in to comment.