linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
@ 2022-12-20 15:14 Daniel Vacek
  2022-12-20 16:59 ` Waiman Long
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Daniel Vacek @ 2022-12-20 15:14 UTC (permalink / raw)
  To: Waiman Long, Zefan Li, Tejun Heo, Johannes Weiner
  Cc: Daniel Vacek, cgroups, linux-kernel

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.

Signed-off-by: Daniel Vacek <neelx@redhat.com>
---
 kernel/cgroup/cpuset.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index a29c0b13706bb..87fe410361b3d 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -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));
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
  2022-12-20 15:14 [PATCH] cgroup/cpuset: no need to explicitly init a global static variable Daniel Vacek
@ 2022-12-20 16:59 ` Waiman Long
  2022-12-21  8:49   ` Daniel Vacek
  2022-12-20 17:32 ` Aaron Tomlin
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 6+ messages in thread
From: Waiman Long @ 2022-12-20 16:59 UTC (permalink / raw)
  To: Daniel Vacek, Zefan Li, Tejun Heo, Johannes Weiner; +Cc: cgroups, linux-kernel

On 12/20/22 10:14, Daniel Vacek wrote:
> 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.
>
> Signed-off-by: Daniel Vacek <neelx@redhat.com>
> ---
>   kernel/cgroup/cpuset.c | 2 --
>   1 file changed, 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index a29c0b13706bb..87fe410361b3d 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
  2022-12-20 15:14 [PATCH] cgroup/cpuset: no need to explicitly init a global static variable Daniel Vacek
  2022-12-20 16:59 ` Waiman Long
@ 2022-12-20 17:32 ` Aaron Tomlin
  2022-12-21  6:19 ` Mukesh Ojha
  2023-01-04 22:21 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Aaron Tomlin @ 2022-12-20 17:32 UTC (permalink / raw)
  To: Daniel Vacek
  Cc: Waiman Long, Zefan Li, Tejun Heo, Johannes Weiner, atomlin,
	cgroups, linux-kernel

On Tue 2022-12-20 16:14 +0100, Daniel Vacek wrote:
> 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.
> 
> Signed-off-by: Daniel Vacek <neelx@redhat.com>
> ---
>  kernel/cgroup/cpuset.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index a29c0b13706bb..87fe410361b3d 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -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));
> -- 
> 2.38.1

Good catch.

Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>

-- 
Aaron Tomlin


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
  2022-12-20 15:14 [PATCH] cgroup/cpuset: no need to explicitly init a global static variable Daniel Vacek
  2022-12-20 16:59 ` Waiman Long
  2022-12-20 17:32 ` Aaron Tomlin
@ 2022-12-21  6:19 ` Mukesh Ojha
  2023-01-04 22:21 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Mukesh Ojha @ 2022-12-21  6:19 UTC (permalink / raw)
  To: Daniel Vacek, Waiman Long, Zefan Li, Tejun Heo, Johannes Weiner
  Cc: cgroups, linux-kernel

Hi,

On 12/20/2022 8:44 PM, Daniel Vacek wrote:
> 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.
> 
> Signed-off-by: Daniel Vacek <neelx@redhat.com>
> ---
>   kernel/cgroup/cpuset.c | 2 --
>   1 file changed, 2 deletions(-)
> 
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index a29c0b13706bb..87fe410361b3d 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -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));

Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>

-Mukesh

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
  2022-12-20 16:59 ` Waiman Long
@ 2022-12-21  8:49   ` Daniel Vacek
  0 siblings, 0 replies; 6+ messages in thread
From: Daniel Vacek @ 2022-12-21  8:49 UTC (permalink / raw)
  To: Waiman Long; +Cc: Zefan Li, Tejun Heo, Johannes Weiner, cgroups, linux-kernel

On Tue, Dec 20, 2022 at 5:59 PM Waiman Long <longman@redhat.com> wrote:
>
> On 12/20/22 10:14, Daniel Vacek wrote:
> > 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

> Cheers,
> Longman
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] cgroup/cpuset: no need to explicitly init a global static variable
  2022-12-20 15:14 [PATCH] cgroup/cpuset: no need to explicitly init a global static variable Daniel Vacek
                   ` (2 preceding siblings ...)
  2022-12-21  6:19 ` Mukesh Ojha
@ 2023-01-04 22:21 ` Tejun Heo
  3 siblings, 0 replies; 6+ messages in thread
From: Tejun Heo @ 2023-01-04 22:21 UTC (permalink / raw)
  To: Daniel Vacek
  Cc: Waiman Long, Zefan Li, Johannes Weiner, cgroups, linux-kernel

On Tue, Dec 20, 2022 at 04:14:15PM +0100, Daniel Vacek wrote:
> 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.
> 
> Signed-off-by: Daniel Vacek <neelx@redhat.com>

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.
    
    Signed-off-by: Daniel Vacek <neelx@redhat.com>
    Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>
    Acked-by: Mukesh Ojha <quic_mojha@quicinc.com>
    Signed-off-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-01-04 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-20 15:14 [PATCH] cgroup/cpuset: no need to explicitly init a global static variable Daniel Vacek
2022-12-20 16:59 ` Waiman Long
2022-12-21  8:49   ` Daniel Vacek
2022-12-20 17:32 ` Aaron Tomlin
2022-12-21  6:19 ` Mukesh Ojha
2023-01-04 22:21 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).