lkml.org 
[lkml]   [2023]   [Aug]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2] mm: memory-failure: use rcu lock instead of tasklist_lock when collect_procs()
From


在 2023/8/27 4:28, Matthew Wilcox 写道:
> On Sat, Aug 26, 2023 at 09:46:53AM +0800, Tong Tiangen wrote:
>> " the ``task_struct`` object is freed only after one or more
>> grace periods elapse, with the help of call_rcu(), which is invoked via
>> put_task_struct_rcu_user(). "
>>
>> Combined with the code,when the task exits:
>>
>> release_task()
>> __exit_signal()
>> __unhash_process()
>> list_del_rcu(&p->tasks)
>>
>> put_task_struct_rcu_user()
>> call_rcu(&task->rcu, delayed_put_task_struct);
>>
>> delayed_put_task_struct()
>> put_task_struct()
>> if (refcount_sub_and_test(nr, &t->usage))
>> __put_task_struct()
>> free_task()
>>
>> The code is consistent with the description in the document.
>>
>> According to this understanding, i think for_each_process() under the
>> protection of rcu locl is safe, that is, task_struct in the list will not be
>> destroyed, and get_task_struct() is also safe.
>
> Aha! This is different from the usual pattern. What I'm used to seeing
> is:
>
> if (refcount_sub_and_test()) {
> list_del_rcu();
> rcu_free();
> }
>
> and then on the read side you need a refcount_inc_not_zero(), which we
> didn't have here. Given this new information you've found, I withdraw
> my objection. It'd be nice to include some of this analysis in an
> updated changelog (and maybe improved documentation for tasklist?).

OK, commit message and changelog have been updated, and a new patch
version v3 has been sent.

Thanks,
Tong.

>
> .

\
 
 \ /
  Last update: 2023-08-28 04:38    [W:0.089 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site