From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from fout-b1-smtp.messagingengine.com (fout-b1-smtp.messagingengine.com [202.12.124.144]) (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 4116325F7A5; Tue, 3 Feb 2026 18:52:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.12.124.144 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770144767; cv=none; b=fliANMaZ+tb3xv3uEqjZTu1ubNPDd7q0btyLewOaUb/c6rQ9nX2y8GWogKWMi9HjNIrTzB7ebXE5Wqr2oicHM6uybbhe44805El2SqwwKc1lm2WtQFHLGECQQ9b6PIviyn8JNg1LbJ0aNET8rWa3F+b6YK96SlHqSykKhGBsqT8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770144767; c=relaxed/simple; bh=zVPiAP3T4UGtkVXMkDdmCpTW/YCWk/ixyuzXCi0/mYs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CcSRRs+h0EQiYbcCM+BzAPmli4A0OPFFRJPm0ls2l+YF+zzsy71S10s1BAv7PPgtdj9nBfJXgfzv6B5WMzvBgdzShodXuO+U5jdoFTdbaeIwQxX3QdWhViPWFdhwGrwhyVC47a2pVXOKey/UF1ygWwNDn9uyaFeQBDQ/85K6iUw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bsbernd.com; spf=pass smtp.mailfrom=bsbernd.com; dkim=pass (2048-bit key) header.d=bsbernd.com header.i=@bsbernd.com header.b=DK0E53PD; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=durFDXvj; arc=none smtp.client-ip=202.12.124.144 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bsbernd.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bsbernd.com header.i=@bsbernd.com header.b="DK0E53PD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="durFDXvj" Received: from phl-compute-08.internal (phl-compute-08.internal [10.202.2.48]) by mailfout.stl.internal (Postfix) with ESMTP id 42C321D0010D; Tue, 3 Feb 2026 13:52:45 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-08.internal (MEProxy); Tue, 03 Feb 2026 13:52:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsbernd.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1770144765; x=1770231165; bh=PuuqUzrOW0ejy4N/6rH49JuxAIizRsFiW6QWrTJ6jjA=; b= DK0E53PDtjlF8yGTfIO1eZj0aTZuTi0aG/mu0JqwIJYCtvZC2/7DjdASgOQVPYUL vPmcoM80Uxp4r34Wl9Ytd3bMHsb+x1LaaViaMt8qIYa8cIpMACQ4vgvZa5ViIl+F qwD26FibxnVvdGcswP+mLvsUqQh6uHwUkjswjYo8yHL7q646O0FHAMjXzA/lBdet VZCoR6v37PKU10vAtIHw8O3RuXmgjIjbo2KvxmJApu+GmfAdhofoZhJNPMOcfMPL x/J2ciFv3wO5+GVublkC5/3/gFcRsRXijNsSMc3GVoM/bLKIpEQZId36v5FGZtoN 0vnXUsF3rV68dnzSEGsK6g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1770144765; x= 1770231165; bh=PuuqUzrOW0ejy4N/6rH49JuxAIizRsFiW6QWrTJ6jjA=; b=d urFDXvjhV49UPOdqm0a1WIV7veZxQ1vIgFgBazT5uX3z0nSCKsOuWQgEhtwPgNH2 dUn37od4WSywCINDtw8A03B22acYmp3NWrtH8rt5ydbNtXGeQ1/Ok55GCHzR3ItY PSaEOiNff7NxpxFol9d1dx74UjcXNqdWAdxf7pCRskNgtTTSfiOOI/e/3hV06EO5 wACARrnoA/gxrhsoREHKiql8NTzj7aJKGMmh3960ngv2Kr6II5dGgzMJm1cLPQWM 0XG4rFh5h+dScaJI7R/nxQxvjYEzrrj1guPI5c672lvQWv64EJHUULo7l5xGGKvQ PGPJfkxMQdw+ULIxC5vBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddukedtkeduucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtvdejnecuhfhrohhmpeeuvghrnhgu ucfutghhuhgsvghrthcuoegsvghrnhgusegsshgsvghrnhgurdgtohhmqeenucggtffrrg htthgvrhhnpeehhfejueejleehtdehteefvdfgtdelffeuudejhfehgedufedvhfehueev udeugeenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe gsvghrnhgusegsshgsvghrnhgurdgtohhmpdhnsggprhgtphhtthhopeduuddpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtohepjhhorghnnhgvlhhkohhonhhgsehgmhgrihhlrd gtohhmpdhrtghpthhtoheprgigsghovgeskhgvrhhnvghlrdgukhdprhgtphhtthhopehm ihhklhhoshesshiivghrvgguihdrhhhupdhrtghpthhtohepsghstghhuhgsvghrthesug gunhdrtghomhdprhgtphhtthhopegtshgrnhguvghrsehpuhhrvghsthhorhgrghgvrdgt ohhmpdhrtghpthhtohepkhhrihhsmhgrnhesshhushgvrdguvgdprhgtphhtthhopehioh dquhhrihhnghesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopegrshhmlhdr shhilhgvnhgtvgesghhmrghilhdrtghomhdprhgtphhtthhopeigihgrohgsihhnghdrlh hisehsrghmshhunhhgrdgtohhm X-ME-Proxy: Feedback-ID: i5c2e48a5:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 3 Feb 2026 13:52:43 -0500 (EST) Message-ID: <9c32bd42-b935-48fa-80f8-d610f4085025@bsbernd.com> Date: Tue, 3 Feb 2026 19:52:42 +0100 Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4 06/25] io_uring/kbuf: add buffer ring pinning/unpinning To: Joanne Koong , axboe@kernel.dk, miklos@szeredi.hu Cc: bschubert@ddn.com, csander@purestorage.com, krisman@suse.de, io-uring@vger.kernel.org, asml.silence@gmail.com, xiaobing.li@samsung.com, safinaskar@gmail.com, linux-fsdevel@vger.kernel.org References: <20260116233044.1532965-1-joannelkoong@gmail.com> <20260116233044.1532965-7-joannelkoong@gmail.com> From: Bernd Schubert Content-Language: en-US, de-DE, fr In-Reply-To: <20260116233044.1532965-7-joannelkoong@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/17/26 00:30, Joanne Koong wrote: > Add kernel APIs to pin and unpin buffer rings, preventing userspace from > unregistering a buffer ring while it is pinned by the kernel. > > This provides a mechanism for kernel subsystems to safely access buffer > ring contents while ensuring the buffer ring remains valid. A pinned > buffer ring cannot be unregistered until explicitly unpinned. On the > userspace side, trying to unregister a pinned buffer will return -EBUSY. > > This is a preparatory change for upcoming fuse usage of kernel-managed > buffer rings. It is necessary for fuse to pin the buffer ring because > fuse may need to select a buffer in atomic contexts, which it can only > do so by using the underlying buffer list pointer. > > Signed-off-by: Joanne Koong > --- > include/linux/io_uring/cmd.h | 17 +++++++++++++ > io_uring/kbuf.c | 48 ++++++++++++++++++++++++++++++++++++ > io_uring/kbuf.h | 5 ++++ > 3 files changed, 70 insertions(+) > > diff --git a/include/linux/io_uring/cmd.h b/include/linux/io_uring/cmd.h > index 375fd048c4cb..702b1903e6ee 100644 > --- a/include/linux/io_uring/cmd.h > +++ b/include/linux/io_uring/cmd.h > @@ -84,6 +84,10 @@ struct io_br_sel io_uring_cmd_buffer_select(struct io_uring_cmd *ioucmd, > bool io_uring_mshot_cmd_post_cqe(struct io_uring_cmd *ioucmd, > struct io_br_sel *sel, unsigned int issue_flags); > > +int io_uring_buf_ring_pin(struct io_uring_cmd *cmd, unsigned buf_group, > + unsigned issue_flags, struct io_buffer_list **bl); > +int io_uring_buf_ring_unpin(struct io_uring_cmd *cmd, unsigned buf_group, > + unsigned issue_flags); > #else > static inline int > io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, > @@ -126,6 +130,19 @@ static inline bool io_uring_mshot_cmd_post_cqe(struct io_uring_cmd *ioucmd, > { > return true; > } > +static inline int io_uring_buf_ring_pin(struct io_uring_cmd *cmd, > + unsigned buf_group, > + unsigned issue_flags, > + struct io_buffer_list **bl) > +{ > + return -EOPNOTSUPP; > +} > +static inline int io_uring_buf_ring_unpin(struct io_uring_cmd *cmd, > + unsigned buf_group, > + unsigned issue_flags) > +{ > + return -EOPNOTSUPP; > +} > #endif > > static inline struct io_uring_cmd *io_uring_cmd_from_tw(struct io_tw_req tw_req) > diff --git a/io_uring/kbuf.c b/io_uring/kbuf.c > index d9bdb2be5f13..94ab23400721 100644 > --- a/io_uring/kbuf.c > +++ b/io_uring/kbuf.c > @@ -9,6 +9,7 @@ > #include > #include > #include > +#include > > #include > > @@ -237,6 +238,51 @@ struct io_br_sel io_buffer_select(struct io_kiocb *req, size_t *len, > return sel; > } > > +int io_uring_buf_ring_pin(struct io_uring_cmd *cmd, unsigned buf_group, > + unsigned issue_flags, struct io_buffer_list **bl) I'm just looking at the fuse part and I'm actually not sure what the "buf_group" parameter is. I guess it is a the buffer group set up by userspace? Does io-uring have some documentation like fuse has under Documentation/filesystems/fuse/? Thanks, Bernd