Lines Matching defs:rmap

27 	struct cpu_rmap *rmap;
39 rmap = kzalloc(obj_offset + size * sizeof(rmap->obj[0]), flags);
40 if (!rmap)
43 kref_init(&rmap->refcount);
44 rmap->obj = (void **)((char *)rmap + obj_offset);
53 rmap->near[cpu].index = cpu % size;
54 rmap->near[cpu].dist = CPU_RMAP_DIST_INF;
57 rmap->size = size;
58 return rmap;
68 struct cpu_rmap *rmap = container_of(ref, struct cpu_rmap, refcount);
69 kfree(rmap);
74 * @rmap: reverse-map allocated with alloc_cpu_rmap()
76 static inline void cpu_rmap_get(struct cpu_rmap *rmap)
78 kref_get(&rmap->refcount);
83 * @rmap: reverse-map allocated with alloc_cpu_rmap()
85 int cpu_rmap_put(struct cpu_rmap *rmap)
87 return kref_put(&rmap->refcount, cpu_rmap_release);
94 static bool cpu_rmap_copy_neigh(struct cpu_rmap *rmap, unsigned int cpu,
100 if (rmap->near[cpu].dist > dist &&
101 rmap->near[neigh].dist <= dist) {
102 rmap->near[cpu].index = rmap->near[neigh].index;
103 rmap->near[cpu].dist = dist;
111 static void debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
116 pr_info("cpu_rmap %p, %s:\n", rmap, prefix);
119 index = rmap->near[cpu].index;
121 cpu, index, rmap->near[cpu].dist);
126 debug_print_rmap(const struct cpu_rmap *rmap, const char *prefix)
131 static int get_free_index(struct cpu_rmap *rmap)
135 for (i = 0; i < rmap->size; i++)
136 if (!rmap->obj[i])
143 * cpu_rmap_add - add object to a rmap
144 * @rmap: CPU rmap allocated with alloc_cpu_rmap()
145 * @obj: Object to add to rmap
149 int cpu_rmap_add(struct cpu_rmap *rmap, void *obj)
151 int index = get_free_index(rmap);
156 rmap->obj[index] = obj;
162 * cpu_rmap_update - update CPU rmap following a change of object affinity
163 * @rmap: CPU rmap to update
167 int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
180 if (rmap->near[cpu].index == index) {
181 rmap->near[cpu].dist = CPU_RMAP_DIST_INF;
186 debug_print_rmap(rmap, "after invalidating old distances");
192 rmap->near[cpu].index = index;
193 rmap->near[cpu].dist = 0;
198 debug_print_rmap(rmap, "after updating neighbours");
202 if (cpu_rmap_copy_neigh(rmap, cpu,
205 if (cpu_rmap_copy_neigh(rmap, cpu,
208 if (cpu_rmap_copy_neigh(rmap, cpu,
216 debug_print_rmap(rmap, "after copying neighbours");
227 struct cpu_rmap *rmap;
233 * @rmap: Reverse-map allocated with alloc_irq_cpu_map(), or %NULL
237 void free_irq_cpu_rmap(struct cpu_rmap *rmap)
242 if (!rmap)
245 for (index = 0; index < rmap->size; index++) {
246 glue = rmap->obj[index];
251 cpu_rmap_put(rmap);
269 rc = cpu_rmap_update(glue->rmap, glue->index, mask);
283 glue->rmap->obj[glue->index] = NULL;
284 cpu_rmap_put(glue->rmap);
290 * @rmap: The reverse-map
293 int irq_cpu_rmap_remove(struct cpu_rmap *rmap, int irq)
301 * @rmap: The reverse-map
310 int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq)
319 glue->rmap = rmap;
320 cpu_rmap_get(rmap);
321 rc = cpu_rmap_add(rmap, glue);
333 rmap->obj[glue->index] = NULL;
335 cpu_rmap_put(glue->rmap);