Lines Matching +full:- +full:affinity

1 // SPDX-License-Identifier: GPL-2.0-only
7 #include "dm-path-selector.h"
9 #include <linux/device-mapper.h>
12 #define DM_MSG_PREFIX "multipath io-affinity"
29 struct path_info *pi = s->path_map[cpu]; in ioa_free_path()
34 if (refcount_dec_and_test(&pi->refcount)) { in ioa_free_path()
35 cpumask_clear_cpu(cpu, s->path_mask); in ioa_free_path()
36 free_cpumask_var(pi->cpumask); in ioa_free_path()
39 s->path_map[cpu] = NULL; in ioa_free_path()
46 struct selector *s = ps->context; in ioa_add_path()
52 *error = "io-affinity ps: invalid number of arguments"; in ioa_add_path()
53 return -EINVAL; in ioa_add_path()
58 *error = "io-affinity ps: Error allocating path context"; in ioa_add_path()
59 return -ENOMEM; in ioa_add_path()
62 pi->path = path; in ioa_add_path()
63 path->pscontext = pi; in ioa_add_path()
64 refcount_set(&pi->refcount, 1); in ioa_add_path()
66 if (!zalloc_cpumask_var(&pi->cpumask, GFP_KERNEL)) { in ioa_add_path()
67 *error = "io-affinity ps: Error allocating cpumask context"; in ioa_add_path()
68 ret = -ENOMEM; in ioa_add_path()
72 ret = cpumask_parse(argv[0], pi->cpumask); in ioa_add_path()
74 *error = "io-affinity ps: invalid cpumask"; in ioa_add_path()
75 ret = -EINVAL; in ioa_add_path()
79 for_each_cpu(cpu, pi->cpumask) { in ioa_add_path()
86 if (s->path_map[cpu]) { in ioa_add_path()
91 cpumask_set_cpu(cpu, s->path_mask); in ioa_add_path()
92 s->path_map[cpu] = pi; in ioa_add_path()
93 refcount_inc(&pi->refcount); in ioa_add_path()
96 if (refcount_dec_and_test(&pi->refcount)) { in ioa_add_path()
97 *error = "io-affinity ps: No new/valid CPU mapping found"; in ioa_add_path()
98 ret = -EINVAL; in ioa_add_path()
105 free_cpumask_var(pi->cpumask); in ioa_add_path()
117 return -ENOMEM; in ioa_create()
119 s->path_map = kzalloc(nr_cpu_ids * sizeof(struct path_info *), in ioa_create()
121 if (!s->path_map) in ioa_create()
124 if (!zalloc_cpumask_var(&s->path_mask, GFP_KERNEL)) in ioa_create()
127 atomic_set(&s->map_misses, 0); in ioa_create()
128 ps->context = s; in ioa_create()
132 kfree(s->path_map); in ioa_create()
135 return -ENOMEM; in ioa_create()
140 struct selector *s = ps->context; in ioa_destroy()
143 for_each_cpu(cpu, s->path_mask) in ioa_destroy()
146 free_cpumask_var(s->path_mask); in ioa_destroy()
147 kfree(s->path_map); in ioa_destroy()
150 ps->context = NULL; in ioa_destroy()
156 struct selector *s = ps->context; in ioa_status()
167 DMEMIT("%d ", atomic_read(&s->map_misses)); in ioa_status()
170 pi = path->pscontext; in ioa_status()
171 DMEMIT("%*pb ", cpumask_pr_args(pi->cpumask)); in ioa_status()
183 struct path_info *pi = p->pscontext; in ioa_fail_path()
185 pi->failed = true; in ioa_fail_path()
190 struct path_info *pi = p->pscontext; in ioa_reinstate_path()
192 pi->failed = false; in ioa_reinstate_path()
200 struct selector *s = ps->context; in ioa_select_path()
207 pi = s->path_map[cpu]; in ioa_select_path()
208 if (pi && !pi->failed) in ioa_select_path()
216 atomic_inc(&s->map_misses); in ioa_select_path()
221 pi = s->path_map[i]; in ioa_select_path()
222 if (pi && !pi->failed) in ioa_select_path()
226 for_each_cpu(i, s->path_mask) { in ioa_select_path()
227 pi = s->path_map[i]; in ioa_select_path()
228 if (pi && !pi->failed) in ioa_select_path()
235 return pi ? pi->path : NULL; in ioa_select_path()
239 .name = "io-affinity",