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=-13.3 required=3.0 tests=BAYES_00,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=no 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 25166C433F5 for ; Wed, 22 Sep 2021 17:04:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A9DC061211 for ; Wed, 22 Sep 2021 17:04:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A9DC061211 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 0B1E36B0082; Wed, 22 Sep 2021 13:04:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 060FB6B0083; Wed, 22 Sep 2021 13:04:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E92CF940009; Wed, 22 Sep 2021 13:04:40 -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 D95B16B0082 for ; Wed, 22 Sep 2021 13:04:40 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 7B62732072 for ; Wed, 22 Sep 2021 17:04:40 +0000 (UTC) X-FDA: 78615833520.35.1C205B7 Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) by imf15.hostedemail.com (Postfix) with ESMTP id 1D0B0D0000A6 for ; Wed, 22 Sep 2021 17:04:39 +0000 (UTC) Received: by mail-il1-f181.google.com with SMTP id b15so3470069ils.10 for ; Wed, 22 Sep 2021 10:04:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=6Ux03cG5hBPJ9MQ2bUemW8lwVWLAct1mE8axUh1mK6k=; b=Z6U/J9MOXmwaNV+2zF5ntuLypdkphil3PjK5ro65TRqO89DHh8u1ndKkc8KqLah1rV v99nt+Du+gWUFK0sn9LyHdJiRBylTtBEBq6YeeXbLq4yaXDOUH1CLuZeqNoiFSjbnB4I mr8TRJoZ+L1Jol1L2QB1qQqlkv1/Y6CoiYPjicVRS3m8qBWdhjEIR2WJzya1A39m1blW ++icpE8GBziVH0LzlbpOdDup4TVgTz8adYh6IxwQ88C2YONiBD0QLxo4ZQalU17Bx4bd 30O6XguWTD14tRIKez+dPQyOOihhIiUVm6bue5FEKlUHLcoaHDlzdgqHoaZ3bFGlD5mo EDEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6Ux03cG5hBPJ9MQ2bUemW8lwVWLAct1mE8axUh1mK6k=; b=INF21VoAv6+plNkSPYmCHOQibAaTCSk63RgKaXE54ttmkEKclN5hK/8nxlwUoxezHA nyoUSCm5ZzrSYYYxYo4lICKWkt5WbhSSjePZa7YHVJ1zQh4u5SDE5Acv13muB/iC8Wwa drSsuAhOh8QJeW53FT0MhuuvceqKnU0xql9fuU4sjevVY2JSvCShAox+ySJaRxQFn2JU WAsXGtyqTF2fRhcVFKc22/1HVGstdkNyBHVbrleByxsfXxcJ7P6b82pCZEYnM21xxQer jYbbG+EUbzAuC6hSTgFLswZpRIO4LNkLGXAeVBKGtDgPnHkDI1haljNZtuwdPQYxGzhK iEQA== X-Gm-Message-State: AOAM531ehR6fO+AIUbgPgVEVjB2Aasg2gil4N/EIxTaHUtCCMD81rKs1 4RG2dHlG+ZTELunp4O7tHp+60i/E/vQ2RQHqEvn0pA== X-Google-Smtp-Source: ABdhPJz+KAJcw9lPLpGejjDEw4hAk3C/8Z8dhpkjFErjgU4n2XhzvH7ncUcXbpu1TUH9G56ERqUMbzU2TyTdwYMDTlQ= X-Received: by 2002:a92:db0b:: with SMTP id b11mr48933iln.275.1632330279236; Wed, 22 Sep 2021 10:04:39 -0700 (PDT) MIME-Version: 1.0 References: <20210921163323.944352-1-axelrasmussen@google.com> In-Reply-To: From: Axel Rasmussen Date: Wed, 22 Sep 2021 10:04:03 -0700 Message-ID: Subject: Re: [PATCH 1/3] userfaultfd/selftests: fix feature support detection To: Peter Xu Cc: Andrew Morton , Shuah Khan , Linux MM , Linuxkselftest , LKML Content-Type: text/plain; charset="UTF-8" Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="Z6U/J9MO"; spf=pass (imf15.hostedemail.com: domain of axelrasmussen@google.com designates 209.85.166.181 as permitted sender) smtp.mailfrom=axelrasmussen@google.com; dmarc=pass (policy=reject) header.from=google.com X-Stat-Signature: 561rj6wboyi8znhjcq37dmu7pqihaou5 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 1D0B0D0000A6 X-HE-Tag: 1632330279-189239 X-Bogosity: Ham, tests=bogofilter, spamicity=0.002848, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Thanks for discussing the design Peter. I have some ideas which might make for a nicer v2; I'll massage the code a bit and see what I can come up with. On Tue, Sep 21, 2021 at 5:29 PM Peter Xu wrote: > > On Tue, Sep 21, 2021 at 01:31:12PM -0700, Axel Rasmussen wrote: > > Ah, it has to do with us asserting the list of expected ioctls. The > > kernel changes the list of ioctls it reports in response to a > > UFFDIO_REGISTER, depending on the particular kind of vma being > > registered, **as well as what mode(s) it is being registered with**. > > > > So for example, consider the hugetlb_shared test. When registering, > > the kernel might set the UFFDIO_CONTINUE bit or not, depending on > > whether we registered with the MINOR mode bit set in particular. > > I can understand your point, but the "capability set" of the kernel is still > the same. In this case we should have UFFDIO_CONTINUE capability for > hugetlb_shared test globally, as long as the kernel supports it, irrelevant of > what test case we're going to have. > > Then in the test, if we don't register with MINOR mode, IMHO we should just > mask out the expected_ioctls with UFFDIO_CONTINUE because it does not make > sense to request UFFDIO_CONTINUE if we will never use it in the test. Right, this is how it was before. I didn't love how the base set included everything, and then each test is responsible for removing the things it isn't testing. It seems reversed: why not just have each test compute the set of things it *is* testing? > > In other words, having a "uffd_features" global variable and having it changing > all the time during tests is odd to me, but I agree it's not a big deal. :) 100% agree with this. From my perspective this is tech debt since: 8ba6e86408 userfaultfd/selftests: reinitialize test context in each test It used to be that we just had one global context (variables like uffd, count_verify, area_src, area_dst, etc). But this had the problem where some previous test can mutate the context, breaking or affecting following tests. After 8ba6e86408, we clear and reinitialize all these variables for each test, but they're still global. I think it would be cleaner if these instead were in a struct, which each test initialized and then destroyed within its own scope. If we were to do such a refactor, I would put uffd_features in that struct too - it should be private to a test, since it's a property we get from the uffd. But, I wasn't sure it was worth the churn to do something like this. > > -- > Peter Xu >