From patchwork Tue Sep 19 19:01:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Axel Rasmussen X-Patchwork-Id: 13391773 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 76FE2CE79AA for ; Tue, 19 Sep 2023 19:02:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07B0A6B00B8; Tue, 19 Sep 2023 15:02:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 034426B00B9; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DBD786B00BA; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C892F6B00B8 for ; Tue, 19 Sep 2023 15:02:22 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id AC43EC06B2 for ; Tue, 19 Sep 2023 19:02:22 +0000 (UTC) X-FDA: 81254267724.05.D5E59D8 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf11.hostedemail.com (Postfix) with ESMTP id D1C014001E for ; Tue, 19 Sep 2023 19:02:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tpW+7o8w; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695150140; a=rsa-sha256; cv=none; b=Uza0l64UFMa94uSccriULer9Hxx0ywlA8Ea9gjKgiugs/VkJqFejbUuNEiSsepjxwu1EAL dJIB0qxAjLn/n4ykuYMXIY+de/7krVFlWrNH7hi6wzLWzjzeZqbqUElgezJ/R+BWAnCQRG LiS+LwACmz3wYCXU92P28Ys0tk0q0Nk= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=tpW+7o8w; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf11.hostedemail.com: domain of 3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3PPAJZQ0KCHMRoVciRjdljjVeXffXcV.TfdcZelo-ddbmRTb.fiX@flex--axelrasmussen.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695150140; 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=ki2PsI/vYMabFbd8E5Ao5rQjeLB7FSTcyoizKDHBTIc=; b=M1i66Gf6hJE8gF8dMwj25mFwJDz9mqEojjE4sce2mAJsQBNHXjDbvkGfDnIqf01Bu6gkY6 lzsOQU0DqlCroamU/jdKP3TDr3VDCUvLoY+7x0q5doaRlSdiQAgnVhWQp6jZCrDnKxj0zv NvIjuIwJdbZWUA0/5sASCFOEOA/nqtw= Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-d859ac9ea15so277230276.2 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=kvack.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=tpW+7o8wdfKa1VXIW8WjxrflhEGWEySQ+qNLeng/e8XS+zHRHl39P0bPUSQ5MJfLxF plhrJAL2x32P0vmtqov0Sc1TqCwrx52IH1+AhPbWiGELddLBw7U+JHue/OPKhYdYqgUH BQ0wmTVypsphWWzPhIwR2lEeNOmcLT7XuU6STOyaZA9m4I7dj/XAbDoASNgko1kDOPli N6KryCCPEWgC2XD8DZvooBKkLVZiP+Mje6dHb2RhJhd2SlR6IORRZHjVjJ40FWMtYJBu 1HcgoaiGjkJU9IA9YqGyzzYN0Nyp1gBruhwCqc5NtJx0TK0pCbxLj4GiveOX/TnKGqzT XaxA== 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=UIKscpzyVAin7EXQQblNPLtR4aBZq7kg+c1SXVFzpk1TFVw74whdLaz9YxXB0PPMtQ ysw1cafbk0qaukPeGsTyhVUAiNoN1iHd/MI1cEYy+BJ3ytTPug0mW5p9OTB4cBFaYkq5 wZmeMsW0G0riE8iyXRuk559q0du4Bn5rMuoDrujBMAK8O0s5Cg6y/SFBELXxVPnKX+NX St2jPbpj14WIuYcLeZsBxmTE010gIpBxshM65euYJow4MtGZWq2bS/Ja66Sx2uwRAV2l plS1w3+j0uJ+lhZ+fK3Z9BcSQcuxwhrL8Gm2cKMlautQXbb2hLU9rIK5mvy+ID+5IUB2 Y0BQ== X-Gm-Message-State: AOJu0Yw0EWbtmHaoMAQcIJKKvQ1yhlZ1Vzmi37So2UtxrUMYyDFLpo9O wH2BrSx0fKjvVOc6/kCX7sfOkDGg1hUCxCUmSrHB X-Google-Smtp-Source: AGHT+IGXSMthavzGtM+I960Ina2tCwgtxbX7+5w8vKtVGs3oDe4TAyxfuIyBkIIgO4pFyUZosMmWqGuYU0BoHxollsgu 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 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D1C014001E X-Stat-Signature: kboyroqffsyqizeeogfps3yj64ef6qs6 X-HE-Tag: 1695150140-317995 X-HE-Meta: U2FsdGVkX1+H+SoYOWYrSs212lGGlW1RObCatc6r5+m/15g6pq8TILAUV9vx6PwAROTjoFx2FP50gWFXGyyqFXMpx813KrEcMTR4PyocXmZn2KKJeIULAD+wpxRVQl7/hC/RzZAr+3L84s5RSRZgwBX7KmxFJYKVrHSCw6/o5QbtdXbQdSqcA4JHdVy9N+ytEojJ+7zvfOeAn4UOD0/AexR8WrC4N6nlwOhG4GtyZBAacCi7BIb8QYT7MuuwiWFaymdfwherflg9NlLi7/anU9rWwwulznGNFECufYS4c2h+j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A9sbmL0yNh6bveEi8jpYoLRm9SCL2jMhP5dtt1GntiWkdR1GqLfg2Ttx0EyWZtrPz7RPXiJn00IZC3CrenI0Y5N8vi1UbmildVv5uw2fY+49rPDm7AmR5hWcZX4NL6KN7nKTGDnRsFEaXrl7Bn9FqV2SXIrH2kXU1QCK0ifudHxePvHHHv1xajnNcP2KdPYSMKKbuqRs/fF+W5LirOVIn5VsDvcTw/5vyHNx3J69V9g8/+YHkitvOuP8Ye4neFqkIgDCrUUfHl/yVhoOPRzSkJskoaj4brng== X-Bogosity: Ham, tests=bogofilter, spamicity=0.136434, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 Reviewed-by: Mike Rapoport (IBM) --- 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)