From nobody Tue Dec 16 22:14:31 2025 Received: from mail-vs1-f100.google.com (mail-vs1-f100.google.com [209.85.217.100]) (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 325F02F25F2 for ; Mon, 15 Dec 2025 20:10:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.100 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765829431; cv=none; b=ccENy3c9yS0z6g442lyQfGVD2qitSDrZaVQQ5pc+RZWkjHT0FEPJzIA31DA5twPdbVu+f8pbOV6Dq60SDQUVuNd4gmm+xU11iKCynkwG3oYtaI09x7HyRC9nTh7p182hAC8GZU/oBu3WSPSzaC3hLlNSM61j2wJMypfIpOBJWx0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765829431; c=relaxed/simple; bh=L5Uqu9+rr+DwT6pdOZXAwcq9nYIz91fuoF+OXKgDo4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kgeezkcrhjBBBWh86y18C4LpBgHxrXKZxP94+1mTNGdP7oPqoolZnGQ/mOwgnifkVQLdpO/LBa4wXZJ0PEQnJTIYdzRn36sDAwKuyiIBBJuJAbucMKEHO0qRHAC3OmiSaomNppT5VkdeTMTZqv8XK1Q5VB6z+wRZj+JwLJZ7wlg= 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=D2R8823k; arc=none smtp.client-ip=209.85.217.100 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="D2R8823k" Received: by mail-vs1-f100.google.com with SMTP id ada2fe7eead31-5dfac1bac03so200078137.2 for ; Mon, 15 Dec 2025 12:10:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1765829428; x=1766434228; 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=8/b4bbf5Fpl1ur/4rCqqMbk9Yx0Nl8rzYgHyXMsZmA8=; b=D2R8823kiebbKgRlkM8K0puk0F56/RwS/dl3FTRxXrIKVIHUIdC5ND/uoVQPjhR0nb nH97znrM8QWQbUBSYy06IWvhQWCyLfD+3qGtFNaV4NZGriB7GwK8r7/lnzy+f46s+rTx FgF9yICYWblpvyEaSCDEhGwaFLZ64C22HjGSLeurvZMw/PVJai9m+EOhboaXodkiqscu zx5bqKZ0A2qZGrLzwQ5R0G8wmbGCaswBhSTBl9TBhXC7I8hEkOdm3LCrTu3SO4Hxiu0g 07e0O6IOarAyOQVOBzAJb6KgNa5qRuohxew32yoOHAzwjUiY/6muCxdVMHweipjUqN1Q KY2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765829428; x=1766434228; 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=8/b4bbf5Fpl1ur/4rCqqMbk9Yx0Nl8rzYgHyXMsZmA8=; b=Tdh0+QDlkMtCSHznJ6IOS1v8B28N3QSYbvpDWQZLE6HP2iUXYDR2kNo/MBuJDlL6nQ Pq2hEgsuNlVyRo2lTgdV4qUdp8XRPiPYI7PmZkJEjE2V6tg4VzAYF0OvWyH2vy71ihBe u6Yt58w1oqM8s2ZlNEEhAEyMyNucVX6KFqPxVJZKNT5sMHIEWAhFC3H3zpnS9plJC+UY FiXXWmZuEYf/L4+wxtwCIi0t4biqG96hcr+wQW9rhmIfuKQao5WBwR4LbJaee380E1mC N1bH09PQW6LJP9B/dR3MU0/GienYCRud9CgWKg+RWW60YcL+KDBJzL27LvcgiWTAEFJb jg5Q== X-Forwarded-Encrypted: i=1; AJvYcCWQk2NuD/Q733FBWjLjLyifYkB98duh0qCPYNiFmSjPx9GgVaex7v5vbNf26Q1ngoHEZJPYVUklDw9Guy0=@vger.kernel.org X-Gm-Message-State: AOJu0Yws8RlDShRzebtxV5rmivKzZBJ0sS5DjHvpdlVBZZ3eYI8Xeq5f cLtYIyZf20273N5htJQDWTrKiDQjDPH2Av286LEpDEso7mYVNhCkBvE7ewXu/hKNlSYaHR7gH49 QcWyKHrubvrFj14cJV2KEvgSZKrCrUmW4SFKY X-Gm-Gg: AY/fxX4BLDi2HpuxFR7guT3lGydjYMAgH3QRiY5G2BXWoweHtcfEOshLJ08naTnTNz4 QdfQ4s3kDZ5N+klUlEJ/yE4g/uJK4IdQyKaE6WHS6qxUPdwNxmKecp0AC5NXdUX7FzKYYxe8jY+ AFjL58fGz+qpB2tBVPinxgvO/92POYqSuWfl4J3e7y8CX1Rs/XWzTZR5tcY+4BvDa/GT8bj3H6d cyLFCnkLmNen0z7zZo8kl27mJWLP1qlfdDJpe5jfXLLko6LYsdY2Swacdr6n3/Cxc7qFbGp04Ht gY08EX9cQ0XbUbFJgqaUvjWbCU7m8l5FrYXQ+9Z/bXSeS2GBoCwq7afBMxPPq7eD4O16LXOn/b1 f7+ltTcgisMYaXQykujxS5xvlMn0ojmXzyGYNYUiGpw== X-Google-Smtp-Source: AGHT+IFKo5M5Rl8K/RJA2NKxyvyaJHy8f7f3xqa4502hQs2OTK/7NEPZO40ym/Kndj/mdUSjtyBo9OgDxpGI X-Received: by 2002:a05:6102:1915:b0:5db:cc92:26f3 with SMTP id ada2fe7eead31-5e8277b9ea1mr2168153137.3.1765829427659; Mon, 15 Dec 2025 12:10:27 -0800 (PST) Received: from c7-smtp-2023.dev.purestorage.com ([208.88.159.129]) by smtp-relay.gmail.com with ESMTPS id ada2fe7eead31-5e81e5a1d6bsm1924476137.1.2025.12.15.12.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 12:10:27 -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 9DBEF34076B; Mon, 15 Dec 2025 13:10:26 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 9BAC1E41D23; Mon, 15 Dec 2025 13:10:26 -0700 (MST) From: Caleb Sander Mateos To: Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Joanne Koong , Caleb Sander Mateos Subject: [PATCH v5 2/6] io_uring: clear IORING_SETUP_SINGLE_ISSUER for IORING_SETUP_SQPOLL Date: Mon, 15 Dec 2025 13:09:05 -0700 Message-ID: <20251215200909.3505001-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251215200909.3505001-1-csander@purestorage.com> References: <20251215200909.3505001-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 761b9612c5b6..44ff5756b328 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -3478,10 +3478,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 ctx 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