Skip to contentSkip to conversation

cgroup/cpuset: reduce redundant comparisons for generating shecd domains

PATCH In review Chen Ridong 2 participants 3 messages Jul 26, 2024 – Jul 27, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cgroup/cpuset: reduce redundant comparisons for generating shecd domains

In the generate_sched_domains function, it's unnecessary to start the second for loop with zero, which leads redundant comparisons. Simply start with i+1, as that is sufficient.

---
 kernel/cgroup/cpuset.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cgroup/cpuset.c +1 -1
index 40ec4abaf440..1c4c36db3d93 100644
@@ -1113,7 +1113,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
 		struct cpuset *a = csa[i];
 		int apn = a->pn;
 
-		for (j = 0; j < csn; j++) {
+		for (j = i + 1; j < csn; j++) {
 			struct cpuset *b = csa[j];
 			int bpn = b->pn;
 
Signature · 1 line
2.34.1
maintainer
#1 lore raw

Hello.

Quoted 3 lines · Chen Ridong

In the generate_sched_domains function, it's unnecessary to start the second for loop with zero, which leads redundant comparisons. Simply start with i+1, as that is sufficient.

Please see
https://lore.kernel.org/r/[email protected]

Your patch is likely obsoleted with that.

Michal

author
#2 lore raw
Quoted 7 lines · Michal Koutný

Hello.

Quoted 3 lines · Chen Ridong

In the generate_sched_domains function, it's unnecessary to start the second for loop with zero, which leads redundant comparisons. Simply start with i+1, as that is sufficient.

Quoted 6 lines

Please see
https://lore.kernel.org/r/[email protected]

Your patch is likely obsoleted with that.

Michal

Thanks, Michal, I'm sorry I didn't notice these patches. It's a good idea to optimize with uf_node.

Thanks
Ridong