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 1CF1CC3ABC9 for ; Tue, 13 May 2025 17:54:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29FA66B00EF; Tue, 13 May 2025 13:54:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 24FDF6B00FA; Tue, 13 May 2025 13:54:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0C9366B00FB; Tue, 13 May 2025 13:54:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D930B6B00EF for ; Tue, 13 May 2025 13:54:55 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E67E0C13C4 for ; Tue, 13 May 2025 17:54:55 +0000 (UTC) X-FDA: 83438635350.23.C92CA3E Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) by imf12.hostedemail.com (Postfix) with ESMTP id C727840003 for ; Tue, 13 May 2025 17:54:53 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kylehuey.com header.s=google header.b="G/PFYLO3"; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@kylehuey.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=me@kylehuey.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1747158894; a=rsa-sha256; cv=none; b=o5FeMvrcLPeO9pxL0RO0bkJRtOMZIbXk92zQrwNrOl/yLsFyPfMV8Vte7faAMVD0lku+mS xbmRMPONYfM4IU+cOMOYcGxAxdOIF2ZbHVGCoitGaRnldFTaoIPjRlk3uL3Os5BojnBSQM IPBk+qKL1obzEBQ8SwNkSNH8pZhJig0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kylehuey.com header.s=google header.b="G/PFYLO3"; dmarc=none; spf=pass (imf12.hostedemail.com: domain of me@kylehuey.com designates 209.85.167.49 as permitted sender) smtp.mailfrom=me@kylehuey.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1747158894; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fEkbbjc8SgdWndktwHsp8qvmd1XKdC5xi77nBDSspCk=; b=BYTkN96gc5XXKhHUUwwlylqjdgOcE/yl6eMwd3bEHR/JJysJXI4Pt+YjkLau4Li4teBRsW X027Ia+2eLu2imEmVfn8fgvZBlRJPhKFkdeY+B6t735Emy0UCyILz1yboVMesnPVgPUL3I vrJxw9HeAOkj7ORajYQDUK/AOk3rueg= Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-54afb5fcebaso7696214e87.3 for ; Tue, 13 May 2025 10:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kylehuey.com; s=google; t=1747158892; x=1747763692; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=fEkbbjc8SgdWndktwHsp8qvmd1XKdC5xi77nBDSspCk=; b=G/PFYLO3k/7Z+oqAGuGP95Ks59eoen0mXdQr0s3rQHTY1nbxJpV70WCwkvY7XrfAnu 6ZNBaVmlkr5m56MhGBV6kGSDBcbe/zUO+qdBU3rYUOkp2UF8FnZPoIsk+qpHKiCbbmh5 CLOV1k2yCwvF/2TGeiZjSsJYuSnnUp5M3f1AeAEN2Jh/eu4BL3yH3bJVKM+mOXqNCB7X M6fQAmcnCHTxp7nrnh6MfP1D6VJl08s7UCOuLyI05r1otAocRCPWc/KLrMytRDQ8fRMt 2/Zdv/I3AVHbMSaVMAlkmjlVhBZa8acSuHmMFRIQ0mjDAEpjsBPqcGWZZ1nWIcrDFenY TjTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747158892; x=1747763692; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fEkbbjc8SgdWndktwHsp8qvmd1XKdC5xi77nBDSspCk=; b=k2al6W3JorLAm5S59ytbX1yyx2YynFBt6MqCB9qJctv/b7uK3afspF1M0CgryMrJgx 6h/sUzTQVrhvBNeuowDJMesZespIOiqb/EYdgOq0UylYJ9v8uLXW0EiBb44PL5tQu759 CTFVQo1cybjQuFFnj1Ad1ECAYZhzdXxVsa/I5vDACChx4e0p+uYtuRcbAW5pdHpdk7l5 i6ZZqWE3oSvC2bexnFuapEyGsjnVnwfd0TExnrdGr4TR3WIIISlq6Z5gL89J4l2dhpbD VfrKyAfFWxuqgCda16wZtSoY4hdb+kbztur39HA0Q0tYI2v2rQ8wmVM3fMmPU3q4jvDr QLlQ== X-Forwarded-Encrypted: i=1; AJvYcCVCEDXce1r3h/y09Y0khlE1Xy37nkz2MXtuukkGRhQL5WchN447ouv6xnp90rNgzHbhOodJrMHhuw==@kvack.org X-Gm-Message-State: AOJu0Yzg0OdWQg8184x+KboZ0ESXIoFxQtq9ZqmFhdIPl+xc/rZyCbGU Qjq7YkFfPb9vFblf+hc3t02rkP2kp1qjL/lxtLIoHV2EowcpXIskV87JOTk0xAV98vWBJ+WTLm4 JvsA4l+p9o7pBQnQtZNOGtsS8Clo5VKpiW2Z4 X-Gm-Gg: ASbGnct0ay7wlzrma2S53LQRGEOpuoEPDtqZceJ6ZJMKlgWbJ6rfwofZoOE1bX92XpY 0vTknV+075Ec2vcX3N08QVDHwX+ohzk+kgdlWQcy4GIdJv2C+0RJs1cleOrjHTkhdLOD3p8HxYD iJlyLz4PUbfIzNxztOQYlr//q6Q24lIffDsdHIMAJ80F4= X-Google-Smtp-Source: AGHT+IEdqK+uTg3aHvnbNkaG9RlhSEYZqBiUwcBgzQU1q3K8m+RX0GeIMjK97H9IUDcFFqxAb7dhp9Ubi7rz5ZLPNHc= X-Received: by 2002:a05:651c:2227:b0:30d:b366:d259 with SMTP id 38308e7fff4ca-327ed0d966fmr541821fa.10.1747158891597; Tue, 13 May 2025 10:54:51 -0700 (PDT) MIME-Version: 1.0 References: <20250512171922.356408-1-peterx@redhat.com> <20250512171922.356408-2-peterx@redhat.com> In-Reply-To: <20250512171922.356408-2-peterx@redhat.com> From: Kyle Huey Date: Tue, 13 May 2025 10:54:39 -0700 X-Gm-Features: AX0GCFu0GiXP77j7Ocw_EEYHdj6M7fuJmdwT_meIB0dk-dffw8oy1ZpyJcbP0xo Message-ID: Subject: Re: [PATCH 1/2] UFFDIO_API.2const: Update userfaultfd handshake and feature probe To: Peter Xu Cc: Alejandro Colomar , linux-man@vger.kernel.org, linux-kernel@vger.kernel.org, Andrea Arcangeli , Mike Rapoport , Axel Rasmussen , linux-mm@kvack.org, "Robert O'Callahan" , Suren Baghdasaryan Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspam-User: X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C727840003 X-Stat-Signature: a18fi5cq4g6ryptc1h5k71ioeqb1yiqo X-HE-Tag: 1747158893-809604 X-HE-Meta: U2FsdGVkX19jkOFOuQo0zB6K7csraxtd44ifUYbXQfhNIyMHFiuFx5zLs07nPfZYjFqkZRSobzjuAP/XxAaz2QZ4ZmcoomwYZ9qT9zIEvY34OFFaRC8PyUXV/974rl/I3Td877mYOGtCdsCazYVpfT0mdelPiEb11YcO82fNe9jGk3ywX1FW3yc8s4VPDpPYuSRZ0ztUH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MDfJncWqR24IZSagm6JnOmh2REhGag== 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: On Mon, May 12, 2025 at 10:19=E2=80=AFAM 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. > > 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. > > Signed-off-by: Peter Xu > --- > man/man2const/UFFDIO_API.2const | 43 ++++++++++++++++++--------------- > 1 file changed, 24 insertions(+), 19 deletions(-) > > diff --git a/man/man2const/UFFDIO_API.2const b/man/man2const/UFFDIO_API.2= const > index 54b34a1bc..1c554107a 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,30 @@ 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 0. 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 > -- > 2.49.0 > lgtm Reviewed-by: Kyle Huey Thanks, - Kyle