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)
132 * cpu_rmap_add - add object to a rmap
133 * @rmap: CPU rmap allocated with alloc_cpu_rmap()
134 * @obj: Object to add to rmap
138 int cpu_rmap_add(struct cpu_rmap *rmap, void *obj)
142 BUG_ON(rmap->used >= rmap->size);
143 index = rmap->used++;
144 rmap->obj[index] = obj;
150 * cpu_rmap_update - update CPU rmap following a change of object affinity
151 * @rmap: CPU rmap to update
155 int cpu_rmap_update(struct cpu_rmap *rmap, u16 index,
168 if (rmap->near[cpu].index == index) {
169 rmap->near[cpu].dist = CPU_RMAP_DIST_INF;
174 debug_print_rmap(rmap, "after invalidating old distances");
180 rmap->near[cpu].index = index;
181 rmap->near[cpu].dist = 0;
186 debug_print_rmap(rmap, "after updating neighbours");
190 if (cpu_rmap_copy_neigh(rmap, cpu,
193 if (cpu_rmap_copy_neigh(rmap, cpu,
196 if (cpu_rmap_copy_neigh(rmap, cpu,
204 debug_print_rmap(rmap, "after copying neighbours");
215 struct cpu_rmap *rmap;
221 * @rmap: Reverse-map allocated with alloc_irq_cpu_map(), or %NULL
225 void free_irq_cpu_rmap(struct cpu_rmap *rmap)
230 if (!rmap)
233 for (index = 0; index < rmap->used; index++) {
234 glue = rmap->obj[index];
239 cpu_rmap_put(rmap);
257 rc = cpu_rmap_update(glue->rmap, glue->index, mask);
271 glue->rmap->obj[glue->index] = NULL;
272 cpu_rmap_put(glue->rmap);
278 * @rmap: The reverse-map
287 int irq_cpu_rmap_add(struct cpu_rmap *rmap, int irq)
296 glue->rmap = rmap;
297 cpu_rmap_get(rmap);
298 glue->index = cpu_rmap_add(rmap, glue);
301 cpu_rmap_put(glue->rmap);
302 rmap->obj[glue->index] = NULL;