mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
sched/fair, cpumask: Export for_each_cpu_wrap()
More users for for_each_cpu_wrap() have appeared. Promote the construct to generic cpumask interface. The implementation is slightly modified to reduce arguments. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Lauro Ramos Venancio <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mike Galbraith <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Rik van Riel <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
8c0334697d
commit
c743f0a5c5
3 changed files with 53 additions and 41 deletions
|
|
@ -43,6 +43,38 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu)
|
|||
}
|
||||
EXPORT_SYMBOL(cpumask_any_but);
|
||||
|
||||
/**
|
||||
* cpumask_next_wrap - helper to implement for_each_cpu_wrap
|
||||
* @n: the cpu prior to the place to search
|
||||
* @mask: the cpumask pointer
|
||||
* @start: the start point of the iteration
|
||||
* @wrap: assume @n crossing @start terminates the iteration
|
||||
*
|
||||
* Returns >= nr_cpu_ids on completion
|
||||
*
|
||||
* Note: the @wrap argument is required for the start condition when
|
||||
* we cannot assume @start is set in @mask.
|
||||
*/
|
||||
int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
|
||||
{
|
||||
int next;
|
||||
|
||||
again:
|
||||
next = cpumask_next(n, mask);
|
||||
|
||||
if (wrap && n < start && next >= start) {
|
||||
return nr_cpumask_bits;
|
||||
|
||||
} else if (next >= nr_cpumask_bits) {
|
||||
wrap = true;
|
||||
n = -1;
|
||||
goto again;
|
||||
}
|
||||
|
||||
return next;
|
||||
}
|
||||
EXPORT_SYMBOL(cpumask_next_wrap);
|
||||
|
||||
/* These are not inline because of header tangles. */
|
||||
#ifdef CONFIG_CPUMASK_OFFSTACK
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue