2024-04-20 09:52:57

by Xiu Jianfeng

[permalink] [raw]
Subject: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset

Initializing top_cpuset.relax_domain_level and setting
CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
completed at the time of top_cpuset definition by compiler.

Signed-off-by: Xiu Jianfeng <[email protected]>
---
kernel/cgroup/cpuset.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index d8d3439eda4e..e70008a1d86a 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -369,8 +369,9 @@ 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_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
.partition_root_state = PRS_ROOT,
+ .relax_domain_level = -1,
.remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
};

@@ -4309,8 +4310,6 @@ int __init cpuset_init(void)
nodes_setall(top_cpuset.effective_mems);

fmeter_init(&top_cpuset.fmeter);
- set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags);
- top_cpuset.relax_domain_level = -1;
INIT_LIST_HEAD(&remote_children);

BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
--
2.34.1



2024-04-22 18:35:03

by Waiman Long

[permalink] [raw]
Subject: Re: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset


On 4/20/24 05:46, Xiu Jianfeng wrote:
> Initializing top_cpuset.relax_domain_level and setting
> CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
> completed at the time of top_cpuset definition by compiler.
>
> Signed-off-by: Xiu Jianfeng <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index d8d3439eda4e..e70008a1d86a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -369,8 +369,9 @@ 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_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
> .partition_root_state = PRS_ROOT,
> + .relax_domain_level = -1,
> .remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
> };
>
> @@ -4309,8 +4310,6 @@ int __init cpuset_init(void)
> nodes_setall(top_cpuset.effective_mems);
>
> fmeter_init(&top_cpuset.fmeter);
> - set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags);
> - top_cpuset.relax_domain_level = -1;
> INIT_LIST_HEAD(&remote_children);
>
> BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
Reviewed-by: Waiman Long <[email protected]>


2024-04-22 19:54:41

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset

On Sat, Apr 20, 2024 at 09:46:16AM +0000, Xiu Jianfeng wrote:
> Initializing top_cpuset.relax_domain_level and setting
> CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
> completed at the time of top_cpuset definition by compiler.
>
> Signed-off-by: Xiu Jianfeng <[email protected]>

Applied to cgroup/for-6.10.

Thanks.

--
tejun

2024-04-23 19:22:50

by Klara Modin

[permalink] [raw]
Subject: Re: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset

Hi,

On 2024-04-20 11:46, Xiu Jianfeng wrote:
> Initializing top_cpuset.relax_domain_level and setting
> CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
> completed at the time of top_cpuset definition by compiler.
>
> Signed-off-by: Xiu Jianfeng <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index d8d3439eda4e..e70008a1d86a 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -369,8 +369,9 @@ 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_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),

You dropped a '<' for the bitwise shift, this causes bad cpu utilization
for me.

> .partition_root_state = PRS_ROOT,
> + .relax_domain_level = -1,
> .remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
> };
>
> @@ -4309,8 +4310,6 @@ int __init cpuset_init(void)
> nodes_setall(top_cpuset.effective_mems);
>
> fmeter_init(&top_cpuset.fmeter);
> - set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags);
> - top_cpuset.relax_domain_level = -1;
> INIT_LIST_HEAD(&remote_children);
>
> BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));

Kind regards,
Klara Modin


Attachments:
bisect-bad-cpu-util (4.13 kB)
0001-cgroup-cpuset-fix-bitwise-shift-in-top_cpuset-initia.patch (1.04 kB)
Download all attachments

2024-04-23 19:51:27

by Waiman Long

[permalink] [raw]
Subject: Re: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset


On 4/23/24 15:21, Klara Modin wrote:
> Hi,
>
> On 2024-04-20 11:46, Xiu Jianfeng wrote:
>> Initializing top_cpuset.relax_domain_level and setting
>> CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
>> completed at the time of top_cpuset definition by compiler.
>>
>> Signed-off-by: Xiu Jianfeng <[email protected]>
>> ---
>>   kernel/cgroup/cpuset.c | 5 ++---
>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index d8d3439eda4e..e70008a1d86a 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -369,8 +369,9 @@ 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_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
>
> You dropped a '<' for the bitwise shift, this causes bad cpu
> utilization for me.

Oh, now load_balancing is disable by default in the root cgroup. That is
bad. Will post a patch to fix it.

Thanks,
Longman



>
>>       .partition_root_state = PRS_ROOT,
>> +    .relax_domain_level = -1,
>>       .remote_sibling = LIST_HEAD_INIT(top_cpuset.remote_sibling),
>>   };
>>   @@ -4309,8 +4310,6 @@ int __init cpuset_init(void)
>>       nodes_setall(top_cpuset.effective_mems);
>>         fmeter_init(&top_cpuset.fmeter);
>> -    set_bit(CS_SCHED_LOAD_BALANCE, &top_cpuset.flags);
>> -    top_cpuset.relax_domain_level = -1;
>>       INIT_LIST_HEAD(&remote_children);
>>         BUG_ON(!alloc_cpumask_var(&cpus_attach, GFP_KERNEL));
>
> Kind regards,
> Klara Modin


2024-04-23 20:10:54

by Klara Modin

[permalink] [raw]
Subject: Re: [PATCH -next] cgroup/cpuset: Statically initialize more members of top_cpuset

On 2024-04-23 21:50, Waiman Long wrote:
>
> On 4/23/24 15:21, Klara Modin wrote:
>> Hi,
>>
>> On 2024-04-20 11:46, Xiu Jianfeng wrote:
>>> Initializing top_cpuset.relax_domain_level and setting
>>> CS_SCHED_LOAD_BALANCE to top_cpuset.flags in cpuset_init() could be
>>> completed at the time of top_cpuset definition by compiler.
>>>
>>> Signed-off-by: Xiu Jianfeng <[email protected]>
>>> ---
>>>   kernel/cgroup/cpuset.c | 5 ++---
>>>   1 file changed, 2 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>>> index d8d3439eda4e..e70008a1d86a 100644
>>> --- a/kernel/cgroup/cpuset.c
>>> +++ b/kernel/cgroup/cpuset.c
>>> @@ -369,8 +369,9 @@ 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_MEM_EXCLUSIVE) | (1 < CS_SCHED_LOAD_BALANCE)),
>>
>> You dropped a '<' for the bitwise shift, this causes bad cpu
>> utilization for me.
>
> Oh, now load_balancing is disable by default in the root cgroup. That is
> bad. Will post a patch to fix it.
>
> Thanks,
> Longman
>
I attached one in my previous message, though I'm still very new at this
and may have missed something.

Regards,
Klara Modin