From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D7B5325711; Wed, 21 Jan 2026 18:25:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769019934; cv=none; b=ifhIe2MGeDYLEPTB0E++MZ5HWusMl/cOS8thfiOwtKEI7edzuuv1NG3JgVIIP9DeW6DlWz8OcbDFM5NMvZmSsu80ookh1+b+7/3oTZ8JrXD0U6j6WOL651oZo3QXZXpiX9Q5UHRiA4Ki+nyrn4gSZ07/+M4QmM+tiIx/SPCs2/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769019934; c=relaxed/simple; bh=X3Xz67H9qbRaPC60Fl/TnDhLGvE/ctZCUuaqOGGEllI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BZ4KXkQG5vOquSWQkSEg4jdRei1C36ufgnJHqf5Z/bWnvCcpZBUw2eMw0zqgirlugumNN697/thhdAnDcCzP2Pc8bKJawteJM/obHHmlm/otsx7RldtUI7oQ0eelpNDQZ5TQ4/rMEVGGNSKRaGpMjUanFXNxnJjdbKE/GkRUfcQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Q1wSDGfu; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Q1wSDGfu" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B0E7C4CEF1; Wed, 21 Jan 2026 18:25:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1769019934; bh=X3Xz67H9qbRaPC60Fl/TnDhLGvE/ctZCUuaqOGGEllI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q1wSDGfuNuy+UNXd8iv2niNj7Y7N4fzlcCn74wP5lAp17pwemFf2M9RTrLFodcIfw lTF82BmMFotoAtEDaZR9N468Anzs3AP+vM2xIIGn4z/BlNP8TpFqfhCcLW/R07CN3+ 6+LeAFKU7GhJiADQocMSRem0cO1NyzsLUVHgZb30= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ming Lei , Jens Axboe Subject: [PATCH 6.18 011/198] io_uring: move local task_work in exit cancel loop Date: Wed, 21 Jan 2026 19:13:59 +0100 Message-ID: <20260121181418.953751946@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260121181418.537774329@linuxfoundation.org> References: <20260121181418.537774329@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ming Lei commit da579f05ef0faada3559e7faddf761c75cdf85e1 upstream. With IORING_SETUP_DEFER_TASKRUN, task work is queued to ctx->work_llist (local work) rather than the fallback list. During io_ring_exit_work(), io_move_task_work_from_local() was called once before the cancel loop, moving work from work_llist to fallback_llist. However, task work can be added to work_llist during the cancel loop itself. There are two cases: 1) io_kill_timeouts() is called from io_uring_try_cancel_requests() to cancel pending timeouts, and it adds task work via io_req_queue_tw_complete() for each cancelled timeout: 2) URING_CMD requests like ublk can be completed via io_uring_cmd_complete_in_task() from ublk_queue_rq() during canceling, given ublk request queue is only quiesced when canceling the 1st uring_cmd. Since io_allowed_defer_tw_run() returns false in io_ring_exit_work() (kworker != submitter_task), io_run_local_work() is never invoked, and the work_llist entries are never processed. This causes io_uring_try_cancel_requests() to loop indefinitely, resulting in 100% CPU usage in kworker threads. Fix this by moving io_move_task_work_from_local() inside the cancel loop, ensuring any work on work_llist is moved to fallback before each cancel attempt. Cc: stable@vger.kernel.org Fixes: c0e0d6ba25f1 ("io_uring: add IORING_SETUP_DEFER_TASKRUN") Signed-off-by: Ming Lei Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- io_uring/io_uring.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3017,12 +3017,12 @@ static __cold void io_ring_exit_work(str mutex_unlock(&ctx->uring_lock); } - if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) - io_move_task_work_from_local(ctx); - /* The SQPOLL thread never reaches this path */ - while (io_uring_try_cancel_requests(ctx, NULL, true, false)) + do { + if (ctx->flags & IORING_SETUP_DEFER_TASKRUN) + io_move_task_work_from_local(ctx); cond_resched(); + } while (io_uring_try_cancel_requests(ctx, NULL, true, false)); if (ctx->sq_data) { struct io_sq_data *sqd = ctx->sq_data;