diff options
author | Peter Zijlstra <peterz@infradead.org> | 2017-04-14 08:20:05 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2017-05-15 04:15:23 -0400 |
commit | c743f0a5c50f2fcbc628526279cfa24f3dabe182 (patch) | |
tree | f9f9f8c337e8e9a0366ee8e95032a21f19015c00 /lib/cpumask.c | |
parent | 8c0334697dc37eb3d6d7632304d3a3662248daac (diff) |
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) <peterz@infradead.org>
Cc: Lauro Ramos Venancio <lvenanci@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: lwang@redhat.com
Link: http://lkml.kernel.org/r/20170414122005.o35me2h5nowqkxbv@hirez.programming.kicks-ass.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'lib/cpumask.c')
-rw-r--r-- | lib/cpumask.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c index 81dedaab36cc..4731a0895760 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c | |||
@@ -43,6 +43,38 @@ int cpumask_any_but(const struct cpumask *mask, unsigned int cpu) | |||
43 | } | 43 | } |
44 | EXPORT_SYMBOL(cpumask_any_but); | 44 | EXPORT_SYMBOL(cpumask_any_but); |
45 | 45 | ||
46 | /** | ||
47 | * cpumask_next_wrap - helper to implement for_each_cpu_wrap | ||
48 | * @n: the cpu prior to the place to search | ||
49 | * @mask: the cpumask pointer | ||
50 | * @start: the start point of the iteration | ||
51 | * @wrap: assume @n crossing @start terminates the iteration | ||
52 | * | ||
53 | * Returns >= nr_cpu_ids on completion | ||
54 | * | ||
55 | * Note: the @wrap argument is required for the start condition when | ||
56 | * we cannot assume @start is set in @mask. | ||
57 | */ | ||
58 | int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap) | ||
59 | { | ||
60 | int next; | ||
61 | |||
62 | again: | ||
63 | next = cpumask_next(n, mask); | ||
64 | |||
65 | if (wrap && n < start && next >= start) { | ||
66 | return nr_cpumask_bits; | ||
67 | |||
68 | } else if (next >= nr_cpumask_bits) { | ||
69 | wrap = true; | ||
70 | n = -1; | ||
71 | goto again; | ||
72 | } | ||
73 | |||
74 | return next; | ||
75 | } | ||
76 | EXPORT_SYMBOL(cpumask_next_wrap); | ||
77 | |||
46 | /* These are not inline because of header tangles. */ | 78 | /* These are not inline because of header tangles. */ |
47 | #ifdef CONFIG_CPUMASK_OFFSTACK | 79 | #ifdef CONFIG_CPUMASK_OFFSTACK |
48 | /** | 80 | /** |