From nobody Tue Dec 2 00:02:44 2025 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 A36262F25FE for ; Tue, 25 Nov 2025 23:39:41 +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=1764113983; cv=none; b=gkpP/cZSxdXHA6Qg4sMl39A/oM/3z61Aa++BQ7ewI3l6BVz7+60oF9GZiiIPYQP7F1rSkbUbLw2R/GNxdpiPk359P+INoHrOt3o2UmAwTCqeZkdL+Z6P+LIgoCeqRZ/8d+C+mxDlNpFUj3HBMBPbt9FcWHFCVJIwGyYthf2D4SQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764113983; c=relaxed/simple; bh=oPe4d1Dt/kF8ouGFjdvfRNnkBvKL4QPie4rpDGptmqs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Od7eZnYCVDyWlymV0IxAvT0hPUrx1HUnBuMUYK1F4w2aQFTDZLB5nb2YovJPKr9LFQoJbJEL9ue4MxLPICfOTMhvOFj4Qfyn4FwTGUc7o2xoMyoQWF8VxYNfOkbsjwyXrRGODtNAY+YCS5IU+WMqfiINn6ZdalVarpc4440gt3w= 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=HPoyD+Gj; 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="HPoyD+Gj" Received: by mail-pl1-f227.google.com with SMTP id d9443c01a7336-297ea936b39so11386955ad.1 for ; Tue, 25 Nov 2025 15:39:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1764113981; x=1764718781; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oVcZ1kjlWKJeBcL9Jbm6axJm3ukOLpidER5l9zdbGNM=; b=HPoyD+Gj9Wx3+XeE+UvYoDA3BuWm7JFY6qqpMQEOfyzcfRanKgXpzDa5ShQHQJr8eP vB8KpwWkvkA6M1eAJmoS7plC9o5xsVPFCIPILa+gpHvBI7seeIvRNIGONupu5/Y3nhEw WuPhlQtIOBIWA7CI4HtThy7BTF+8jtSMwC0/b/3VGTdfH6O72FMZPZbMpT95Z0YmDlmR jQlYjJpPfnv6+Bx5EiQZxxFs8Ez7agMlBOHLgdiLcBeP7qVqjS4eykUT0b4RJFwrPvD9 F136HTMrj8Wxtv490i+9OXiS4mpjfpMC0hskaQco1EEJnvprHMXOj9VVO4NFU+n17jEf yKnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764113981; x=1764718781; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oVcZ1kjlWKJeBcL9Jbm6axJm3ukOLpidER5l9zdbGNM=; b=uEOtrglowiuHEDYVWrCVGJNlfKrttRKcW43TUiHvxlfFLgHB1C1NXVsmK7a2US7YBW FLfa5DXEMs57qU+ZgP5uAd17WHpT1u3A237RVNaP9074M7+6uqJJ/7VdNS71So0MlePB fu/sIZYNQhzYEMvKjX/UMKtIlcaffTQyU22/GEGxe+inf3xeVZX21mUAhE5LYn041zyC kiBX4FnKvd/svAZW+jsOGoLOurWFnbeoDHXXtsMkV+clIoTNyN8CsvDQD/4G6N3q6AxD Qo3/fjNo049aqfsUVd+Ga1EBr68q6VcLBorFyXne+6ZEzpMAM5uMNe8ZK4G02ulvnEVR C93w== X-Forwarded-Encrypted: i=1; AJvYcCUe6xHhkqD0o+uxkQJ5S4tCN3lCU5wKWda8Qc12rUwx7OcoZxAWtnZp3JMqA/OyWLS3iv9UuzHfHPM9wcY=@vger.kernel.org X-Gm-Message-State: AOJu0Yy7kVvRo+ObUpBaiX/NLpXjikm514NoO3noN+PNDYbQmbRGhAf4 JRXNZNxCwrPyUqJKjftnYnm7a9N8gUpILA53VzdRqSSUGqutrcJt5G3lYZoz2Q2VRmwKBw0GOyD 0l/T4lLd26PvFiqRdRRhtkQJG194r5TfX47bL X-Gm-Gg: ASbGncs8eSIWRQsva0n7awBH2aM2iLo98JN6NlTLD9NRuQQhQUf2kh27MK8NoGtXP6Z wSokAMm531FuVQZHAMmjJ6r5H6kxxuy9ZCTdRpTpShTseAWsmEIpjQs7KIg08LVmblcI7GDpRKn VR16XXNj+P0TZPAqkp1z1vKQ2d9cBLdocuZqBPGEnZ3ckPIcdmBbks/G2YLxOI+Dm3qwQdxt4/X UtkFnTo5CTGWCt2XdGUfjkByVSTacdRLBFmOA3RrqKRBbI+lN4pvOHaUk4q4g6i3ooOL+mL1ek9 BbtYz13PDJeN1Q+LYJIV/93f8fsYxwl8WQqTbu6fyqiz5mlvEb2Uu5VAXv3stbhoBOVc6mh5hUi //8dVetkmOnbvZksgNagK2ncKO8cPZbpVL+r7u0a+ig== X-Google-Smtp-Source: AGHT+IHC6KWWpHlL/oKY1CixtwVh6OZTqTPIxixKTx2gsuf5v2kwMO7SEEwbn2xVUTsk5aIP+iAbsXidd/38 X-Received: by 2002:a17:903:388d:b0:299:db45:c5a9 with SMTP id d9443c01a7336-29b702764c5mr95171425ad.9.1764113980973; Tue, 25 Nov 2025 15:39:40 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.128]) by smtp-relay.gmail.com with ESMTPS id d9443c01a7336-29b5b2420a7sm21392035ad.52.2025.11.25.15.39.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 15:39:40 -0800 (PST) X-Relaying-Domain: purestorage.com Received: from dev-csander.dev.purestorage.com (dev-csander.dev.purestorage.com [10.7.70.37]) by c7-smtp-2023.dev.purestorage.com (Postfix) with ESMTP id 7C3D33400B6; Tue, 25 Nov 2025 16:39:40 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 74912E41EF2; Tue, 25 Nov 2025 16:39:39 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Sander Mateos Subject: [PATCH v3 1/4] io_uring: clear IORING_SETUP_SINGLE_ISSUER for IORING_SETUP_SQPOLL Date: Tue, 25 Nov 2025 16:39:25 -0700 Message-ID: <20251125233928.3962947-2-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251125233928.3962947-1-csander@purestorage.com> References: <20251125233928.3962947-1-csander@purestorage.com> 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" IORING_SETUP_SINGLE_ISSUER doesn't currently enable any optimizations, but it will soon be used to avoid taking io_ring_ctx's uring_lock when submitting from the single issuer task. If the IORING_SETUP_SQPOLL flag is set, the SQ thread is the sole task issuing SQEs. However, other tasks may make io_uring_register() syscalls, which must be synchronized with SQE submission. So it wouldn't be safe to skip the uring_lock around the SQ thread's submission even if IORING_SETUP_SINGLE_ISSUER is set. Therefore, clear IORING_SETUP_SINGLE_ISSUER from the io_ring_ctx flags if IORING_SETUP_SQPOLL is set. Signed-off-by: Caleb Sander Mateos --- io_uring/io_uring.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 1e58fc1d5667..05a1ac457581 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3473,10 +3473,19 @@ static int io_uring_sanitise_params(struct io_uring= _params *p) */ if ((flags & (IORING_SETUP_SQE128|IORING_SETUP_SQE_MIXED)) =3D=3D (IORING_SETUP_SQE128|IORING_SETUP_SQE_MIXED)) return -EINVAL; =20 + /* + * If IORING_SETUP_SQPOLL is set, only the SQ thread issues SQEs, + * but other threads may call io_uring_register() concurrently. + * We still need uring_lock to synchronize these io_ring_ctx accesses, + * so disable the single issuer optimizations. + */ + if (flags & IORING_SETUP_SQPOLL) + p->flags &=3D ~IORING_SETUP_SINGLE_ISSUER; + return 0; } =20 static int io_uring_fill_params(struct io_uring_params *p) { --=20 2.45.2