Skip to content

Commit fc3b618

Browse files
babumogerbp3tk0v
authored andcommitted
x86/resctrl: Replace smp_call_function_many() with on_each_cpu_mask()
on_each_cpu_mask() runs the function on each CPU specified by cpumask, which may include the local processor. Replace smp_call_function_many() with on_each_cpu_mask() to simplify the code. Signed-off-by: Babu Moger <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2241ab5 commit fc3b618

File tree

2 files changed

+11
-29
lines changed

2 files changed

+11
-29
lines changed

arch/x86/kernel/cpu/resctrl/ctrlmondata.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,6 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
310310
enum resctrl_conf_type t;
311311
cpumask_var_t cpu_mask;
312312
struct rdt_domain *d;
313-
int cpu;
314313
u32 idx;
315314

316315
if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
@@ -341,13 +340,9 @@ int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid)
341340

342341
if (cpumask_empty(cpu_mask))
343342
goto done;
344-
cpu = get_cpu();
345-
/* Update resource control msr on this CPU if it's in cpu_mask. */
346-
if (cpumask_test_cpu(cpu, cpu_mask))
347-
rdt_ctrl_update(&msr_param);
348-
/* Update resource control msr on other CPUs. */
349-
smp_call_function_many(cpu_mask, rdt_ctrl_update, &msr_param, 1);
350-
put_cpu();
343+
344+
/* Update resource control msr on all the CPUs. */
345+
on_each_cpu_mask(cpu_mask, rdt_ctrl_update, &msr_param, 1);
351346

352347
done:
353348
free_cpumask_var(cpu_mask);

arch/x86/kernel/cpu/resctrl/rdtgroup.c

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,7 @@ static void update_cpu_closid_rmid(void *info)
325325
static void
326326
update_closid_rmid(const struct cpumask *cpu_mask, struct rdtgroup *r)
327327
{
328-
int cpu = get_cpu();
329-
330-
if (cpumask_test_cpu(cpu, cpu_mask))
331-
update_cpu_closid_rmid(r);
332-
smp_call_function_many(cpu_mask, update_cpu_closid_rmid, r, 1);
333-
put_cpu();
328+
on_each_cpu_mask(cpu_mask, update_cpu_closid_rmid, r, 1);
334329
}
335330

336331
static int cpus_mon_write(struct rdtgroup *rdtgrp, cpumask_var_t newmask,
@@ -1866,13 +1861,9 @@ static int set_cache_qos_cfg(int level, bool enable)
18661861
/* Pick one CPU from each domain instance to update MSR */
18671862
cpumask_set_cpu(cpumask_any(&d->cpu_mask), cpu_mask);
18681863
}
1869-
cpu = get_cpu();
1870-
/* Update QOS_CFG MSR on this cpu if it's in cpu_mask. */
1871-
if (cpumask_test_cpu(cpu, cpu_mask))
1872-
update(&enable);
1873-
/* Update QOS_CFG MSR on all other cpus in cpu_mask. */
1874-
smp_call_function_many(cpu_mask, update, &enable, 1);
1875-
put_cpu();
1864+
1865+
/* Update QOS_CFG MSR on all the CPUs in cpu_mask */
1866+
on_each_cpu_mask(cpu_mask, update, &enable, 1);
18761867

18771868
free_cpumask_var(cpu_mask);
18781869

@@ -2349,7 +2340,7 @@ static int reset_all_ctrls(struct rdt_resource *r)
23492340
struct msr_param msr_param;
23502341
cpumask_var_t cpu_mask;
23512342
struct rdt_domain *d;
2352-
int i, cpu;
2343+
int i;
23532344

23542345
if (!zalloc_cpumask_var(&cpu_mask, GFP_KERNEL))
23552346
return -ENOMEM;
@@ -2370,13 +2361,9 @@ static int reset_all_ctrls(struct rdt_resource *r)
23702361
for (i = 0; i < hw_res->num_closid; i++)
23712362
hw_dom->ctrl_val[i] = r->default_ctrl;
23722363
}
2373-
cpu = get_cpu();
2374-
/* Update CBM on this cpu if it's in cpu_mask. */
2375-
if (cpumask_test_cpu(cpu, cpu_mask))
2376-
rdt_ctrl_update(&msr_param);
2377-
/* Update CBM on all other cpus in cpu_mask. */
2378-
smp_call_function_many(cpu_mask, rdt_ctrl_update, &msr_param, 1);
2379-
put_cpu();
2364+
2365+
/* Update CBM on all the CPUs in cpu_mask */
2366+
on_each_cpu_mask(cpu_mask, rdt_ctrl_update, &msr_param, 1);
23802367

23812368
free_cpumask_var(cpu_mask);
23822369

0 commit comments

Comments
 (0)