Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp954137rdb; Tue, 19 Sep 2023 15:51:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF7doj1PWTSYkStGgY7X/bNNiKFY/oHmFM0Zv67E1r5I74Ha08Odz36f/iaSzhhm3D3uAdL X-Received: by 2002:a17:903:1ca:b0:1c5:5c6e:ccec with SMTP id e10-20020a17090301ca00b001c55c6eccecmr1038769plh.51.1695163880054; Tue, 19 Sep 2023 15:51:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695163880; cv=none; d=google.com; s=arc-20160816; b=LdyfRky4B18O7ONQYWIMBAVzHt5EmKqB4WO6yUO6EnCzyonnkAKCIzav05sP3rG1Nk 4cDf3QoeSmDBqgWSF4gDngvSfthRRxsuriXv7WwUu5qls9WuBIa7VVSUqV4ClQb7A2In 2rZuB13oc2xxSe8264+OSSbpP7rzI0oay/Tgd1P8YMKNPpJyNP0CBk7mJlbe6UytRSPn Qac6eeifLWkyv3gL8vLSPcsa6TH3CNkXbgm7OTjcp3VtCEl/whM2L7Rj9ll7zZtnwK7I iw5olF4pJFtJkzhUvjxGj/jYAt9xv3tt8pQZsTl/GCggXlzb16caOCZRFUt/B7Zk/H0k 682Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; fh=SqwPTGdhTS3wVH9FltNQ4n/lDM1p3ApEDnroT8zra0U=; b=QOIJY1K2+sA0cbBAaMfHaMhKGsIEhJzithedU763yHVf7nvllMRG1wpLJaY6BwdE1t qORSvuXGk0vzWp+pBhINqVgT0FDOrEv4Jld6g+SbIvsMcMRNXaJLmZq9xfx1SIr6jQuA gNm7bcoqdewUn3vx8+T1PvMjLi3NBPHpiSb2AYe3j6SQEzXdYPyWGJU2MyzVESVHqfWR RXogqoPc96Qrrw9w4zncQiJyvfw8z4KhONRapZNkATF4QAlcKX2S3ZYWKvADGFrrWabn hDSoGfMnKEHFiQUiSahHpbIysqp1CSvcdHjxewsTX/iUHgXg2c5sfC2d+kY6bX6+n2pl UiOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RfuW+oLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kz12-20020a170902f9cc00b001bbd70bdffbsi10222089plb.440.2023.09.19.15.51.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 15:51:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=RfuW+oLr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 05454820C347; Tue, 19 Sep 2023 12:02:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232827AbjISTCg (ORCPT + 99 others); Tue, 19 Sep 2023 15:02:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjISTCa (ORCPT ); Tue, 19 Sep 2023 15:02:30 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3A80F2 for ; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d81841ef79bso6655032276.1 for ; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695150140; x=1695754940; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=RfuW+oLrkSfj54woc+wxQPhieeRi54xqzswro7rv/4GQgHRZ+lKMdoytyLc4q6AdXp 2kUZmrFIkj59xZQnca8mIMCq1lI7nilMkEYXAYBqk9hXVdyoA/LjLr0eChf+6RQiQrQa 0S8WpnxdazGcTJacisCSD3zv7+YJxd6qKA2X2vqUzTiA+lz15do0s04RiWrUxV84SqDD dGNGh7R2fslNnrsksgagle0lkIU1rf6Vbzd5fKid4OuCkiJMevQfa7ZFw2YbAeNXLpXx /q4/Ps2nZ2PT5ltz0txjUq94m8Cl1TNHZO6xNKZMoURfdqgdJtUI80T1GcCB+6H8dOVZ 8H1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695150140; x=1695754940; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=QBOkvNLeu4mRX4a0lpADvQioXKl6WMWzo04VQ9VI/cRZOrQYykboccAiyccuevF0FJ 7xz663cnsNs9zb12pqqsS/4iQedw9Kwp9EDW6nDwwbxeF/q+MKBSfiff0zTvobroPzDY jyOZbcqkazgpt9C0OGlRl5ueLPdENX0ZRRIU+vSxCu7oN6uLv7UMyJCGbRAmFTvHLejz FCz8z52tkpQFNyHRMpzV/yF5gjjiZxg5Wg9l2HS6nYyq5GTroifLY6bbLKreCmiuef70 CfUwUlOkEvyrc5sm5R1/2zntziZFEHpu89zizN/ZrO/+EiOY1Xvg0LStmPMNnBa8ADPR OfpQ== X-Gm-Message-State: AOJu0YxBtpqq9PX9hQOzFUvYxmy3wDt778th3ZLuNOHG7PJ+9pStvY1o 5/iSJkvuBKlzrvktdRWGbYu4e9kNk1HQ9TzKYsn8 X-Received: from axel.svl.corp.google.com ([2620:15c:2a3:200:8f5a:6a6a:cafc:a3ad]) (user=axelrasmussen job=sendgmr) by 2002:a05:6902:1805:b0:d77:f7c3:37db with SMTP id cf5-20020a056902180500b00d77f7c337dbmr7869ybb.8.1695150140155; Tue, 19 Sep 2023 12:02:20 -0700 (PDT) Date: Tue, 19 Sep 2023 12:01:59 -0700 In-Reply-To: <20230919190206.388896-1-axelrasmussen@google.com> Mime-Version: 1.0 References: <20230919190206.388896-1-axelrasmussen@google.com> X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230919190206.388896-4-axelrasmussen@google.com> Subject: [PATCH 03/10] userfaultfd.2: comment on feature detection in the example program From: Axel Rasmussen To: Alejandro Colomar , Peter Xu Cc: linux-man@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Axel Rasmussen Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 19 Sep 2023 12:02:48 -0700 (PDT) The example program doesn't depend on any extra features, so it does not make use of the two-step feature handshake process. This is fine, but it might set a bad example for programs which *do* depend on specific features (e.g. they may conclude they don't need to do anything to enable / detect them). No need to make the example program more complicated: let's just add a comment indicating why we do it the way we do it in the example, and describing briefly what a more complicated program would need to do instead. The comment is kept rather brief; a full description of this feature will be included in ioctl_userfaultfd.2 instead. Signed-off-by: Axel Rasmussen --- man2/userfaultfd.2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/man2/userfaultfd.2 b/man2/userfaultfd.2 index 00d94e514..b2b79f61d 100644 --- a/man2/userfaultfd.2 +++ b/man2/userfaultfd.2 @@ -881,6 +881,13 @@ main(int argc, char *argv[]) if (uffd == \-1) err(EXIT_FAILURE, "userfaultfd"); \& + /* NOTE: Two-step feature handshake is not needed here, since this + example doesn't require any specific features. + + Programs that *do* should call UFFDIO_API twice: once with + `features = 0` to detect features supported by this kernel, and + again with the subset of features the program actually wants to + enable. */ uffdio_api.api = UFFD_API; uffdio_api.features = 0; if (ioctl(uffd, UFFDIO_API, &uffdio_api) == \-1) -- 2.42.0.459.ge4e396fd5e-goog