Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1764435iog; Tue, 14 Jun 2022 12:48:58 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vN8BpBv9VU42CUFWSrPhMeDyk2+3FydWzrAwS6f/Xdq/Ms3i8vkum995EfeJC5oADrv4yV X-Received: by 2002:a17:90a:e545:b0:1ea:c49a:6b0a with SMTP id ei5-20020a17090ae54500b001eac49a6b0amr5499299pjb.163.1655236138589; Tue, 14 Jun 2022 12:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655236138; cv=none; d=google.com; s=arc-20160816; b=pqRDPM8bXuGLyPN3e/h/JAbZ1UTyI0gmRngaIumJKZpE8IU7o+v5bqWBR2HtmO3rWS lMdHjZhSNELXXdP4E78WY3PqTp0ZGwKo2b2XLfJfdsXloqX9gcwAWu1KkdFobPbShQLk +wY2dTkNWYq13BM6isE90KI4N9RHPxjL9DcKuvu0EPtKvEyxfHAQnnHM+bKONe+kanEU e+aKj5zAc8+DotqIb9mn8PPK2a9xAa50vcztJ14qmKz+amnlQqKzpwG0GQZAzMye2L05 SIZVP6AHZoIb23opGcLvTo8KODqx481gbdjZLjOIbKNrsZDnTyB3uti0KpO+yEmw2RX3 XRhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vaTfScKXlrbTkiP4vfe3NQO4/VTa9RTXFc7gSdqVKa8=; b=xND0c7ezbC2TzlUI3Ejmxggxmtpl3EoDob88cniEOoDyOOubz+8ufdaOPV8uwL9q4P uvtUehP9XZwJUHkvsMD1d0b4IKPorA24mB+UILIP2Qmz5b/X8FnRPiJqo7QeVLwA/olG oOxT/+YEwqfg3Z07hlYdVJ7rZR2nvc7wfiV6uX7Y9b4wFcdQtjxYaXIJBRr83yDjIBEz J62kKQcoNDWbks9pShXRKTuPbAkWTA0a+E5AArRJ3P70dvsbOKqQqlXZEoKp5/Xl7mxl aA4MX/46oUHEec4vLHhzQfgWZcCifSgX5tOp5A22short0TQZhBLoVzz5H5G9ZImDsZp LQyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IPOaed6b; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f18-20020a056a00229200b0050aa4c2957dsi337791pfe.131.2022.06.14.12.48.45; Tue, 14 Jun 2022 12:48:58 -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=@redhat.com header.s=mimecast20190719 header.b=IPOaed6b; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344702AbiFNTnP (ORCPT + 99 others); Tue, 14 Jun 2022 15:43:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344454AbiFNTnL (ORCPT ); Tue, 14 Jun 2022 15:43:11 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E563B2A433 for ; Tue, 14 Jun 2022 12:43:10 -0700 (PDT) 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-il1-f199.google.com (mail-il1-f199.google.com [209.85.166.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-451-Chdo-vNeMMa4mIS6XRzETQ-1; Tue, 14 Jun 2022 15:43:08 -0400 X-MC-Unique: Chdo-vNeMMa4mIS6XRzETQ-1 Received: by mail-il1-f199.google.com with SMTP id q15-20020a056e0220ef00b002d15dcd2750so7198794ilv.1 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=RqDmPhGStl0eeXBMmZrd9NX9fE8Vm4UpjoKGWAenZSvzAsw6ZGnfA49FRJ2kk1bYSS 9ngvTj6rdYTqGjj/UHoDxwafJGTgpYln+qARoCM+86xIdTrFcy+jhnL90zvoKD9On46/ zA+H3ane0cD2yP/bLMJ3YF0WD5Rhwyr8KoD3gqRIkhb8cVEKeZmUmONex+UJZEkFps4E WovWAwtxj2QVLIFNQKcI2MgGa58iwIhCVwT/qadamIW9G4RGu/mM+Ov2zWsGesDPreqW T4F1tdTiLtMhl4xbmc3NULx4pYFwmxuj41yrZfxwT9+VQjyeO5L+m5drbunbllupKpDL CEKg== X-Gm-Message-State: AOAM531yUiSc7QPU90vro7r/pDqkPivRwSs/xYGj1qMQYPjgbekw6Lcq 1x/yPTQ3uO700aLx1rCSYs14XW399LT8QtFckZgIPU2E/fxXD+e5Fe9Qn41P70cJ0imV1BUKqEm ffVx6Z+VqU2kvjT6U9ltu2nyP X-Received: by 2002:a05:6638:1117:b0:331:4bc8:3856 with SMTP id n23-20020a056638111700b003314bc83856mr3502717jal.128.1655235788315; Tue, 14 Jun 2022 12:43:08 -0700 (PDT) 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 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220601210951.3916598-6-axelrasmussen@google.com> X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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