Skip to content

Commit 71f0a24

Browse files
elic307iSaeed Mahameed
authored andcommitted
lib: cpu_rmap: Add irq_cpu_rmap_remove to complement irq_cpu_rmap_add
Add a function to complement irq_cpu_rmap_add(). It removes the irq from the reverse mapping by setting the notifier to NULL. The function calls irq_set_affinity_notifier() with NULL at the notify argument which then cancel any pending notifier work and decrement reference on the notifier. When ref count reaches zero, the glue pointer is kfree and the rmap entry is set to NULL serving both to avoid second attempt to release it and also making the rmap entry available for subsequent mapping. It should be noted the drivers usually creates the reverse mapping at initialization time and remove it at unload time so we do not expect failures in allocating rmap due to kref holding the glue entry. Cc: Thomas Gleixner <[email protected]> Signed-off-by: Eli Cohen <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Reviewed-by: Jacob Keller <[email protected]>
1 parent 9821d8d commit 71f0a24

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/linux/cpu_rmap.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
6060
}
6161
extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
6262

63+
int irq_cpu_rmap_remove(struct cpu_rmap *rmap, int irq);
6364
extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
6465

6566
#endif /* __LINUX_CPU_RMAP_H */

lib/cpu_rmap.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,17 @@ static void irq_cpu_rmap_release(struct kref *ref)
285285
kfree(glue);
286286
}
287287

288+
/**
289+
* irq_cpu_rmap_remove - remove an IRQ from a CPU affinity reverse-map
290+
* @rmap: The reverse-map
291+
* @irq: The IRQ number
292+
*/
293+
int irq_cpu_rmap_remove(struct cpu_rmap *rmap, int irq)
294+
{
295+
return irq_set_affinity_notifier(irq, NULL);
296+
}
297+
EXPORT_SYMBOL(irq_cpu_rmap_remove);
298+
288299
/**
289300
* irq_cpu_rmap_add - add an IRQ to a CPU affinity reverse-map
290301
* @rmap: The reverse-map

0 commit comments

Comments
 (0)