11 #ifdef CONFIG_GENERIC_HARDIRQS
14 #include <linux/export.h>
44 rmap = kzalloc(obj_offset + size *
sizeof(rmap->
obj[0]), flags);
69 static bool cpu_rmap_copy_neigh(
struct cpu_rmap *rmap,
unsigned int cpu,
75 if (rmap->
near[cpu].dist > dist &&
76 rmap->
near[neigh].dist <= dist) {
86 static void debug_print_rmap(
const struct cpu_rmap *rmap,
const char *
prefix)
91 pr_info(
"cpu_rmap %p, %s:\n", rmap, prefix);
95 pr_info(
"cpu %d -> obj %u (distance %u)\n",
96 cpu, index, rmap->
near[cpu].dist);
118 index = rmap->
used++;
143 if (rmap->
near[cpu].index == index) {
145 cpumask_set_cpu(cpu, update_mask);
149 debug_print_rmap(rmap,
"after invalidating old distances");
157 cpumask_or(update_mask, update_mask,
161 debug_print_rmap(rmap,
"after updating neighbours");
165 if (cpu_rmap_copy_neigh(rmap, cpu,
168 if (cpu_rmap_copy_neigh(rmap, cpu,
171 if (cpu_rmap_copy_neigh(rmap, cpu,
179 debug_print_rmap(rmap,
"after copying neighbours");
181 free_cpumask_var(update_mask);
186 #ifdef CONFIG_GENERIC_HARDIRQS
191 struct irq_affinity_notify
notify;
203 void free_irq_cpu_rmap(
struct cpu_rmap *rmap)
205 struct irq_glue *glue;
211 for (index = 0; index < rmap->
used; index++) {
213 irq_set_affinity_notifier(glue->notify.irq,
NULL);
215 irq_run_affinity_notifiers();
222 irq_cpu_rmap_notify(
struct irq_affinity_notify *
notify,
const cpumask_t *mask)
224 struct irq_glue *glue =
230 pr_warning(
"irq_cpu_rmap_notify: update failed: %d\n", rc);
233 static void irq_cpu_rmap_release(
struct kref *ref)
235 struct irq_glue *glue =
251 int irq_cpu_rmap_add(
struct cpu_rmap *rmap,
int irq)
253 struct irq_glue *glue = kzalloc(
sizeof(*glue),
GFP_KERNEL);
258 glue->notify.notify = irq_cpu_rmap_notify;
259 glue->notify.release = irq_cpu_rmap_release;
262 rc = irq_set_affinity_notifier(irq, &glue->notify);