mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
![David Decotigny](/assets/img/avatar_default.png)
In some cases, free_irq_cpu_rmap() is called while holding a lock (eg rtnl). This can lead to deadlocks, because it invokes flush_scheduled_work() which ends up waiting for whole system workqueue to flush, but some pending works might try to acquire the lock we are already holding. This commit uses reference-counting to replace irq_run_affinity_notifiers(). It also removes irq_run_affinity_notifiers() altogether. [akpm@linux-foundation.org: eliminate free_cpu_rmap, rename cpu_rmap_reclaim() to cpu_rmap_release(), propagate kref_put() retval from cpu_rmap_put()] Signed-off-by: David Decotigny <decot@googlers.com> Reviewed-by: Ben Hutchings <bhutchings@solarflare.com> Acked-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Or Gerlitz <ogerlitz@mellanox.com> Acked-by: Amir Vadai <amirv@mellanox.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
72 lines
1.9 KiB
C
72 lines
1.9 KiB
C
#ifndef __LINUX_CPU_RMAP_H
|
|
#define __LINUX_CPU_RMAP_H
|
|
|
|
/*
|
|
* cpu_rmap.c: CPU affinity reverse-map support
|
|
* Copyright 2011 Solarflare Communications Inc.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
* under the terms of the GNU General Public License version 2 as published
|
|
* by the Free Software Foundation, incorporated herein by reference.
|
|
*/
|
|
|
|
#include <linux/cpumask.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/kref.h>
|
|
|
|
/**
|
|
* struct cpu_rmap - CPU affinity reverse-map
|
|
* @refcount: kref for object
|
|
* @size: Number of objects to be reverse-mapped
|
|
* @used: Number of objects added
|
|
* @obj: Pointer to array of object pointers
|
|
* @near: For each CPU, the index and distance to the nearest object,
|
|
* based on affinity masks
|
|
*/
|
|
struct cpu_rmap {
|
|
struct kref refcount;
|
|
u16 size, used;
|
|
void **obj;
|
|
struct {
|
|
u16 index;
|
|
u16 dist;
|
|
} near[0];
|
|
};
|
|
#define CPU_RMAP_DIST_INF 0xffff
|
|
|
|
extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
|
|
extern int cpu_rmap_put(struct cpu_rmap *rmap);
|
|
|
|
extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
|
|
extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
|
|
const struct cpumask *affinity);
|
|
|
|
static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
|
|
{
|
|
return rmap->near[cpu].index;
|
|
}
|
|
|
|
static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
|
|
{
|
|
return rmap->obj[rmap->near[cpu].index];
|
|
}
|
|
|
|
#ifdef CONFIG_GENERIC_HARDIRQS
|
|
|
|
/**
|
|
* alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs
|
|
* @size: Number of objects to be mapped
|
|
*
|
|
* Must be called in process context.
|
|
*/
|
|
static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
|
|
{
|
|
return alloc_cpu_rmap(size, GFP_KERNEL);
|
|
}
|
|
extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
|
|
|
|
extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
|
|
|
|
#endif
|
|
#endif /* __LINUX_CPU_RMAP_H */
|