From nobody Fri Dec 19 06:40:20 2025 Received: from mail-pl1-f226.google.com (mail-pl1-f226.google.com [209.85.214.226]) (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 EA0A42FC024 for ; Thu, 18 Dec 2025 02:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.226 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766025906; cv=none; b=rLgjPIlYlIWnKinLeTt2rJGkMXTCDe/d+QAvCqg4/VsdPmdu0URiOsfac3TVF/Op4BiLk+8Y7NzEemJNoH1Ac/q7a4bzSOmiUT6M06vnR5rEGSOjBF/LKqYVu69HO2mHmvc1D8H6tH+eWgM1ucrIvrLce5yoEHqkjjPKsWPGUTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766025906; c=relaxed/simple; bh=L5Uqu9+rr+DwT6pdOZXAwcq9nYIz91fuoF+OXKgDo4U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QMXWAvj/yfXVwQ/DNDtnP+EL37hKju7cdURI0l188/vIWlt74JyD+CH5jkbU502wF+Y5CXER+Q3LEVvNDIKJTaoDSUzWna0NDyAxEpAIg0Z47J/GEUa8dUXLoZH/P126tuRYy5xAWFScDg7Ws57sW/TL4GnKnXMs4n0hXVKD4iw= 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=QWg/Jpch; arc=none smtp.client-ip=209.85.214.226 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="QWg/Jpch" Received: by mail-pl1-f226.google.com with SMTP id d9443c01a7336-2a110548f10so395755ad.1 for ; Wed, 17 Dec 2025 18:45:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1766025904; x=1766630704; 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=QWg/JpchEaI+A2XxnCK3RiZ1vRCZalvOa9J5DO55Fsq1OM25XT0Xhsrf7WnORjARY7 SRus9koTp4mOVaZJHL5fS+B091b+iE58ZeWyMTq6CFKjJT7aqqx+8AzQGrYtxQAyYd9S 9Zy9FQsXsN11VE5fpuoVsTVChlm6owaO5T+19PNDh9C+EcFYRbcuC+6CizPDbbs4+aeH 0KqmrqeclKkwGbMRVadJyj+0Wv3MUCJcgb2KypFkSa2DBsfiAz/EmGZHoC4pmUE0zFIg uPeZTwD8YKyd1Fm8digSCiFqACpuLMb79Il0e2xrsP/VhivlJGPnfZShaMVXnSvf3bjP NFzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766025904; x=1766630704; 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=YtQMtNZR7jJxuKowriAdx13+8iLj3T/hwWhN2RCJZWXrF23nEjvneHrCGNreYcngLA OtLYVSOu6BHzLW9V/4qaEaU62tkKARsnooYs8Ys69rNCr8I9JeQfNA8+NYvFmyylVPNE ucyf1ExumzXWb+e+/dXW3LUZTJf0ZlNB/ToZ0Ntc6FmM7Cq8MZ55+H3EteSejd93pF/+ q0Da8cXvWmuHtdIkuL2WqT3XXpVaNttlNLmhQ5dH0ctNh+MCcC0637RHHujFxxBnJT/3 z8e3iovdfSRfA8ipCrZsogrcETndEBVCydaRYMoyOcUQrqxmveFJ5AGghHm4NCBJnEVt o0Kg== X-Forwarded-Encrypted: i=1; AJvYcCX4SABlLmQcVIBMZ9PHLv9vSjGZz5wb4sSJRnZxSFM6XU/pYqcLfYEkeh+EoEjJFdBtv7y58JlSWA/oMnQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzJazggFt9V+IK+D35xD5a+t/NLhcxakkMJWeSITMMQPdrut1Lj JXf/slPrGJk1S0NDIglvKM8eDPwcCj66v41sRjixWYJpvVvKjCXPpbtlSzIZ+lh5LlrC1ky9Sna 2vOy72Vgmg7PtTcHKFLj9c4wSwpYUukEF3F4q2jSDdc4n077LO4Gj X-Gm-Gg: AY/fxX6hhBa33X6VRO7Ib/76RhboIRGTPY9yc2SpMz1hOYH8wrByGA785JXHJEqjqgN W5CDw25VlyghD3nrPR1BJ2RdxPVY3AC4JPuJhjOzTmQBmYBy453Q+mpl9AuB6vNWwvHRgZm1ncm ta4OE81BX4ooaFwteRma7wczme9RtklvGX2tC5mooDmdtQAll9Ay6gW6AogAYaS2AmfI1+We69C JeLrIbtmvlHOAO7v6gisG1b9/p3hZ5vNZ3Jwec5UdNrsrFKAEFmw0amoIWpfN7gatV3/Lq/UR+U LmPkJTlU7oXZdMa4d4GFsmNvZQ2aTKILHZb83qqoMUVfCj0JtDxfZd4eEZmmOrxy3EbsEs7ZkQc oSKZdavmAVmept6MQ/lcIrCIpgEA= X-Google-Smtp-Source: AGHT+IELQcyX0BuhAdYyweS2xiLxp/916xvfJHq29Z1LD/xwAwNxnN1c74MVP7pk5B0pAgqSxlddAfPDutJN X-Received: by 2002:a17:902:ebc9:b0:29a:56a:8b81 with SMTP id d9443c01a7336-2a2d4509762mr5916985ad.8.1766025904052; Wed, 17 Dec 2025 18:45:04 -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-2a2d08ab029sm1603095ad.24.2025.12.17.18.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Dec 2025 18:45:04 -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 764913420E0; Wed, 17 Dec 2025 19:45:03 -0700 (MST) Received: by dev-csander.dev.purestorage.com (Postfix, from userid 1557716354) id 6923CE41A13; Wed, 17 Dec 2025 19:45:02 -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 v6 2/6] io_uring: clear IORING_SETUP_SINGLE_ISSUER for IORING_SETUP_SQPOLL Date: Wed, 17 Dec 2025 19:44:55 -0700 Message-ID: <20251218024459.1083572-3-csander@purestorage.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20251218024459.1083572-1-csander@purestorage.com> References: <20251218024459.1083572-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