0001
0002 #ifndef __LINUX_CPU_RMAP_H
0003 #define __LINUX_CPU_RMAP_H
0004
0005
0006
0007
0008
0009
0010 #include <linux/cpumask.h>
0011 #include <linux/gfp.h>
0012 #include <linux/slab.h>
0013 #include <linux/kref.h>
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 struct cpu_rmap {
0025 struct kref refcount;
0026 u16 size, used;
0027 void **obj;
0028 struct {
0029 u16 index;
0030 u16 dist;
0031 } near[];
0032 };
0033 #define CPU_RMAP_DIST_INF 0xffff
0034
0035 extern struct cpu_rmap *alloc_cpu_rmap(unsigned int size, gfp_t flags);
0036 extern int cpu_rmap_put(struct cpu_rmap *rmap);
0037
0038 extern int cpu_rmap_add(struct cpu_rmap *rmap, void *obj);
0039 extern int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
0040 const struct cpumask *affinity);
0041
0042 static inline u16 cpu_rmap_lookup_index(struct cpu_rmap *rmap, unsigned int cpu)
0043 {
0044 return rmap->near[cpu].index;
0045 }
0046
0047 static inline void *cpu_rmap_lookup_obj(struct cpu_rmap *rmap, unsigned int cpu)
0048 {
0049 return rmap->obj[rmap->near[cpu].index];
0050 }
0051
0052
0053
0054
0055
0056
0057
0058 static inline struct cpu_rmap *alloc_irq_cpu_rmap(unsigned int size)
0059 {
0060 return alloc_cpu_rmap(size, GFP_KERNEL);
0061 }
0062 extern void free_irq_cpu_rmap(struct cpu_rmap *rmap);
0063
0064 extern int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq);
0065
0066 #endif