From: Matthew Wilcox <willy@infradead.org>
To: Tong Tiangen <tongtiangen@huawei.com>
Cc: 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] mm: memory-failure: use rcu lock instead of tasklist_lock when collect_procs()
Date: Mon, 21 Aug 2023 05:34:55 +0100 [thread overview]
Message-ID: <ZOLpbwwk4esztLaO@casper.infradead.org> (raw)
In-Reply-To: <20230821022534.1381092-1-tongtiangen@huawei.com>
On Mon, Aug 21, 2023 at 10:25:34AM +0800, Tong Tiangen wrote:
> +++ b/mm/memory-failure.c
> @@ -546,24 +546,26 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
> * Find a dedicated thread which is supposed to handle SIGBUS(BUS_MCEERR_AO)
> * on behalf of the thread group. Return task_struct of the (first found)
> * dedicated thread if found, and return NULL otherwise.
> - *
> - * We already hold read_lock(&tasklist_lock) in the caller, so we don't
> - * have to call rcu_read_lock/unlock() in this function.
> */
> static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
> {
> struct task_struct *t;
>
> + rcu_read_lock();
> for_each_thread(tsk, t) {
> if (t->flags & PF_MCE_PROCESS) {
> if (t->flags & PF_MCE_EARLY)
> - return t;
> + goto found;
> } else {
> if (sysctl_memory_failure_early_kill)
> - return t;
> + goto found;
> }
> }
> - return NULL;
> +
> + t = NULL;
> +found:
> + rcu_read_unlock();
> + return t;
> }
I don't understand why you need to modify find_early_kill_thread() at
all. It's still true that the caller holds _a_ lock protecting it; the
comment needs to be updated to reflect that it might be the RCU lock
or the tasklist_lock (or did you change all callers?), but there's no
need for this function to take the RCU lock itself, afaics?
next prev parent reply other threads:[~2023-08-21 4:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-21 2:25 Tong Tiangen
2023-08-21 4:13 ` Naoya Horiguchi
2023-08-21 4:34 ` Matthew Wilcox [this message]
2023-08-21 6:35 ` Tong Tiangen
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=ZOLpbwwk4esztLaO@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=naoya.horiguchi@nec.com \
--cc=tongtiangen@huawei.com \
--cc=wangkefeng.wang@huawei.com \
/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