lib/group_cpus: sequentially bind CPUs within node to groups.
Subsystems (2)
PATCH 1/1 lib/group_cpus: sequentially bind CPUs within node to groups.
From: Chunguang Xu <[email protected]>
grp_spread_init_one() tends to bind adjacent CPUs to a queue, which may leads to performance regresstion in some case, such as SPDK, business often need to bind SPDK to static CPUs to poll data, such as 3,4,5,6, this will result in some SPDK instance may only have one queue active. So I think we should tends to spread the CPUs within node to all queue sequentially as what we do before.
Signed-off-by Chunguang Xu <[email protected]>
--- lib/group_cpus.c | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-)
lib/group_cpus.c +23 -19
@@ -11,19 +11,28 @@#ifdef CONFIG_SMP -static void grp_spread_init_one (struct cpumask *irqmsk,struct cpumask *nmsk, -unsigned int cpus_per_grp) +struct node_groups { +unsigned id; + +union { +unsigned ngroups; +unsigned ncpus; + }; +}; + +static void grp_spread_init_one (struct node_groups *nv,struct cpumask *irqmsk, +struct cpumask *nmsk,unsigned int cpus_per_grp) {const struct cpumask *siblmsk;int cpu, sibl; + cpu =cpumask_first (nmsk); + +/* Should not happen, but I'm too lazy to think about it */ +if (cpu >= nr_cpu_ids) +return ; +for ( ; cpus_per_grp >0 ; ) { - cpu =cpumask_first (nmsk); - -/* Should not happen, but I'm too lazy to think about it */ -if (cpu >= nr_cpu_ids) -return ; -cpumask_clear_cpu (cpu, nmsk);cpumask_set_cpu (cpu, irqmsk); cpus_per_grp--;
@@ -39,6 +48,10 @@ static void grp_spread_init_one(struct cpumask *irqmsk, struct cpumask *nmsk,cpumask_set_cpu (sibl, irqmsk); cpus_per_grp--; } + + cpu += nv->ngroups; +if (!cpumask_test_cpu (cpu, nmsk)) +return ; } }
@@ -97,15 +110,6 @@ static int get_nodes_in_cpumask(cpumask_var_t *node_to_cpumask,return nodes; } -struct node_groups { -unsigned id; - -union { -unsigned ngroups; -unsigned ncpus; - }; -}; -static int ncpus_cmp_func (const void *l,const void *r) {const struct node_groups *ln = l;
@@ -320,8 +324,8 @@ static int __group_cpus_evenly(unsigned int startgrp, unsigned int numgrps,*/ if (curgrp >= last_grp) curgrp =0 ; -grp_spread_init_one (&masks[curgrp], nmsk, - cpus_per_grp); + +grp_spread_init_one (nv, &masks[curgrp], nmsk, cpus_per_grp); } done += nv->ngroups; }
Signature · 1 line
2.43.0