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 X-Spam-Level: X-Spam-Status: No, score=-12.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AA24C433F5 for ; Tue, 21 Sep 2021 19:21:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DC6256112F for ; Tue, 21 Sep 2021 19:21:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DC6256112F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 6DFC1900002; Tue, 21 Sep 2021 15:21:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 68E4A6B0071; Tue, 21 Sep 2021 15:21:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 57CF7900002; Tue, 21 Sep 2021 15:21:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 44BA56B006C for ; Tue, 21 Sep 2021 15:21:24 -0400 (EDT) Received: from smtpin02.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E1334181D7EA0 for ; Tue, 21 Sep 2021 19:21:23 +0000 (UTC) X-FDA: 78612549246.02.3F5B779 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 6F3C250000BB for ; Tue, 21 Sep 2021 19:21:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632252082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=yTp5nZl5FP2S4p5cUtShACrTS3ff7K6W1gpGjotFl+0=; b=EcUrosvIB+wWWhgtC7zp2zvbdvl3S2Ou+VZ0FwxawhxjEeFC0ymjKenaPrM64eLRvCZJys 8SUZmUbyTaK5/F2klCjeTa9pF5kvLRWpN9KG09adXfAgt8BINSDowa4iKkRIDQJ42UFE+z oc3Z+L/4FypjEp4eEHpz1Fg74HzJmks= Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-464-Ty0Tqat1OeW_T-bOZAITLQ-1; Tue, 21 Sep 2021 15:21:21 -0400 X-MC-Unique: Ty0Tqat1OeW_T-bOZAITLQ-1 Received: by mail-qv1-f71.google.com with SMTP id h16-20020a05621402f000b0037cc26a5659so5177666qvu.1 for ; Tue, 21 Sep 2021 12:21:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yTp5nZl5FP2S4p5cUtShACrTS3ff7K6W1gpGjotFl+0=; b=FPYQSMS0zhNJitw68PApaKKt0jOfROilx4g72gt6ctNpoysW6y8yNFIaGiGEeVGh75 Q6IFT5l3Mj8zPShO03c8lR7kzp2Rl0h/EP/0sMefhndNoj6YWI6f4+iY0W8oz1XehXcu Iw8V5859B5OcZXCiwOEIi79ctrv8pJrX4a1t8JIyZBI01XR0SiWlZk4DGa4vl5ywBBqM 9SszgJypg33Is6DF6Mt2GWb5qo/Ok6Cs5gYYoqkAHQR0EIVJ3rdJq1Ofv/Y7bSW9dx7j 1S+Q0zAeIcx0UQ1CvmlnypiLDqVp/fChRWaNZuOnJ+qUiTY94+9IlKyuCpPkbCgWVB75 qxIg== X-Gm-Message-State: AOAM533sS1GyFJJiqPfSxEgPA0j+J2kPqIeIFRL8RxyRvl1NyrSPi0lX v92jqI5IOPu395/rn5PWFGPfMtFZZWegNKiZ1tdsUvCPQwFOd6/BxTOOuDjyso1ebx+y+H2zwOi OI4knOT61ed0= X-Received: by 2002:a0c:b391:: with SMTP id t17mr8884818qve.35.1632252081321; Tue, 21 Sep 2021 12:21:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxCxg/1fWoiiV7evbw5NzE0whd7BvYgpUL/aAEXYfn2sAz+T6HT6pVp513PoQzhTVefWS6UXA== X-Received: by 2002:a0c:b391:: with SMTP id t17mr8884784qve.35.1632252081010; Tue, 21 Sep 2021 12:21:21 -0700 (PDT) Received: from t490s ([2607:fea8:56a2:9100::d3ec]) by smtp.gmail.com with ESMTPSA id a9sm14623542qkk.82.2021.09.21.12.21.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 12:21:20 -0700 (PDT) Date: Tue, 21 Sep 2021 15:21:19 -0400 From: Peter Xu To: Axel Rasmussen Cc: Andrew Morton , Shuah Khan , Linux MM , Linuxkselftest , LKML Subject: Re: [PATCH 1/3] userfaultfd/selftests: fix feature support detection Message-ID: References: <20210921163323.944352-1-axelrasmussen@google.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 6F3C250000BB X-Stat-Signature: 3kcpcgtkkbux88ko6tcnmuqwnn98oitr Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EcUrosvI; spf=none (imf04.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-HE-Tag: 1632252083-250248 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: On Tue, Sep 21, 2021 at 11:26:14AM -0700, Axel Rasmussen wrote: > On Tue, Sep 21, 2021 at 10:44 AM Peter Xu wrote: > > > > Hi, Axel, > > > > On Tue, Sep 21, 2021 at 09:33:21AM -0700, Axel Rasmussen wrote: > > > diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c > > > index 10ab56c2484a..2366caf90435 100644 > > > --- a/tools/testing/selftests/vm/userfaultfd.c > > > +++ b/tools/testing/selftests/vm/userfaultfd.c > > > @@ -79,10 +79,6 @@ static int test_type; > > > #define ALARM_INTERVAL_SECS 10 > > > static volatile bool test_uffdio_copy_eexist = true; > > > static volatile bool test_uffdio_zeropage_eexist = true; > > > -/* Whether to test uffd write-protection */ > > > -static bool test_uffdio_wp = false; > > > -/* Whether to test uffd minor faults */ > > > -static bool test_uffdio_minor = false; > > > > IMHO it's not a fault to have these variables; they're still the fastest way to > > do branching. It's just that in some cases we should set them to "false" > > rather than "true", am I right? > > > > How about we just set them properly in set_test_type? Say, we can fetch the > > feature bits in set_test_type rather than assuming it's only related to the > > type of memory. > > We could do that, but it would require opening a userfaultfd, issuing > a UFFDIO_API ioctl, and getting the feature bits in set_test_type. And > then I guess just closing the UFFD again, as we aren't yet setting up > for any particular test. To me, it seemed "messier" than this > approach. > > Another thing to consider is, for the next patch we don't just want to > know "does this kernel support $FEATURE in general?" but also "is > $FEATURE supported for this particular memory region I've > registered?", and we can't have a single global answer to that. Could I ask why? For each run, the memory type doesn't change, isn't it? Then I think the capability it should support is a constant? Btw, note that "open an uffd, detect features, close uffd quickly" during setup phase is totally fine to me just for probing the capabilities, and instead of thinking it being messy I see it a very clean approach.. > It seemed a bit cleaner to me to write the code as if I was dealing with that > case, and then re-use the infrastructure I'd built for patch 2/3. I didn't comment on patch 2, but I had the same confusion - aren't all these information constant after we settle the hardware, the kernel and the memory type to test? > > Basically, I didn't initially have a goal of getting rid of these > variables, but it ended up being the cleanest way (IMHO). > > Just trying to explain the thinking. :) In the end, I think it's a > stylistic choice and don't feel super strongly about it, either way > could work. So, I can change it if you or others do feel strongly. I have no strong opinion as long as the code works (which I trust you on :). We can keep it in Andrew's queue unless you do feel the other way is better. Thanks, -- Peter Xu