2024-04-24 01:01:23

by Waiman Long

[permalink] [raw]
Subject: [PATCH-cgroup] cgroup/cpuset: Fix incorrect top_cpuset flags

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")
Signed-off-by: Waiman Long <[email protected]>
---
kernel/cgroup/cpuset.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index e70008a1d86a..b0a97efa5f20 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -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),
--
2.39.3



2024-04-24 01:03:09

by Waiman Long

[permalink] [raw]
Subject: Re: [PATCH-cgroup] cgroup/cpuset: Fix incorrect top_cpuset flags


On 4/23/24 21:00, Waiman Long wrote:
> 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")
> Signed-off-by: Waiman Long <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index e70008a1d86a..b0a97efa5f20 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -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]>


2024-04-24 01:30:41

by Xiu Jianfeng

[permalink] [raw]
Subject: Re: [PATCH-cgroup] cgroup/cpuset: Fix incorrect top_cpuset flags



On 2024/4/24 9:02, Waiman Long wrote:
>
> On 4/23/24 21:00, Waiman Long wrote:
>> 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")
>> Signed-off-by: Waiman Long <[email protected]>
>> ---
>>   kernel/cgroup/cpuset.c | 4 ++--
>>   1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index e70008a1d86a..b0a97efa5f20 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -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. :)

>

2024-04-24 03:32:21

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH-cgroup] cgroup/cpuset: Fix incorrect top_cpuset flags

On Tue, Apr 23, 2024 at 09:00:20PM -0400, Waiman Long wrote:
> 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")
> Signed-off-by: Waiman Long <[email protected]>

Applied to cgroup/for-6.10.

Thanks.

--
tejun

2024-04-24 11:13:04

by Klara Modin

[permalink] [raw]
Subject: Re: [PATCH-cgroup] cgroup/cpuset: Fix incorrect top_cpuset flags

On 2024-04-24 03:00, Waiman Long wrote:
> 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")
> Signed-off-by: Waiman Long <[email protected]>
> ---
> kernel/cgroup/cpuset.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index e70008a1d86a..b0a97efa5f20 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -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,
Tested-by: Klara Modin <[email protected]>

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