From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC433C3ABD8 for ; Sun, 18 May 2025 08:18:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A07516B0082; Sun, 18 May 2025 04:18:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 990B76B0083; Sun, 18 May 2025 04:18:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 830846B0085; Sun, 18 May 2025 04:18:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 63C106B0082 for ; Sun, 18 May 2025 04:18:38 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 0945180A5C for ; Sun, 18 May 2025 08:18:40 +0000 (UTC) X-FDA: 83455327200.20.26A69C6 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf22.hostedemail.com (Postfix) with ESMTP id 55963C0005 for ; Sun, 18 May 2025 08:18:38 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="p/LUc3cL"; spf=pass (imf22.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747556318; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7qjkD5zPKKbZxjcH5w1N+dJYdXdTUYJZf8rCb4SsyGs=; b=OaEu+hxzgk+AO6GSpz685hd9CQCYTN81lL1WSYzLPRWAPyvB3Lf4kxL/kUb/+FDDDSTFh9 s6WqW5tfku0ucguQMj71SaVE/MmQfizqPtyWM9B1EsbrFnb3UrQ1gz0nWGquPvm17sudpQ svoBgvgsw4nu5R2SoTjTqhWwVmjNw7U= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="p/LUc3cL"; spf=pass (imf22.hostedemail.com: domain of alx@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=alx@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747556318; a=rsa-sha256; cv=none; b=q3rYP/FiDJhi+Sc3cTJaKMmy2Os4LhPR9BNeFY5KTwo+ClmE1y6GI0AY0U0KsBKrZ9dyEO OBYh9hWicEcAup+e2/xQBxoNQ5CBqipXYkma52clPtj6VI6j3Uf+An36uEBnm6UJ9opMqG NWfGkPxRuFQr8W9soj9BYZHqVm54cSM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1EF685C12B1; Sun, 18 May 2025 08:16:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A3A55C4CEE7; Sun, 18 May 2025 08:18:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747556317; bh=WkoJYO/kFuyzqd6xD5zIc+bpw0cwLLyFN4qGKlHP+e8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=p/LUc3cLQw3EIgqhxABjRQUVhhMLyyqxRDS4gbsqOHXIQ4h48irKl58DBTby7F04p /3T82l8HA3Lr949j2xQOZ8s18UKmgmvpLHRUO8jBAcnvgf2CvfmHsxUCzT35hGWDJq Z+Td2K3GeDmFNY+zCh+2U4SFM1txrLv+koaMz3QI3rHrn8rJ65+3ThSdsCagZXpoS+ 4KJa00HG1O0pvlIMtTPvtO18UW/yxq7FrqiLdqC36AC6PBIJ7xm2fGI8dDeSOld6tR nUPFMbmIXBsTeQXLbJTCVYhfTp5M4G83hWI0+ZTOc8ZNeENHYEA6eC66E58R51EFMr IDdbVihMdn31A== Date: Sun, 18 May 2025 10:18:30 +0200 From: Alejandro Colomar To: Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Kyle Huey , Robert O'Callahan , Mike Rapoport , Suren Baghdasaryan , Axel Rasmussen , Kyle Huey Subject: Re: [PATCH v2 1/2] UFFDIO_API.2const: Update userfaultfd handshake and feature probe Message-ID: References: <20250514172630.569788-1-peterx@redhat.com> <20250514172630.569788-2-peterx@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="4cxxifislilvffi3" Content-Disposition: inline In-Reply-To: <20250514172630.569788-2-peterx@redhat.com> X-Rspamd-Queue-Id: 55963C0005 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 9zismed8f9mts5mdzj6pwwq4r7con7yy X-HE-Tag: 1747556318-89808 X-HE-Meta: U2FsdGVkX18w389W0jf87yIAgYpmmE7qvuFa/xVvxgpK/pAp0y/2SFHY9Ypw1ElMN2cq8YliMtwQ9+QVxxk8BhpBjZkdZExchER0ON8YFLd6H8W3MVb26yMlvNvmC3SijgjIRiDc1W587GixhkywoGevQFUAkTsgTcJV7lxfReR6wsN1ZWa6QZQXOiMsv4gYE589LLxZUcP5O3ZyE0cZGalwk3b0AD4aONvJC8Sm4ogYx7PmIh89EI5MsOPxzQd3cKyhlnHHsYVhBVdHkRCilIVP6yg0xDrLfWnECSuUYsN+dVxLl94mvJeh/gUdksQ6hU/03h3olMeTaSVDUi8D2AzINej4CPNAIfD3vRY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DjXQc6X1663ovlp5KyA7Zcq6LJuyiOAtfjj46RHuRw49Jae64MUhourlErfcQ9qIsS66onvVoO8vR9gN7BMnleh X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: --4cxxifislilvffi3 Content-Type: text/plain; protected-headers=v1; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable From: Alejandro Colomar To: Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Kyle Huey , Robert O'Callahan , Mike Rapoport , Suren Baghdasaryan , Axel Rasmussen , Kyle Huey Subject: Re: [PATCH v2 1/2] UFFDIO_API.2const: Update userfaultfd handshake and feature probe References: <20250514172630.569788-1-peterx@redhat.com> <20250514172630.569788-2-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: <20250514172630.569788-2-peterx@redhat.com> Hi Peter, On Wed, May 14, 2025 at 01:26:29PM -0400, Peter Xu wrote: > There's a confusing paragraph in the man page on two-steps handshake for > userfaultfd UFFDIO_API ioctl. In reality, after a successful UFFDIO_API > ioctl, the userfaultfd will be locked up on the features and any further > UFFDIO_API on top of an initialized userfaultfd would fail. >=20 > Modify the UFFDIO_API(2const) man page to reflect the reality. Instead, > add a paragraph explaining the right way to probe userfaultfd features. > Add that only after the "Before Linux 4.11" paragraph, as the old kernel > doesn't support any feature anyway. >=20 > Fixes: a252b3345 ("ioctl_userfaultfd.2: Describe two-step feature handsha= ke") > Reviewed-by: Kyle Huey > Signed-off-by: Peter Xu Thanks! I've applied the patch. Have a lovely day! Alex > --- > man/man2const/UFFDIO_API.2const | 44 +++++++++++++++++++-------------- > 1 file changed, 25 insertions(+), 19 deletions(-) >=20 > diff --git a/man/man2const/UFFDIO_API.2const b/man/man2const/UFFDIO_API.2= const > index 54b34a1bc..aca27dc5c 100644 > --- a/man/man2const/UFFDIO_API.2const > +++ b/man/man2const/UFFDIO_API.2const > @@ -42,25 +42,6 @@ fields to bit masks representing all the available fea= tures and the generic > .BR ioctl (2) > operations available. > .P > -Since Linux 4.11, > -applications should use the > -.I features > -field to perform a two-step handshake. > -First, > -.B UFFDIO_API > -is called with the > -.I features > -field set to zero. > -The kernel responds by setting all supported feature bits. > -.P > -Applications which do not require any specific features > -can begin using the userfaultfd immediately. > -Applications which do need specific features > -should call > -.B UFFDIO_API > -again with a subset of the reported feature bits set > -to enable those features. > -.P > Before Linux 4.11, the > .I features > field must be initialized to zero before the call to > @@ -70,6 +51,31 @@ and zero (i.e., no feature bits) is placed in the > field by the kernel upon return from > .BR ioctl (2). > .P > +Since Linux 4.11, > +userfaultfd supports features that need to be enabled explicitly. > +To enable any of the features, > +one needs to set the corresponding feature bits in > +.I features > +when issuing the > +.B UFFDIO_API > +ioctl. > +.P > +For historical reasons, > +a temporary userfaultfd is needed to probe > +what userfaultfd features the kernel supports. > +The application needs to create a temporary userfaultfd, > +issue an > +.B UFFDIO_API > +ioctl with > +.I features > +set to zero. > +After the > +.B UFFDIO_API > +ioctl returns successfully, > +.I features > +should contain all the userfaultfd features that the kernel supports. > +The temporary userfaultfd can be safely closed after the probe. > +.P > If the application sets unsupported feature bits, > the kernel will zero out the returned > .I uffdio_api > --=20 > 2.49.0 >=20 --=20 --4cxxifislilvffi3 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmgpl9YACgkQ64mZXMKQ wqnk3Q//eDnIHs2yAZNv31E7QcNanklA5vLux0jF7JUBOBjuQQQzvRmk9H3zxSzj VvTnecJleTpNXvDvq29wjvFPKFbMnI0siYL35nMMLIicU1Z4ilQrAIr/yQ5NiT25 6SMMOAnwRAiGsF7QQqE6Nv6IqTP8hBoSeXtpEZLF4A7dJkJm8UWfrA+HQjnurZgb 8TyuiBa0taT39qmM38QICFHtEWJDHAt/+lFsVDDuzjZLw9t8MEa0mZfVvni186eJ bCNQT/Z5GbDgEoYIhB4OMq4WTuHQtkq2P1lrxUMjuHoAPJS9HrsC1LnitZkUpLZ5 Vkhb3BWhRjLPhp1Nbdu7ORZr1/ssqqPNG8A6AqWE50DOQcvWDV+ifabAHN8Yi/6L VsJuh3ztErgI6VLNm4/5vWUAvBOD+7EXc82lp8F66POQxvQVamChFXnMLELzGloG o0Zv43ANjek6f1C0yolfGieClX677lR4mDdKzEgOHO1RNT4QwsglFD9puZHvfg8q oSJeh3MFpg/xkH/JfoKlJnmMnhnAILtiP6jkp8JvgbMcGH3bvPYPKuG74pmM2koQ ktBMUVL09UK/3aHdHLxF7ps9pldwXm+czHpbSlLC8ht7TOUhKQd0ahu5JkfZG71G GVpVyB39VHQVWehAJRgD7NbTLAOwKAfmG9C25IJbRiNXXrnhqxk= =pFCu -----END PGP SIGNATURE----- --4cxxifislilvffi3--