Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp990006rwl; Wed, 29 Mar 2023 11:01:13 -0700 (PDT) X-Google-Smtp-Source: AKy350ZSYrBVtUgBFnsA9GWh6X7mAKG9jQJm4rQIFYpRvG+u1PRNwCXM8Tml3F5WALNzmgwYgY8N X-Received: by 2002:a17:906:4d8b:b0:92b:f8ce:4e75 with SMTP id s11-20020a1709064d8b00b0092bf8ce4e75mr19048483eju.72.1680112873010; Wed, 29 Mar 2023 11:01:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680112872; cv=none; d=google.com; s=arc-20160816; b=tp/Xv3hc++NJ54g8+d9yU36l6G4TVqiQ243BS6IB9WdQj2GLuudY8TnP9Nf22AfYyr qfe8iZOOQGEAXcJ6hvSjCo4ZWanLXtYh7mHlkAarjt1hM/ko21ahEIXvWXdBUofKr7h4 L6kzHrr7YvDX+8gCU73FMIA/ON8MCf4fN/DTc+7vitzTm6gQuq+EYeN6KghlSnc+NTvJ MBlVyjtcTALTSKsuLYeXm6KQ6u9HaPKB7mOc7yMINYAGfRpY+Pfw2THnjqUff612DKw5 ebDtxF/DzyMqoWISO4zty8HHA/s2IHiSXnpmCJ0QT6Qp9b2IDA8QkIBPJPSaw5RcXm8T H0WQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=j7r474dcwAeSgzFtA0e++9lGH7M7F1P88vLQKvQsNGk=; b=ktmpUyJSF+Gpf24xcxPrGdEZaLQXXpJWDiE/V/U6UdfWIGSJf9bjFs0WLFp8SXngXv PhQjHAfVAjCxy1WbL0TJBD8PcH5DADfgvkSi3u8CyL1ComZ/TKlMAvB4pJlU2P1EGmXI ynemaQWU8DFYwqnXec/vWrfJnFqCl2K3gsoffZ28CXOGHPpnNA069jad6mMdbhosJ+Ce 4OahOlVt2dnyOJsnVbyPe6Enc7c+0V7Dd2zta3Z1yGRkgj0VDhQAB1tkj9BV4GTjOph5 IFjpWAUNm2Q9ItK9gn22pvoJ3mtI46S9YOGjKpE7OrwkbzIiiNUlkbeYOTXyj++VNzyJ E4Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BvTNLj+T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p16-20020a1709065dd000b00944041f6c81si9669955ejv.476.2023.03.29.11.00.47; Wed, 29 Mar 2023 11:01:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=BvTNLj+T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229461AbjC2RyT (ORCPT + 99 others); Wed, 29 Mar 2023 13:54:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjC2RyS (ORCPT ); Wed, 29 Mar 2023 13:54:18 -0400 Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BCD6DF for ; Wed, 29 Mar 2023 10:54:17 -0700 (PDT) Received: by mail-lf1-x135.google.com with SMTP id c29so21312494lfv.3 for ; Wed, 29 Mar 2023 10:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1680112455; x=1682704455; 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=j7r474dcwAeSgzFtA0e++9lGH7M7F1P88vLQKvQsNGk=; b=BvTNLj+T6CPVNp/B17LSyz/YfoU50UfKpT8APVBjmijPPh3VFYJahkylhYlXnIk43Q 6cHt3gQeVzUk7wTQWXdZeGFnVOKnYd453W3FNjOL5XfQEuLFXvXlYTMUAZ5EpIpxIBlJ fDaArvKVjDUgumVb53IEDTLBhZF/oeW78YWaRHFI5pwZKEa4We2ErPZ+LoZ0Vjz940T4 kAjtBW6zReQwLO4VHR+jS19ef74AzyxOc/ftH5A2C/bKM4D032qE+SsBgljcY9ntOfTG pQB7E7k/+is01eN8PhehbkJfo6KvAgVDatZr6icaCIHo2jo2atZLkR6NMRTtgmyzKRGJ f4vA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680112455; x=1682704455; 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=j7r474dcwAeSgzFtA0e++9lGH7M7F1P88vLQKvQsNGk=; b=Kn+aW0l3oiyuIjjbVIKSHnyj6QtW8OtTEaPunX55L+lqKQDka1zOYFPGAJhqXSGTMT 5Gdvd37MPO56MGR4gqwKiMfET1k/J0bUQr73Dz5uFKWwyez7kNNvfKv0x7pQb4LJiBrv 7qV+Wdb3I5G1bA48UJBI3QAVLhJN/Ig18T9afFmWcp+Ag6pb5ZrUPib8Cax+5cH4NTuc Rwet1Y7QuqazTN/yOt089B/teGBGYeQsDA/TqYaOZWuROZOXuY1wNYwM6xBRSkAGruSy dgLZ2bj4s4N71cwk67jUMUeYlaDHASicRfA3ap5v9tbdJUBgppNXTujPsBZuxuQmEUwT WdMA== X-Gm-Message-State: AAQBX9feEX8+MnsexPVmiUxFdLzZG6WGMAeo8YRv3p/TALu+vLFS6dca K9hoyrHsh1K6Q521Q6qS3CLgIpAYDe8ip9HFjU+Mmg== X-Received: by 2002:ac2:55a2:0:b0:4ea:f9d4:93a1 with SMTP id y2-20020ac255a2000000b004eaf9d493a1mr6037484lfg.10.1680112455212; Wed, 29 Mar 2023 10:54:15 -0700 (PDT) MIME-Version: 1.0 References: <20220722201513.1624158-1-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Wed, 29 Mar 2023 10:53:38 -0700 Message-ID: Subject: Re: [PATCH] userfaultfd: don't fail on unrecognized features To: Peter Xu Cc: Alexander Viro , Andrew Morton , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 28, 2023 at 3:34=E2=80=AFPM Peter Xu wrote: > > On Tue, Mar 28, 2023 at 02:52:35PM -0700, Axel Rasmussen wrote: > > I don't see being very strict here as useful. Another example might be > > madvise() - for example trying to MADV_PAGEOUT on a kernel that > > doesn't support it. There is no way the kernel can proceed here, since > > it simply doesn't know how to do what you're asking for. In this case > > an error makes sense. > > IMHO, PAGEOUT is not a great example. I wished we can have a way to prob= e > what madvise() the system supports, and I know many people wanted that to= o. > I even had a feeling that we'll have it some day. > > So now I'm going back to look at this patch assuming I'm reviewing it, I'= m > still not convinced the old API needs changing. > > Userfaultfd allows probing with features=3D0 with/without this patch, so = I > see this patch as something that doesn't bring a direct functional benefi= t, The benefit is we combine probing for features and creating a userfaultfd into a single step, so userspace doesn't have to open + manipulate a userfaultfd twice. In my mind, both approaches achieve the same thing, it's just that one requires extra steps to get there. To me, it's still unclear why there is any harm in supporting the simpler way? And, I also don't see any way in which the more complex way is better? > but some kind of api change due to subjective preferences which I cannot > say right or wrong. Now the patch is already merged. If we need to chan= ge > either this patch or the man page to make them match again, again I'd > prefer we simply revert it to keep everything like before and copy stable= . I think we need to change documentation either way. But, I think the changes needed are actually bigger if we want to revert. With the simpler behavior, the selftest and the example program in the man page are ~correct as-is; otherwise we would need to modify those to use the two-step probing method. (By the way, I am excited about the selftest refactoring you talked about! Thanks for doing that work. It definitely needs it, the complexity there has gotten significantly worse as we've added more things onto it [wp, minor faults].) I think the man page description of how to use the API is incomplete in either case. Right now it sort of alludes to the fact that you can probe with features=3D=3D0, but it doesn't explicitly say "you need to probe first, then close that userfaultfd and open the real one you want to use, with a subset of the features reported in the first step". If we want to keep the old behavior, it should be more explicit about the steps needed to get a userfaultfd. You are right that it also doesn't describe "you can just ask for what you want, and the kernel tells you what subset it can give you; you need to check that the reported features are acceptable" - the new behavior. That should be updated. > > Thanks, > > -- > Peter Xu >