From nobody Sun Feb 8 01:36:29 2026 Received: from mail-pl1-f227.google.com (mail-pl1-f227.google.com [209.85.214.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C50B22F8BC3 for ; Tue, 2 Dec 2025 20:57:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764709075; cv=none; b=W/y6k88gUPKqr9f8E9dKp/SQQk9jf/WZSY1VkkD/TgiLxOJ6vGSFSPhCkWTAGRvAUtEbK6x00RCn+Lgwm9bxpPCP+/oiq2U7OCHLJMW/JPFW/9LOh6+Nd8awOKMRXIFKgSk9AHIKDkomrF3AMy0h79QOoYiwcLbz8sQ+ynGBUm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764709075; c=relaxed/simple; bh=sX0ww1/l52mEd0ETRBUj2OEXBY14nu/Cxss4GuQO1UY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=QigoLSgHWDtl/NUbE5le/TRGze4YBR1wQIPfylCZwFsX0W5K7QuZeatlOCoKCyRaclXsyXZLF6FGb3h5pfMQ7zLOpX6by8ZVycOaM+3YmKWzzhT3Shru1oGM6HFk0c8d1hcUeAxlEg57cuyHGPywodR+zdKFcM5tXQoqC05FhcQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=KICAI0kf; arc=none smtp.client-ip=209.85.214.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="KICAI0kf" Received: by mail-pl1-f227.google.com with SMTP id d9443c01a7336-297f2c718a8so9981915ad.3 for ; Tue, 02 Dec 2025 12:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1764709073; x=1765313873; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=WCFY6ttRSuGdVF/JBzuDEsCiI5Xdw0CqLhG9NMpubKE=; b=KICAI0kfoi/K+f726E1NcX4nZQLi3OONZSnnsZ3wGOIbmgRH8eM9F9LGOyvHAJy3j2 rN6TcOueXAqaL1KjHukS+YOP7dr0g04iEmHrumcFcvgIakJnSstUi4+xY94S/iAjEnCj fAw5QtWDLLhklYaC8OqsNLZfP9lmL1ENahAbNfg4ihCTQw++dsIWRKyHEO0gJFPzmVFP IFg0dmJpKE2DBeF5O5SjjsZbkt1iYbjLwFTPuYUXlqLIvWzfAljQX2qKSL9+9x1I1cBv zhglnmVNXxb1bqOiwIfUh8pd3XyAgB5sCmAZH1od00XLlOsl59WrWqI9E0LpjW6PnYbi mcjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764709073; x=1765313873; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WCFY6ttRSuGdVF/JBzuDEsCiI5Xdw0CqLhG9NMpubKE=; b=PncFabqnpNOeWG2c4KripGpNPd35of5MgVpfu/xtFgYdcYbnMMBigTmVhcc47oam4Z BYzwKZjD+MWxqV+XLh8CoUyUWuqKYpR23BGkgwGmYxNV+hO4Pkws+G4ALrjSwSorpSUb mLnHNzqJLM5S09YhY4jv9fi2E9Kxv3blxLzCoTfEb1g7cfj0UVaoaltbrZJLVz24hnYV R1HNKDOR7azAWHSj5jieQ59iiP7+lFdo2wXn/KLZefcUHPxEkMTkY9sQYewjv1rA5DqE gqi/inLYibpyam4hAtE5HkbzI9yiwS25+HY759dgr+ZUYctGFtsrUVGWwFsKDKshuNDa byng== X-Forwarded-Encrypted: i=1; AJvYcCXj+J605anlkpwb+7Y+bePpmoPqY80M6fJJ7Z015XdrkZOIPqhdh9KhOEexWglGbDQaxcwigrODd+xN49E=@vger.kernel.org X-Gm-Message-State: AOJu0YzuazgysUp93mhznKJlOYsoZ/QbxMP4gtIvcChVQZNxde2XCWBy AIQBMN+i6HbELy/KxpzEwI9LP5JvI1hTKu48PwoM7KQatj5mTjc5hgqU8tPcMHtvG9ELnzkBPhf z3dv8S4T95KTt2LxUBVnFN4NA0YqyMazpylKScE736CN9pmydBiTV X-Gm-Gg: ASbGnctKPZVNDswmVpDXi/dKplfbftxtIfvz4tK7KVxBcjstTkjMwW2vR2gYaOrf6ow Wnq9kigyTDXy79fhbLdR437wNshSHW5yssnUx5o0kwSwKONttly2FPMdPdxlwC1d6ZCFMT+cpos O6YkAOigelLGXT46T7vPAVEOuwUzKgxxMqDgANw0UFceQmGVXPOEVQzMMuXbq24u/R/uR/9AdhV d3dQJ2MYlZ7IbAb80B3rvh6I6BfqM/i7T6MK96rjCS+fQ5j5tw8Du2fVLtfEAv7U9U4UJObEePo yhL2WSeYUVEOcUXXOKhKjxukMWbyMFuDzIcgWnd3TL8YFcPbGvkssltMoWhsjVdaT8J2FT7qaj0 aNjj+zGkKT5n+pAAs2hVopB5Wxxc= X-Google-Smtp-Source: AGHT+IGxthmxn51MtajamGGrOy6wmhrHdngQ16dAA5HyliKSnwYsh2b9iAmV7GSW2/6+01Fcd/I9//wd9zgC X-Received: by 2002:a17:902:fc4f:b0:298:371:94f1 with SMTP id d9443c01a7336-29b6ff7b956mr275657085ad.1.1764709073003; Tue, 02 Dec 2025 12:57:53 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([2620:125:9017:12:36:3:5:0]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-29bce453e6fsm22538065ad.23.2025.12.02.12.57.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Dec 2025 12:57:52 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (unknown [IPv6:2620:125:9007:640:ffff::1199]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 3F5233400C8; Tue, 2 Dec 2025 13:57:52 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 46AF0E41C86; Tue, 2 Dec 2025 13:57:52 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: Uday Shankar , Caleb Sander Mateos , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] io_uring/io-wq: always retry worker create on ERESTART* Date: Tue, 2 Dec 2025 13:57:44 -0700 Message-ID: <20251202205745.3709469-1-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If a task has a pending signal when create_io_thread() is called, copy_process() will return -ERESTARTNOINTR. io_should_retry_thread() will request a retry of create_io_thread() up to WORKER_INIT_LIMIT =3D 3 times. If all retries fail, the io_uring request will fail with ECANCELED. Commit 3918315c5dc ("io-wq: backoff when retrying worker creation") added a linear backoff to allow the thread to handle its signal before the retry. However, a thread receiving frequent signals may get unlucky and have a signal pending at every retry. Since the userspace task doesn't control when it receives signals, there's no easy way for it to prevent the create_io_thread() failure due to pending signals. The task may also lack the information necessary to regenerate the canceled SQE. So always retry the create_io_thread() on the ERESTART* errors, analogous to what a fork() syscall would do. EAGAIN can occur due to various persistent conditions such as exceeding RLIMIT_NPROC, so respect the WORKER_INIT_LIMIT retry limit for EAGAIN errors. Signed-off-by: Caleb Sander Mateos --- io_uring/io-wq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/io_uring/io-wq.c b/io_uring/io-wq.c index 1d03b2fc4b25..cd13d8aac3d2 100644 --- a/io_uring/io-wq.c +++ b/io_uring/io-wq.c @@ -803,15 +803,16 @@ static inline bool io_should_retry_thread(struct io_w= orker *worker, long err) * Prevent perpetual task_work retry, if the task (or its group) is * exiting. */ if (fatal_signal_pending(current)) return false; - if (worker->init_retries++ >=3D WORKER_INIT_LIMIT) - return false; =20 + worker->init_retries++; switch (err) { case -EAGAIN: + return worker->init_retries <=3D WORKER_INIT_LIMIT; + /* Analogous to a fork() syscall, always retry on a restartable error */ case -ERESTARTSYS: case -ERESTARTNOINTR: case -ERESTARTNOHAND: return true; default: --=20 2.45.2