Skip to contentSkip to conversation

cgroup/cpuset: no need to explicitly init a global static variable

PATCH Applied Daniel Vacek 5 participants 6 messages Dec 20, 2022 – Jan 4, 2023

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

PATCH 1/1 cgroup/cpuset: no need to explicitly init a global static variable

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

---
 kernel/cgroup/cpuset.c | 2 --
 1 file changed, 2 deletions(-)
kernel/cgroup/cpuset.c +0 -2
index a29c0b13706bb..87fe410361b3d 100644
@@ -3281,8 +3281,6 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
 
 int __init cpuset_init(void)
 {
-	BUG_ON(percpu_init_rwsem(&cpuset_rwsem));
-
 	BUG_ON(!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL));
 	BUG_ON(!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL));
 	BUG_ON(!zalloc_cpumask_var(&top_cpuset.subparts_cpus, GFP_KERNEL));
Signature · 1 line
2.38.1
maintainer
#1 lore raw
Quoted 13 lines · Daniel Vacek

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

---
  kernel/cgroup/cpuset.c | 2 --
  1 file changed, 2 deletions(-)
kernel/cgroup/cpuset.c +0 -0
index a29c0b13706bb..87fe410361b3d 100644

kernel/cgroup/cpuset.c struct cgroup_subsys cpuset_cgrp_subsys = { · line 3286

Quoted 8 lines
kernel/cgroup/cpuset.c +0 -2
@@ -3281,8 +3281,6 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
 
  int __init cpuset_init(void)
  {
-	BUG_ON(percpu_init_rwsem(&cpuset_rwsem));
-
  	BUG_ON(!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL));
  	BUG_ON(!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL));
  	BUG_ON(!zalloc_cpumask_var(&top_cpuset.subparts_cpus, GFP_KERNEL));

It will be clearer if you mention that DEFINE_STATIC_PERCPU_RWSEM() is used to set up cpuset_rwsem at build time. Other than that, the patch looks good to me.

Cheers,
Longman

#2 lore raw
Quoted 8 lines · Waiman Long
Quoted 2 lines · Daniel Vacek

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

It will be clearer if you mention that DEFINE_STATIC_PERCPU_RWSEM() is used to set up cpuset_rwsem at build time. Other than that, the patch looks good to me.

That's true. I only figured later.
Whoever is going to apply it, feel free to amend the message if you like.

--nX

Quoted 3 lines

Cheers,
Longman

Reviewed-by on v1 1/1
#3 lore raw
In reply to Daniel Vacek
Quoted 23 lines · Daniel Vacek

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

---
 kernel/cgroup/cpuset.c | 2 --
 1 file changed, 2 deletions(-)
kernel/cgroup/cpuset.c +0 -2
index a29c0b13706bb..87fe410361b3d 100644
@@ -3281,8 +3281,6 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
 
 int __init cpuset_init(void)
 {
-	BUG_ON(percpu_init_rwsem(&cpuset_rwsem));
-
 	BUG_ON(!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL));
 	BUG_ON(!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL));
 	BUG_ON(!zalloc_cpumask_var(&top_cpuset.subparts_cpus, GFP_KERNEL));
Signature · 1 line
2.38.1

Good catch.

Signature · 1 line
Aaron Tomlin
Acked-by on v1 1/1
#4 lore raw
In reply to Daniel Vacek

Hi,

Quoted 13 lines · Daniel Vacek

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

---
  kernel/cgroup/cpuset.c | 2 --
  1 file changed, 2 deletions(-)
kernel/cgroup/cpuset.c +0 -0
index a29c0b13706bb..87fe410361b3d 100644

kernel/cgroup/cpuset.c struct cgroup_subsys cpuset_cgrp_subsys = { · line 3286

Quoted 8 lines
kernel/cgroup/cpuset.c +0 -2
@@ -3281,8 +3281,6 @@ struct cgroup_subsys cpuset_cgrp_subsys = {
 
  int __init cpuset_init(void)
  {
-	BUG_ON(percpu_init_rwsem(&cpuset_rwsem));
-
  	BUG_ON(!alloc_cpumask_var(&top_cpuset.cpus_allowed, GFP_KERNEL));
  	BUG_ON(!alloc_cpumask_var(&top_cpuset.effective_cpus, GFP_KERNEL));
  	BUG_ON(!zalloc_cpumask_var(&top_cpuset.subparts_cpus, GFP_KERNEL));

-Mukesh

maintainer Reviewed-by Aaron Tomlin Acked-by Mukesh Ojha on v1 1/1 Applied
#5 lore raw
In reply to Daniel Vacek
Quoted 4 lines · Daniel Vacek

cpuset_rwsem is a static variable. It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

Applied to cgroup/for-6.2-fixes with the following description:

cgroup/cpuset: no need to explicitly init a global static variable

cpuset_rwsem is a static variable defined with DEFINE_STATIC_PERCPU_RWSEM(). It's initialized at build time and so there's no need for explicit runtime init leaking one percpu int.

Thanks.

Signature · 1 line
tejun