summaryrefslogtreecommitdiffstats
path: root/lib/cpumask.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cpumask.c')
-rw-r--r--lib/cpumask.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/lib/cpumask.c b/lib/cpumask.c
index 14049a96f04a..b810b753c607 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -163,68 +163,4 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
163{ 163{
164 memblock_free_early(__pa(mask), cpumask_size()); 164 memblock_free_early(__pa(mask), cpumask_size());
165} 165}
166
167/**
168 * cpumask_set_cpu_local_first - set i'th cpu with local numa cpu's first
169 *
170 * @i: index number
171 * @numa_node: local numa_node
172 * @dstp: cpumask with the relevant cpu bit set according to the policy
173 *
174 * This function sets the cpumask according to a numa aware policy.
175 * cpumask could be used as an affinity hint for the IRQ related to a
176 * queue. When the policy is to spread queues across cores - local cores
177 * first.
178 *
179 * Returns 0 on success, -ENOMEM for no memory, and -EAGAIN when failed to set
180 * the cpu bit and need to re-call the function.
181 */
182int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp)
183{
184 cpumask_var_t mask;
185 int cpu;
186 int ret = 0;
187
188 if (!zalloc_cpumask_var(&mask, GFP_KERNEL))
189 return -ENOMEM;
190
191 i %= num_online_cpus();
192
193 if (!cpumask_of_node(numa_node)) {
194 /* Use all online cpu's for non numa aware system */
195 cpumask_copy(mask, cpu_online_mask);
196 } else {
197 int n;
198
199 cpumask_and(mask,
200 cpumask_of_node(numa_node), cpu_online_mask);
201
202 n = cpumask_weight(mask);
203 if (i >= n) {
204 i -= n;
205
206 /* If index > number of local cpu's, mask out local
207 * cpu's
208 */
209 cpumask_andnot(mask, cpu_online_mask, mask);
210 }
211 }
212
213 for_each_cpu(cpu, mask) {
214 if (--i < 0)
215 goto out;
216 }
217
218 ret = -EAGAIN;
219
220out:
221 free_cpumask_var(mask);
222
223 if (!ret)
224 cpumask_set_cpu(cpu, dstp);
225
226 return ret;
227}
228EXPORT_SYMBOL(cpumask_set_cpu_local_first);
229
230#endif 166#endif