diff options
Diffstat (limited to 'kernel/sched_cpupri.c')
-rw-r--r-- | kernel/sched_cpupri.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/kernel/sched_cpupri.c b/kernel/sched_cpupri.c index 0f052fc674d5..e6871cb3fc83 100644 --- a/kernel/sched_cpupri.c +++ b/kernel/sched_cpupri.c | |||
@@ -27,6 +27,7 @@ | |||
27 | * of the License. | 27 | * of the License. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <linux/gfp.h> | ||
30 | #include "sched_cpupri.h" | 31 | #include "sched_cpupri.h" |
31 | 32 | ||
32 | /* Convert between a 140 based task->prio, and our 102 based cpupri */ | 33 | /* Convert between a 140 based task->prio, and our 102 based cpupri */ |
@@ -47,9 +48,7 @@ static int convert_prio(int prio) | |||
47 | } | 48 | } |
48 | 49 | ||
49 | #define for_each_cpupri_active(array, idx) \ | 50 | #define for_each_cpupri_active(array, idx) \ |
50 | for (idx = find_first_bit(array, CPUPRI_NR_PRIORITIES); \ | 51 | for_each_set_bit(idx, array, CPUPRI_NR_PRIORITIES) |
51 | idx < CPUPRI_NR_PRIORITIES; \ | ||
52 | idx = find_next_bit(array, CPUPRI_NR_PRIORITIES, idx+1)) | ||
53 | 52 | ||
54 | /** | 53 | /** |
55 | * cpupri_find - find the best (lowest-pri) CPU in the system | 54 | * cpupri_find - find the best (lowest-pri) CPU in the system |
@@ -58,7 +57,7 @@ static int convert_prio(int prio) | |||
58 | * @lowest_mask: A mask to fill in with selected CPUs (or NULL) | 57 | * @lowest_mask: A mask to fill in with selected CPUs (or NULL) |
59 | * | 58 | * |
60 | * Note: This function returns the recommended CPUs as calculated during the | 59 | * Note: This function returns the recommended CPUs as calculated during the |
61 | * current invokation. By the time the call returns, the CPUs may have in | 60 | * current invocation. By the time the call returns, the CPUs may have in |
62 | * fact changed priorities any number of times. While not ideal, it is not | 61 | * fact changed priorities any number of times. While not ideal, it is not |
63 | * an issue of correctness since the normal rebalancer logic will correct | 62 | * an issue of correctness since the normal rebalancer logic will correct |
64 | * any discrepancies created by racing against the uncertainty of the current | 63 | * any discrepancies created by racing against the uncertainty of the current |
@@ -135,26 +134,26 @@ void cpupri_set(struct cpupri *cp, int cpu, int newpri) | |||
135 | if (likely(newpri != CPUPRI_INVALID)) { | 134 | if (likely(newpri != CPUPRI_INVALID)) { |
136 | struct cpupri_vec *vec = &cp->pri_to_cpu[newpri]; | 135 | struct cpupri_vec *vec = &cp->pri_to_cpu[newpri]; |
137 | 136 | ||
138 | spin_lock_irqsave(&vec->lock, flags); | 137 | raw_spin_lock_irqsave(&vec->lock, flags); |
139 | 138 | ||
140 | cpumask_set_cpu(cpu, vec->mask); | 139 | cpumask_set_cpu(cpu, vec->mask); |
141 | vec->count++; | 140 | vec->count++; |
142 | if (vec->count == 1) | 141 | if (vec->count == 1) |
143 | set_bit(newpri, cp->pri_active); | 142 | set_bit(newpri, cp->pri_active); |
144 | 143 | ||
145 | spin_unlock_irqrestore(&vec->lock, flags); | 144 | raw_spin_unlock_irqrestore(&vec->lock, flags); |
146 | } | 145 | } |
147 | if (likely(oldpri != CPUPRI_INVALID)) { | 146 | if (likely(oldpri != CPUPRI_INVALID)) { |
148 | struct cpupri_vec *vec = &cp->pri_to_cpu[oldpri]; | 147 | struct cpupri_vec *vec = &cp->pri_to_cpu[oldpri]; |
149 | 148 | ||
150 | spin_lock_irqsave(&vec->lock, flags); | 149 | raw_spin_lock_irqsave(&vec->lock, flags); |
151 | 150 | ||
152 | vec->count--; | 151 | vec->count--; |
153 | if (!vec->count) | 152 | if (!vec->count) |
154 | clear_bit(oldpri, cp->pri_active); | 153 | clear_bit(oldpri, cp->pri_active); |
155 | cpumask_clear_cpu(cpu, vec->mask); | 154 | cpumask_clear_cpu(cpu, vec->mask); |
156 | 155 | ||
157 | spin_unlock_irqrestore(&vec->lock, flags); | 156 | raw_spin_unlock_irqrestore(&vec->lock, flags); |
158 | } | 157 | } |
159 | 158 | ||
160 | *currpri = newpri; | 159 | *currpri = newpri; |
@@ -180,7 +179,7 @@ int cpupri_init(struct cpupri *cp, bool bootmem) | |||
180 | for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) { | 179 | for (i = 0; i < CPUPRI_NR_PRIORITIES; i++) { |
181 | struct cpupri_vec *vec = &cp->pri_to_cpu[i]; | 180 | struct cpupri_vec *vec = &cp->pri_to_cpu[i]; |
182 | 181 | ||
183 | spin_lock_init(&vec->lock); | 182 | raw_spin_lock_init(&vec->lock); |
184 | vec->count = 0; | 183 | vec->count = 0; |
185 | if (!zalloc_cpumask_var(&vec->mask, gfp)) | 184 | if (!zalloc_cpumask_var(&vec->mask, gfp)) |
186 | goto cleanup; | 185 | goto cleanup; |