public inbox for cgroups@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cgroup/cpuset: remove unneeded nodes_or() in cpuset_change_task_nodemask()
@ 2023-06-17  8:30 Miaohe Lin
       [not found] ` <20230617083043.2065556-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Miaohe Lin @ 2023-06-17  8:30 UTC (permalink / raw)
  To: longman-H+wXaHxf7aLQT0dZR+AlfA, tj-DgEjT+Ai2ygdnm+yROfE0A,
	hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linmiaohe-hv44wF8Li93QT0dZR+AlfA

The tsk->mems_allowed is changed before calling mpol_rebind_task() and
being reassigned right after it. But tsk->mems_allowed is not needed
inside mpol_rebind_task(). So remove unneeded tsk->mems_allowed modify
via nodes_or() here.

Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
 kernel/cgroup/cpuset.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
index 58e6f18f01c1..33a429c1179f 100644
--- a/kernel/cgroup/cpuset.c
+++ b/kernel/cgroup/cpuset.c
@@ -1941,7 +1941,6 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
 	local_irq_disable();
 	write_seqcount_begin(&tsk->mems_allowed_seq);
 
-	nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
 	mpol_rebind_task(tsk, newmems);
 	tsk->mems_allowed = *newmems;
 
-- 
2.27.0


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

* Re: [PATCH] cgroup/cpuset: remove unneeded nodes_or() in cpuset_change_task_nodemask()
       [not found] ` <20230617083043.2065556-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
@ 2023-06-19 14:37   ` Waiman Long
       [not found]     ` <c32a0bad-b20f-e53b-a38a-5da687b8a205-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Waiman Long @ 2023-06-19 14:37 UTC (permalink / raw)
  To: Miaohe Lin, tj-DgEjT+Ai2ygdnm+yROfE0A,
	hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 6/17/23 04:30, Miaohe Lin wrote:
> The tsk->mems_allowed is changed before calling mpol_rebind_task() and
> being reassigned right after it. But tsk->mems_allowed is not needed
> inside mpol_rebind_task(). So remove unneeded tsk->mems_allowed modify
> via nodes_or() here.
>
> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> ---
>   kernel/cgroup/cpuset.c | 1 -
>   1 file changed, 1 deletion(-)
>
> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> index 58e6f18f01c1..33a429c1179f 100644
> --- a/kernel/cgroup/cpuset.c
> +++ b/kernel/cgroup/cpuset.c
> @@ -1941,7 +1941,6 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
>   	local_irq_disable();
>   	write_seqcount_begin(&tsk->mems_allowed_seq);
>   
> -	nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
>   	mpol_rebind_task(tsk, newmems);
>   	tsk->mems_allowed = *newmems;
>   

That line was inserted by commit cc9a6c8776615 ("cpuset: mm: reduce 
large amounts of memory barrier related damage v3"). At first glance, it 
does looks like it is not necessary. However, I am not sure if a race is 
possible that will produce a false failure because of missing this line.

My 2 cents.

Cheers,
Longman


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

* Re: [PATCH] cgroup/cpuset: remove unneeded nodes_or() in cpuset_change_task_nodemask()
       [not found]     ` <c32a0bad-b20f-e53b-a38a-5da687b8a205-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
@ 2023-06-20  4:02       ` Miaohe Lin
  0 siblings, 0 replies; 3+ messages in thread
From: Miaohe Lin @ 2023-06-20  4:02 UTC (permalink / raw)
  To: Waiman Long, tj-DgEjT+Ai2ygdnm+yROfE0A,
	hannes-druUgvl0LCNAfugRpC6u6w, lizefan.x-EC8Uxl6Npydl57MIdRCFDg
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

On 2023/6/19 22:37, Waiman Long wrote:
> On 6/17/23 04:30, Miaohe Lin wrote:
>> The tsk->mems_allowed is changed before calling mpol_rebind_task() and
>> being reassigned right after it. But tsk->mems_allowed is not needed
>> inside mpol_rebind_task(). So remove unneeded tsk->mems_allowed modify
>> via nodes_or() here.
>>
>> Signed-off-by: Miaohe Lin <linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>>   kernel/cgroup/cpuset.c | 1 -
>>   1 file changed, 1 deletion(-)
>>
>> diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
>> index 58e6f18f01c1..33a429c1179f 100644
>> --- a/kernel/cgroup/cpuset.c
>> +++ b/kernel/cgroup/cpuset.c
>> @@ -1941,7 +1941,6 @@ static void cpuset_change_task_nodemask(struct task_struct *tsk,
>>       local_irq_disable();
>>       write_seqcount_begin(&tsk->mems_allowed_seq);
>>   -    nodes_or(tsk->mems_allowed, tsk->mems_allowed, *newmems);
>>       mpol_rebind_task(tsk, newmems);
>>       tsk->mems_allowed = *newmems;
>>   
> 
> That line was inserted by commit cc9a6c8776615 ("cpuset: mm: reduce large amounts of memory barrier related damage v3"). At first glance, it does looks like it is not necessary. However, I am not sure if a race is possible that will produce a false failure because of missing this line.
> 

Thanks for your comment. IMHO, the code is protected with mems_allowed_seq seqlock. So it should be fine even if there's a race.
I will take a closer look to make sure whether race exists.

> My 2 cents.

Thanks.

> 
> Cheers,
> Longman
> 
> .


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

end of thread, other threads:[~2023-06-20  4:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-17  8:30 [PATCH] cgroup/cpuset: remove unneeded nodes_or() in cpuset_change_task_nodemask() Miaohe Lin
     [not found] ` <20230617083043.2065556-1-linmiaohe-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2023-06-19 14:37   ` Waiman Long
     [not found]     ` <c32a0bad-b20f-e53b-a38a-5da687b8a205-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2023-06-20  4:02       ` Miaohe Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox