From: Gabriel Krisman Bertazi <krisman@suse.de>
To: "Fengnan Chang" <changfengnan@bytedance.com>
Cc: <axboe@kernel.dk>, <io-uring@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <peterz@infradead.org>,
<rostedt@goodmis.org>
Subject: Re: [PATCH] io_uring/io-wq: avoid repeated task_work scans during teardown
Date: Wed, 20 May 2026 15:44:36 +0200 [thread overview]
Message-ID: <87wlwynqkb.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <20260520031221.83210-1-changfengnan@bytedance.com> (Fengnan Chang's message of "Wed, 20 May 2026 11:12:21 +0800")
"Fengnan Chang" <changfengnan@bytedance.com> writes:
> We hit hard-lockup reports from iou-wrk threads stuck in
It seems like a soft-lockup instead no? From your description,
eventually it solves itself, the task is just uninterruptible while
contending on the spinlock.
> + */
> +struct callback_head *
> +task_work_cancel_match_all(struct task_struct *task,
> + bool (*match)(struct callback_head *, void *data),
> + void *data)
> +{
> + struct callback_head **pprev = &task->task_works;
> + struct callback_head *work, *next;
> + struct callback_head *head = NULL, **tail = &head;
> + unsigned long flags;
> +
> + if (likely(!task_work_pending(task)))
> + return NULL;
> +
> + raw_spin_lock_irqsave(&task->pi_lock, flags);
> + work = READ_ONCE(*pprev);
> + while (work && work != &work_exited) {
> + next = READ_ONCE(work->next);
> + if (!match(work, data)) {
> + pprev = &work->next;
> + work = next;
> + continue;
> + }
> +
> + if (!try_cmpxchg(pprev, &work, next))
> + continue;
IIUC, you could ignore the cmpxchg here because the following loop
iteration on the caller would catch it and retry. In this case, it no
retry in io_wq_cancel_tw_create, which looks weird. Did I miss something?
> +
> + work->next = NULL;
> + *tail = work;
> + tail = &work->next;
> + work = next;
> + }
> + raw_spin_unlock_irqrestore(&task->pi_lock, flags);
> +
> + return head;
> +}
> +
> static bool task_work_func_match(struct callback_head *cb, void *data)
> {
> return cb->func == data;
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2026-05-20 13:44 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-20 3:12 Fengnan Chang
2026-05-20 13:44 ` Gabriel Krisman Bertazi [this message]
2026-05-21 7:14 ` changfengnan
2026-05-21 16:58 ` Jens Axboe
2026-06-15 7:33 ` changfengnan
2026-07-09 9:02 ` changfengnan
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=87wlwynqkb.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=changfengnan@bytedance.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.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
Powered by JetHome