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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 77FB9CCA47B for ; Tue, 14 Jun 2022 19:43:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F284E6B0071; Tue, 14 Jun 2022 15:43:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED82D6B0072; Tue, 14 Jun 2022 15:43:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D78A56B0073; Tue, 14 Jun 2022 15:43:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C4A8F6B0071 for ; Tue, 14 Jun 2022 15:43:14 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 92C2860FDC for ; Tue, 14 Jun 2022 19:43:14 +0000 (UTC) X-FDA: 79577865108.18.7476903 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf12.hostedemail.com (Postfix) with ESMTP id B94BB400D2 for ; Tue, 14 Jun 2022 19:43:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655235790; 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=vaTfScKXlrbTkiP4vfe3NQO4/VTa9RTXFc7gSdqVKa8=; b=IPOaed6bVCv7yyNToEtqYuBy3+/rYNUwgcjkBtb6gKZLPKcAHKAz3aaH3dPZ5XQ/I4GlFy T1v2ZGq1SYkwiiGSd2DGKbHXjZZOKPgC5bPJOvOI1kq2YPhzbV1uDG66iMulzkNakwDH/x 2/1HaRlM0w2tn8Fx0vAMR/tEwcnc35Y= Received: from mail-io1-f72.google.com (mail-io1-f72.google.com [209.85.166.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-578-qa-TUF0PPeO0ENm4PldrSw-1; Tue, 14 Jun 2022 15:43:09 -0400 X-MC-Unique: qa-TUF0PPeO0ENm4PldrSw-1 Received: by mail-io1-f72.google.com with SMTP id x13-20020a0566022c4d00b0065491fa5614so4839651iov.9 for ; Tue, 14 Jun 2022 12:43:08 -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=vaTfScKXlrbTkiP4vfe3NQO4/VTa9RTXFc7gSdqVKa8=; b=0HDWP6dMeE8zl9I8CPs409wBd5shMz4FjtbtiYrQieXts8a90V7s3dAEcK0IE5ujxs Iwv50ugnyyrRn0r08d2oF6QwbZpZbFhPFeYTgD3gNRdy82iK6fZLfn5A+iXzSI8SZgId T6CXqqDo0FkFR/NHQMIupkLGZPjinKcADPqPTveMxQbAvKkKKQu8yI4gvcjuq6R5I/As 2HOPxNVDVJL3VyNbMAeS0aQQe8nA6/iq59xOjHlG/uyUF9ehhZa8YBCI0exbvHQGv7Gq 7AhwVJSAzaC86IMVOqHhdcKU3B2ZRGMz8vKnWi+Mp2WgD2jez6bg9bUpUNouEwkOHwDy 3/UQ== X-Gm-Message-State: AOAM5323MFCZjaQr0s/DOt5ctt/K+JO8mPtkfoKlijmOkUsi/o4/WcdN C3NUtp/Jtx8eXVPPNQ69M5yscWRILyoRNhTruEZa8JdX2opIBxU35iepj0g1sXY/umUiK7JERyS D/V9fK+cJ4Gg= X-Received: by 2002:a05:6638:1117:b0:331:4bc8:3856 with SMTP id n23-20020a056638111700b003314bc83856mr3502715jal.128.1655235788315; Tue, 14 Jun 2022 12:43:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS4BXo6S8IqsfxYTIzMi93s0rW45hsfYOZO/scnT22HT25Sk1w2c81oGFG69c9SFrDXgIoxA== X-Received: by 2002:a05:6638:1117:b0:331:4bc8:3856 with SMTP id n23-20020a056638111700b003314bc83856mr3502694jal.128.1655235788033; Tue, 14 Jun 2022 12:43:08 -0700 (PDT) Received: from xz-m1.local (cpec09435e3e0ee-cmc09435e3e0ec.cpe.net.cable.rogers.com. [99.241.198.116]) by smtp.gmail.com with ESMTPSA id g18-20020a02c552000000b00332122c106dsm5261847jaj.152.2022.06.14.12.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Jun 2022 12:43:07 -0700 (PDT) Date: Tue, 14 Jun 2022 15:43:04 -0400 From: Peter Xu To: Axel Rasmussen Cc: Alexander Viro , Andrew Morton , Charan Teja Reddy , Dave Hansen , "Dmitry V . Levin" , Gleb Fotengauer-Malinovskiy , Hugh Dickins , Jan Kara , Jonathan Corbet , Mel Gorman , Mike Kravetz , Mike Rapoport , Nadav Amit , Shuah Khan , Suren Baghdasaryan , Vlastimil Babka , zhangyi , linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH v3 5/6] userfaultfd: selftests: make /dev/userfaultfd testing configurable Message-ID: References: <20220601210951.3916598-1-axelrasmussen@google.com> <20220601210951.3916598-6-axelrasmussen@google.com> MIME-Version: 1.0 In-Reply-To: <20220601210951.3916598-6-axelrasmussen@google.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655235793; a=rsa-sha256; cv=none; b=B1MKEN5jxeT7acU4/wD1PRX3B2LrEr1QKWFSFFnbYQp9Fdkaqh84W/vA4GtSA1nWT4DBJP ycm37HjVxT/o0i0WrSji8O3tInSU7rs9BksgyMZNA9k7waCE0IKUgi1mrNuy8gOzhjz/NP 224n3HTb/bDApzy8XVx1XEiKppTMmLI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IPOaed6b; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf12.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655235793; 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=vaTfScKXlrbTkiP4vfe3NQO4/VTa9RTXFc7gSdqVKa8=; b=KVQW4XW5zOViKB/Jpwn90Mf5GYDEu5PIdq4IonVtieOimDKyU+o6VuRqB/I/LqnNx42lTh K1WHTLIv6uH0bsF6s9pgqNP3O/OHlwFwsu2Is5EI57ir0tULimCyNAavYHwLo892Lx6vRf TH5jx0KYK90cfUSOSmle5PCug56vYQ8= Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IPOaed6b; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf12.hostedemail.com: domain of peterx@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=peterx@redhat.com X-Rspam-User: X-Stat-Signature: dppn4g5ndxbsebx1scceny756hzh8sww X-Rspamd-Queue-Id: B94BB400D2 X-Rspamd-Server: rspam08 X-HE-Tag: 1655235793-621534 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 Wed, Jun 01, 2022 at 02:09:50PM -0700, Axel Rasmussen wrote: > Instead of always testing both userfaultfd(2) and /dev/userfaultfd, > let the user choose which to test. > > As with other test features, change the behavior based on a new > command line flag. Introduce the idea of "test mods", which are > generic (not specific to a test type) modifications to the behavior of > the test. This is sort of borrowed from this RFC patch series [1], but > simplified a bit. > > The benefit is, in "typical" configurations this test is somewhat slow > (say, 30sec or something). Testing both clearly doubles it, so it may > not always be desirable, as users are likely to use one or the other, > but never both, in the "real world". Yes, when I was reading your other patch I was wishing no timeout of any of QE testbeds could trigger. If you plan to remove it anyway, mind to squash these? > > [1]: https://patchwork.kernel.org/project/linux-mm/patch/20201129004548.1619714-14-namit@vmware.com/ > > Signed-off-by: Axel Rasmussen > --- > tools/testing/selftests/vm/userfaultfd.c | 41 +++++++++++++++++------- > 1 file changed, 30 insertions(+), 11 deletions(-) > > diff --git a/tools/testing/selftests/vm/userfaultfd.c b/tools/testing/selftests/vm/userfaultfd.c > index 1badb5d31bf9..aeee6f1ad8ef 100644 > --- a/tools/testing/selftests/vm/userfaultfd.c > +++ b/tools/testing/selftests/vm/userfaultfd.c > @@ -128,6 +128,8 @@ struct uffd_stats { > const char *examples = > "# Run anonymous memory test on 100MiB region with 99999 bounces:\n" > "./userfaultfd anon 100 99999\n\n" > + "# Run the same anonymous memory test, but using /dev/userfaultfd:\n" > + "./userfaultfd anon:dev 100 99999\n\n" > "# Run share memory test on 1GiB region with 99 bounces:\n" > "./userfaultfd shmem 1000 99\n\n" > "# Run hugetlb memory test on 256MiB region with 50 bounces:\n" > @@ -144,6 +146,13 @@ static void usage(void) > "[hugetlbfs_file]\n\n"); > fprintf(stderr, "Supported : anon, hugetlb, " > "hugetlb_shared, shmem\n\n"); > + fprintf(stderr, "'Test mods' can be joined to the test type string with a ':'. " > + "Supported mods:\n"); > + fprintf(stderr, "\tdev - Use /dev/userfaultfd instead of userfaultfd(2)\n"); That looks better than running everything by default twice. Though let's also provide "syscall" if we're at it, anyway? Thanks, > + fprintf(stderr, "\nExample test mod usage:\n"); > + fprintf(stderr, "# Run anonymous memory test with /dev/userfaultfd:\n"); > + fprintf(stderr, "./userfaultfd anon:dev 100 99999\n\n"); > + > fprintf(stderr, "Examples:\n\n"); > fprintf(stderr, "%s", examples); > exit(1); > @@ -1607,8 +1616,6 @@ unsigned long default_huge_page_size(void) > > static void set_test_type(const char *type) > { > - uint64_t features = UFFD_API_FEATURES; > - > if (!strcmp(type, "anon")) { > test_type = TEST_ANON; > uffd_test_ops = &anon_uffd_test_ops; > @@ -1626,10 +1633,28 @@ static void set_test_type(const char *type) > test_type = TEST_SHMEM; > uffd_test_ops = &shmem_uffd_test_ops; > test_uffdio_minor = true; > - } else { > - err("Unknown test type: %s", type); > + } > +} > + > +static void parse_test_type_arg(const char *raw_type) > +{ > + char *buf = strdup(raw_type); > + uint64_t features = UFFD_API_FEATURES; > + > + while (buf) { > + const char *token = strsep(&buf, ":"); > + > + if (!test_type) > + set_test_type(token); > + else if (!strcmp(token, "dev")) > + test_dev_userfaultfd = true; > + else > + err("unrecognized test mod '%s'", token); > } > > + if (!test_type) > + err("failed to parse test type argument: '%s'", raw_type); > + > if (test_type == TEST_HUGETLB) > page_size = default_huge_page_size(); > else > @@ -1676,7 +1701,7 @@ int main(int argc, char **argv) > err("failed to arm SIGALRM"); > alarm(ALARM_INTERVAL_SECS); > > - set_test_type(argv[1]); > + parse_test_type_arg(argv[1]); > > nr_cpus = sysconf(_SC_NPROCESSORS_ONLN); > nr_pages_per_cpu = atol(argv[2]) * 1024*1024 / page_size / > @@ -1714,12 +1739,6 @@ int main(int argc, char **argv) > } > printf("nr_pages: %lu, nr_pages_per_cpu: %lu\n", > nr_pages, nr_pages_per_cpu); > - > - test_dev_userfaultfd = false; > - if (userfaultfd_stress()) > - return 1; > - > - test_dev_userfaultfd = true; > return userfaultfd_stress(); > } > > -- > 2.36.1.255.ge46751e96f-goog > -- Peter Xu