Skip to contentSkip to conversation

cgroup/cpuset: Fix incorrect top_cpuset flags

PATCH-cgroup Applied Waiman Long 4 participants 5 messages Apr 24, 2024

Subsystems (2)
lore
Share & tools
lore

Waiman Long

author maintainer
#0 lore raw

Commit 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset") uses an incorrect "<" relational operator for the CS_SCHED_LOAD_BALANCE bit when initializing the top_cpuset. This results in load_balancing turned off by default in the top cpuset which is bad for performance.

Fix this by using the BIT() helper macro to set the desired top_cpuset flags and avoid similar mistake from being made in the future.

Fixes 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset")
---
 kernel/cgroup/cpuset.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +2 -2
index e70008a1d86a..b0a97efa5f20 100644
@@ -368,8 +368,8 @@ static inline void notify_partition_change(struct cpuset *cs, int old_prs)
 }
 
 static struct cpuset top_cpuset = {
-	.flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) |
-		  (1 << CS_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
+	.flags = BIT(CS_ONLINE) | BIT(CS_CPU_EXCLUSIVE) |
+		 BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
 	.partition_root_state = PRS_ROOT,
 	.relax_domain_level = -1,
 	.remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
Signature · 1 line
2.39.3
author maintainer
#1 lore raw
Quoted 20 lines · Waiman Long

Commit 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset") uses an incorrect "<" relational operator for the CS_SCHED_LOAD_BALANCE bit when initializing the top_cpuset. This results in load_balancing turned off by default in the top cpuset which is bad for performance.

Fix this by using the BIT() helper macro to set the desired top_cpuset flags and avoid similar mistake from being made in the future.

Fixes 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset")
---
  kernel/cgroup/cpuset.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +0 -0
index e70008a1d86a..b0a97efa5f20 100644

kernel/cgroup/cpuset.c static inline void notify_partition_change(struct cpuset *cs, int old_prs) · line 375

Quoted 10 lines
kernel/cgroup/cpuset.c +2 -2
@@ -368,8 +368,8 @@ static inline void notify_partition_change(struct cpuset *cs, int old_prs)
  }
 
  static struct cpuset top_cpuset = {
-	.flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) |
-		  (1 << CS_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
+	.flags = BIT(CS_ONLINE) | BIT(CS_CPU_EXCLUSIVE) |
+		 BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
  	.partition_root_state = PRS_ROOT,
  	.relax_domain_level = -1,
  	.remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),

Add cc to xiujianfeng <[email protected]>

#2 lore raw
Quoted 18 lines · Waiman Long
Quoted 16 lines · Waiman Long

Commit 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset") uses an incorrect "<" relational operator for the CS_SCHED_LOAD_BALANCE bit when initializing the top_cpuset. This results in load_balancing turned off by default in the top cpuset which is bad for performance.

Fix this by using the BIT() helper macro to set the desired top_cpuset flags and avoid similar mistake from being made in the future.

Fixes 8996f93fc388 ("cgroup/cpuset: Statically initialize more

members of top_cpuset")

---
  kernel/cgroup/cpuset.c | 4 ++--

  1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines
Quoted 5 lines
kernel/cgroup/cpuset.c +0 -0
index e70008a1d86a..b0a97efa5f20 100644

kernel/cgroup/cpuset.c static inline void notify_partition_change(struct · line 375

Quoted 10 lines
kernel/cgroup/cpuset.c +2 -2
@@ -368,8 +368,8 @@ static inline void notify_partition_change(struct
 cpuset *cs, int old_prs)
   }
     static struct cpuset top_cpuset = {
-    .flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) |
-          (1 << CS_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
+    .flags = BIT(CS_ONLINE) | BIT(CS_CPU_EXCLUSIVE) |
+         BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
       .partition_root_state = PRS_ROOT,
       .relax_domain_level = -1,
       .remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),

Add cc to xiujianfeng <[email protected]>

Thanks, this looks good. :)

Quoted 1 line
maintainer Applied
#3 lore raw
In reply to Waiman Long
Quoted 11 lines · Waiman Long

Commit 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset") uses an incorrect "<" relational operator for the CS_SCHED_LOAD_BALANCE bit when initializing the top_cpuset. This results in load_balancing turned off by default in the top cpuset which is bad for performance.

Fix this by using the BIT() helper macro to set the desired top_cpuset flags and avoid similar mistake from being made in the future.

Fixes 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset")

Applied to cgroup/for-6.10.

Thanks.

Signature · 1 line
tejun
Tested-by
#4 lore raw
In reply to Waiman Long
Quoted 20 lines · Waiman Long

Commit 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset") uses an incorrect "<" relational operator for the CS_SCHED_LOAD_BALANCE bit when initializing the top_cpuset. This results in load_balancing turned off by default in the top cpuset which is bad for performance.

Fix this by using the BIT() helper macro to set the desired top_cpuset flags and avoid similar mistake from being made in the future.

Fixes 8996f93fc388 ("cgroup/cpuset: Statically initialize more members of top_cpuset")
---
  kernel/cgroup/cpuset.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
kernel/cgroup/cpuset.c +0 -0
index e70008a1d86a..b0a97efa5f20 100644

kernel/cgroup/cpuset.c static inline void notify_partition_change(struct cpuset *cs, int old_prs) · line 375

Quoted 10 lines
kernel/cgroup/cpuset.c +2 -2
@@ -368,8 +368,8 @@ static inline void notify_partition_change(struct cpuset *cs, int old_prs)
  }
 
  static struct cpuset top_cpuset = {
-	.flags = ((1 << CS_ONLINE) | (1 << CS_CPU_EXCLUSIVE) |
-		  (1 << CS_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
+	.flags = BIT(CS_ONLINE) | BIT(CS_CPU_EXCLUSIVE) |
+		 BIT(CS_MEM_EXCLUSIVE) | BIT(CS_SCHED_LOAD_BALANCE),
  	.partition_root_state = PRS_ROOT,
  	.relax_domain_level = -1,
  	.remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),

I saw this made its way into today's next and can confirm it fixes the issue I reported in [1].

Thanks,

1. https://lore.kernel.org/lkml/[email protected]