2 * cpu_rmap.c: CPU affinity reverse-map support
3 * Copyright 2011 Solarflare Communications Inc.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 as published
7 * by the Free Software Foundation, incorporated herein by reference.
10 #include <linux/cpumask.h>
11 #include <linux/gfp.h>
12 #include <linux/slab.h>
15 * struct cpu_rmap - CPU affinity reverse-map
16 * @size: Number of objects to be reverse-mapped
17 * @used: Number of objects added
18 * @obj: Pointer to array of object pointers
19 * @near: For each CPU, the index and distance to the nearest object,
20 * based on affinity masks
30 #define CPU_RMAP_DIST_INF 0xffff
32 extern struct cpu_rmap
*alloc_cpu_rmap(unsigned int size
, gfp_t flags
);
35 * free_cpu_rmap - free CPU affinity reverse-map
36 * @rmap: Reverse-map allocated with alloc_cpu_rmap(), or %NULL
38 static inline void free_cpu_rmap(struct cpu_rmap
*rmap
)
43 extern int cpu_rmap_add(struct cpu_rmap
*rmap
, void *obj
);
44 extern int cpu_rmap_update(struct cpu_rmap
*rmap
, u16 index
,
45 const struct cpumask
*affinity
);
47 static inline u16
cpu_rmap_lookup_index(struct cpu_rmap
*rmap
, unsigned int cpu
)
49 return rmap
->near
[cpu
].index
;
52 static inline void *cpu_rmap_lookup_obj(struct cpu_rmap
*rmap
, unsigned int cpu
)
54 return rmap
->obj
[rmap
->near
[cpu
].index
];
57 #ifdef CONFIG_GENERIC_HARDIRQS
60 * alloc_irq_cpu_rmap - allocate CPU affinity reverse-map for IRQs
61 * @size: Number of objects to be mapped
63 * Must be called in process context.
65 static inline struct cpu_rmap
*alloc_irq_cpu_rmap(unsigned int size
)
67 return alloc_cpu_rmap(size
, GFP_KERNEL
);
69 extern void free_irq_cpu_rmap(struct cpu_rmap
*rmap
);
71 extern int irq_cpu_rmap_add(struct cpu_rmap
*rmap
, int irq
);
This page took 0.031229 seconds and 5 git commands to generate.