From patchwork Wed Apr 12 16:45:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13209365 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 0C8F5C77B6E for ; Wed, 12 Apr 2023 16:45:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A05E390000C; Wed, 12 Apr 2023 12:45:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98ECF900003; Wed, 12 Apr 2023 12:45:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8089390000C; Wed, 12 Apr 2023 12:45:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 69BED900003 for ; Wed, 12 Apr 2023 12:45:43 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 38079C0184 for ; Wed, 12 Apr 2023 16:45:43 +0000 (UTC) X-FDA: 80673315366.24.2C4DCFC Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id 177DBC0004 for ; Wed, 12 Apr 2023 16:45:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="I/w0zopv"; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681317941; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4P1/ScyFhtwT2WBZ2avhVrVKXGlimCZn+6QVBkOI+hY=; b=juoSBbw3lH3i/bS4uLXfCiJmpVThyyWcOPQX4fUFz4/JMCXs2jb3e4cfPS1svDGGu+Fy9n yHqN3SEgP7mjRTEZ6Jp/01GxZMDHqTxZWuIOxO1Hi6Z1Fvjw23Of8BEXbWKX9iaIk8okc6 4z8mBONGzfA5YgZSf07bXybJZ/+G1cc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="I/w0zopv"; spf=pass (imf22.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681317941; a=rsa-sha256; cv=none; b=1sPx/i/KFc78OjAu+nz1bKCNI46IrEO2aAD4bCpGkS9U9yYp+P/TcJZPMAQ32thkBvbyg3 LmF4K5M/9PzRZ6CDDhI/1yOQTz/R6lh/mis7ouX3RnKxVCVdNQ7lj6riNZFLZsgnwPwN+P FuVZtRDYq4PCB2ICV6QEjOLj/XsX85Y= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681317940; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4P1/ScyFhtwT2WBZ2avhVrVKXGlimCZn+6QVBkOI+hY=; b=I/w0zopvsUAuwVWxbPWIOWfOr7/Ykb8jdWeuZCJcV2HSTbz+UDa1SmZ+xZBMOHrCNRNdc/ bFwH670sb5KhO7SFM1ncCstrwjdD4Oc0vr+VmrgqDaCfktUSoxGOSZFNLqSnXP/3KjiNbt dMPIldlTRrrUdpsKawE/erl0Fmyi1uI= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-70-SuuU4JMOMgeQlwZVY4D_Cw-1; Wed, 12 Apr 2023 12:45:39 -0400 X-MC-Unique: SuuU4JMOMgeQlwZVY4D_Cw-1 Received: by mail-qk1-f197.google.com with SMTP id af79cd13be357-74accc750c1so3453385a.0 for ; Wed, 12 Apr 2023 09:45:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681317934; x=1683909934; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4P1/ScyFhtwT2WBZ2avhVrVKXGlimCZn+6QVBkOI+hY=; b=e2pYzybAYUPvgF2Zt4j5hZAylZGP76un2bq5/GpIXYflgVgqUtkhSwC2qHN3ZV1140 TpmBG+xrE0rqH7TLnKTgKjGzaliBCprpYIv/Z/U+LE/Q2V38Hbij8pj3TxVdpOalYGlD HURgclBSOhxBxv7cf5xRRcwasOYO4cy+ixjR1xHNRMCI5K5UdryHOA/jFg2/Qaol5if2 m/C8KAiSLv4u5zT3iv6HTvua9taccebQtACE8PcnYp3ifsxXAEzJDuzbP24x0KSgCFFC M7M9c8sUUk557JvF23IEasgYsTMGaeypLDDfugB2jlTRJ0HRs6sVEOx2kjgEYlGIVkUv 4hgg== X-Gm-Message-State: AAQBX9dEgtWqmDP4SQ+7B16wQNcIYTNQuylFp3RlFzrjEmMNvcfyfKJd VoOl6D2BaTOACo3eL/NubTu0qpaz86BGTDrq3zb15IWIEOM/HMKxdMfAl0juaGsYYzqNxRTHn3c C6ZmupKnzpc0VLoV8GUIRRaAtkhSrzK0vhWf+UIj6CrWr52NOY7tQ7hhOEwAb6lIX2F2c X-Received: by 2002:a05:6214:401a:b0:5aa:14b8:e935 with SMTP id kd26-20020a056214401a00b005aa14b8e935mr4735752qvb.2.1681317933907; Wed, 12 Apr 2023 09:45:33 -0700 (PDT) X-Google-Smtp-Source: AKy350YFr4iYYFdfQl6EUz00VO2xExXsFFSl3Ic24dd5qBrL9XsgdoJ8YxnsY9ruU2bfo6aBT4rElA== X-Received: by 2002:a05:6214:401a:b0:5aa:14b8:e935 with SMTP id kd26-20020a056214401a00b005aa14b8e935mr4735714qvb.2.1681317933520; Wed, 12 Apr 2023 09:45:33 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id eh3-20020a056214186300b005dd8b934594sm1817671qvb.44.2023.04.12.09.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 09:45:30 -0700 (PDT) From: Peter Xu To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Nadav Amit , Mike Rapoport , Leonardo Bras Soares Passos , peterx@redhat.com, David Hildenbrand , Axel Rasmussen , Andrea Arcangeli , Mike Kravetz , Andrew Morton Subject: [PATCH v2 29/31] selftests/mm: Drop sys/dev test in uffd-stress test Date: Wed, 12 Apr 2023 12:45:25 -0400 Message-Id: <20230412164525.329176-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230412163922.327282-1-peterx@redhat.com> References: <20230412163922.327282-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 177DBC0004 X-Rspam-User: X-Stat-Signature: jmx4kophn4o73ejxkos84kkkuxpzqeak X-HE-Tag: 1681317940-278731 X-HE-Meta: U2FsdGVkX1+XqrdBJDcQoh6W8xsNU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CeUIE38zMH9fvzEMg6pfc6OoxllOgO3FvDGR/Lq9HIJf8/nPZ3I22FhwDKSgNA2/ekbZfzo/6PNXcL9vaxyUwIkTqcWVTuiDM5S6qjjw3PpFXHjRh0S+lH3aBeGEN/KR1yGs9bEFaiQ7rLgT+TlNde+Y7Xw5nguAZykyXCNbplsHKEmOX1Bh0erQk6xs7/tYgFVq96Jx00udARcKwojs3sXPFBUOUckMkcnvt335uY1QWNSCrNLsSHRVNJB6gQ70tBDXC9rsl3wyhRnuyv8CHQZxtfQW7B+GBANyzYrZsTKZVV4v6mU/PHsFBmrPRO8CeMdjg6ugHMJpKFfGCdkWBONhleJWWDyYIUt8oElFkYZCbcfLaW9KrH6EEpv3ip 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: With the new uffd unit test covering the /dev/userfaultfd path and syscall path of uffd initializations, we can safely drop the devnode test in the old stress test. One thing is to avoid duplication of running the stress test twice which is an overkill to only test the /dev/ interface in run_vmtests.sh. The other benefit is now all uffd tests (that uses userfaultfd_open) can run automatically as long as any type of interface is enabled (either syscall or dev), so it's more likely to succeed rather than fail due to unprivilege. With this patch lands, we can drop all the "mem_type:XXX" handlings too. Signed-off-by: Peter Xu --- tools/testing/selftests/mm/run_vmtests.sh | 15 +++++-------- tools/testing/selftests/mm/uffd-common.c | 7 ++---- tools/testing/selftests/mm/uffd-common.h | 2 +- tools/testing/selftests/mm/uffd-stress.c | 27 ++--------------------- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index efe22dc569f0..ecc16ea6fc40 100644 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -197,16 +197,13 @@ CATEGORY="gup_test" run_test ./gup_test -a CATEGORY="gup_test" run_test ./gup_test -ct -F 0x1 0 19 0x1000 CATEGORY="userfaultfd" run_test ./uffd-unit-tests -uffd_mods=("" ":dev") uffd_stress_bin=./uffd-stress -for mod in "${uffd_mods[@]}"; do - CATEGORY="userfaultfd" run_test ${uffd_stress_bin} anon${mod} 20 16 - # Hugetlb tests require source and destination huge pages. Pass in half - # the size ($half_ufd_size_MB), which is used for *each*. - CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb${mod} "$half_ufd_size_MB" 32 - CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb_shared${mod} "$half_ufd_size_MB" 32 - CATEGORY="userfaultfd" run_test ${uffd_stress_bin} shmem${mod} 20 16 -done +CATEGORY="userfaultfd" run_test ${uffd_stress_bin} anon 20 16 +# Hugetlb tests require source and destination huge pages. Pass in half +# the size ($half_ufd_size_MB), which is used for *each*. +CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb "$half_ufd_size_MB" 32 +CATEGORY="userfaultfd" run_test ${uffd_stress_bin} hugetlb_shared "$half_ufd_size_MB" 32 +CATEGORY="userfaultfd" run_test ${uffd_stress_bin} shmem 20 16 #cleanup echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c index 3e98e129f8bd..61c6250adf93 100644 --- a/tools/testing/selftests/mm/uffd-common.c +++ b/tools/testing/selftests/mm/uffd-common.c @@ -13,7 +13,7 @@ volatile bool test_uffdio_copy_eexist = true; unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; char *area_src, *area_src_alias, *area_dst, *area_dst_alias, *area_remap; int uffd = -1, uffd_flags, finished, *pipefd, test_type; -bool map_shared, test_dev_userfaultfd; +bool map_shared; bool test_uffdio_wp = true; unsigned long long *count_verify; uffd_test_ops_t *uffd_test_ops; @@ -236,10 +236,7 @@ int userfaultfd_open(uint64_t *features) { struct uffdio_api uffdio_api; - if (test_dev_userfaultfd) - uffd = uffd_open_dev(UFFD_FLAGS); - else - uffd = uffd_open_sys(UFFD_FLAGS); + uffd = uffd_open(UFFD_FLAGS); if (uffd < 0) return -1; uffd_flags = fcntl(uffd, F_GETFD, NULL); diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h index 32e590ce9442..6068f2346b86 100644 --- a/tools/testing/selftests/mm/uffd-common.h +++ b/tools/testing/selftests/mm/uffd-common.h @@ -90,7 +90,7 @@ typedef struct uffd_test_ops uffd_test_ops_t; extern unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size; extern char *area_src, *area_src_alias, *area_dst, *area_dst_alias, *area_remap; extern int uffd, uffd_flags, finished, *pipefd, test_type; -extern bool map_shared, test_dev_userfaultfd; +extern bool map_shared; extern bool test_uffdio_wp; extern unsigned long long *count_verify; extern volatile bool test_uffdio_copy_eexist; diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index c0e804f05002..4e071a7d0ff5 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -55,8 +55,6 @@ pthread_attr_t attr; 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" @@ -69,18 +67,9 @@ const char *examples = static void usage(void) { - fprintf(stderr, "\nUsage: ./userfaultfd " - "[hugetlbfs_file]\n\n"); + fprintf(stderr, "\nUsage: ./userfaultfd \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, "\tsyscall - Use userfaultfd(2) (default)\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); @@ -400,21 +389,9 @@ static void set_test_type(const char *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 if (!strcmp(token, "syscall")) - test_dev_userfaultfd = false; - else - err("unrecognized test mod '%s'", token); - } + set_test_type(raw_type); if (!test_type) err("failed to parse test type argument: '%s'", raw_type);