From: Tong Tiangen <tongtiangen@huawei.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Naoya Horiguchi <naoya.horiguchi@linux.dev>,
"Paul E. McKenney" <paulmck@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Naoya Horiguchi <naoya.horiguchi@nec.com>,
Miaohe Lin <linmiaohe@huawei.com>, <wangkefeng.wang@huawei.com>,
<linux-mm@kvack.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] mm: memory-failure: use rcu lock instead of tasklist_lock when collect_procs()
Date: Mon, 28 Aug 2023 10:36:56 +0800 [thread overview]
Message-ID: <ce28f147-8c97-36d9-3b5a-bb7a1ac3130f@huawei.com> (raw)
In-Reply-To: <ZOpgXCAAz7PAxT7b@casper.infradead.org>
在 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.
>
> .
prev parent reply other threads:[~2023-08-28 2:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 9:13 Tong Tiangen
2023-08-21 18:33 ` Matthew Wilcox
2023-08-22 3:41 ` Tong Tiangen
2023-08-22 12:08 ` Matthew Wilcox
2023-08-25 6:02 ` Naoya Horiguchi
2023-08-26 1:46 ` Tong Tiangen
2023-08-26 20:28 ` Matthew Wilcox
2023-08-28 2:36 ` Tong Tiangen [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ce28f147-8c97-36d9-3b5a-bb7a1ac3130f@huawei.com \
--to=tongtiangen@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@linux.dev \
--cc=naoya.horiguchi@nec.com \
--cc=paulmck@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=willy@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox