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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84220C433EF for ; Tue, 19 Jul 2022 22:48:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236237AbiGSWsN (ORCPT ); Tue, 19 Jul 2022 18:48:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237896AbiGSWsH (ORCPT ); Tue, 19 Jul 2022 18:48:07 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64F884F184 for ; Tue, 19 Jul 2022 15:48:05 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2A6B2B81B94 for ; Tue, 19 Jul 2022 22:48:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3839C341C6; Tue, 19 Jul 2022 22:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1658270882; bh=N/Td1zUnMwakBafrwvioqhC2CMZ9/uqlL5uYYKHUIsc=; h=Date:To:From:Subject:From; b=OFusV18Ljq/lKiTnQWGtAhlnDI7h9lp5LvsDzPI5NoPlTzggTime2HYFYqrBVK/GS 8exV/xnwS1/3ywtBJ0+yWRsmL/nHGp8v8xm6spkPwWtUcCTTkGiseLnBoCtFzU42TP 22FFW/JMqFe+vp3J6V+oTmHZ64o4tPTKelkDbpyk= Date: Tue, 19 Jul 2022 15:48:02 -0700 To: mm-commits@vger.kernel.org, yi.zhang@huawei.com, viro@zeniv.linux.org.uk, vbabka@suse.cz, surenb@google.com, skhan@linuxfoundation.org, rppt@kernel.org, peterx@redhat.com, mike.kravetz@oracle.com, mgorman@techsingularity.net, ldv@altlinux.org, jack@suse.cz, hughd@google.com, glebfm@altlinux.org, dave.hansen@linux.intel.com, corbet@lwn.net, charante@codeaurora.org, axelrasmussen@google.com, akpm@linux-foundation.org From: Andrew Morton Subject: [to-be-updated] userfaultfd-selftests-make-dev-userfaultfd-testing-configurable.patch removed from -mm tree Message-Id: <20220719224802.D3839C341C6@smtp.kernel.org> Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org The quilt patch titled Subject: userfaultfd: selftests: make /dev/userfaultfd testing configurable has been removed from the -mm tree. Its filename was userfaultfd-selftests-make-dev-userfaultfd-testing-configurable.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Axel Rasmussen Subject: userfaultfd: selftests: make /dev/userfaultfd testing configurable Date: Wed, 1 Jun 2022 14:09:50 -0700 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". [1]: https://patchwork.kernel.org/project/linux-mm/patch/20201129004548.1619714-14-namit@vmware.com/ Link: https://lkml.kernel.org/r/20220601210951.3916598-6-axelrasmussen@google.com Signed-off-by: Axel Rasmussen Cc: Al Viro Cc: Charan Teja Kalla Cc: Dave Hansen Cc: Dmitry V. Levin Cc: Gleb Fotengauer-Malinovskiy Cc: Hugh Dickins Cc: Jan Kara Cc: Jonathan Corbet Cc: Mel Gorman Cc: Mike Kravetz Cc: Mike Rapoport Cc: Peter Xu Cc: Shuah Khan Cc: Suren Baghdasaryan Cc: Vlastimil Babka Cc: Zhang Yi Signed-off-by: Andrew Morton --- tools/testing/selftests/vm/userfaultfd.c | 41 +++++++++++++++------ 1 file changed, 30 insertions(+), 11 deletions(-) --- a/tools/testing/selftests/vm/userfaultfd.c~userfaultfd-selftests-make-dev-userfaultfd-testing-configurable +++ a/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"); + 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(voi 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 *ty 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(); } _ Patches currently in -mm which might be from axelrasmussen@google.com are selftests-vm-add-dev-userfaultfd-test-cases-to-run_vmtestssh.patch