From patchwork Thu Mar 30 16:08:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13194510 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 9FDC1C6FD1D for ; Thu, 30 Mar 2023 16:08:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6576E6B009C; Thu, 30 Mar 2023 12:08:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 590C090000A; Thu, 30 Mar 2023 12:08:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 393256B009E; Thu, 30 Mar 2023 12:08:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 2307C6B009C for ; Thu, 30 Mar 2023 12:08:45 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id F15CFAC1A6 for ; Thu, 30 Mar 2023 16:08:44 +0000 (UTC) X-FDA: 80626047768.19.5D3E669 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id C81F5140022 for ; Thu, 30 Mar 2023 16:08:42 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HF0knmSu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680192522; 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=SqqRZE0+KdLihnYJHNBsrIiryhx5Vgf+EPtUaXiDnEk=; b=7AB8Emt56OJnm9DAyJbHZIKf0/3zfGWc+dIGb6WLW9NqiokrcRFpXhoTJ5q0/O15Dd7AFf L0Hb0pPHAtXHSh1O0Pv7Y7QKRrM8ZMi8nyNG4HIQIUGNm/8WqKrAWEhhPZDKQ0i84iPUbs IKAJNSuDzs9VB+Rj7PIwfX3F8S5g6s8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=HF0knmSu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680192522; a=rsa-sha256; cv=none; b=K/6ijZONxLXiWDJeaooWv55sg+rOs2quMDT8qb78e2F6c+V0Izv1FKCFRQEHYmdPxx+p0u BQ4qwnZ0goMKq47xg4iAKb04TOHYuun2ySidTicqNvckWD7RFJCpiPtnKTTMcbX2sBYxLP e67+st7AiJTzPpZR9uWsK08f7Elq1tI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680192522; 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=SqqRZE0+KdLihnYJHNBsrIiryhx5Vgf+EPtUaXiDnEk=; b=HF0knmSuYvEYRVAZCBF7GxhWUMqP2CLqLB2fNvmin13K1t2AdN0G1LreQGfkTFr2eHFKa4 bejLlF+a1lnbkkj8V5M1/Hw/HdN5vPYaIEUEkGVd62Nwp7yp3oBQPRTbfmbIXGRdRRpYhV mXIQx/hoTE+IWovkL576O0p4lly6JhI= Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-myKYyltIM32S22y8mmL6Qg-1; Thu, 30 Mar 2023 12:08:40 -0400 X-MC-Unique: myKYyltIM32S22y8mmL6Qg-1 Received: by mail-qk1-f200.google.com with SMTP id d72-20020ae9ef4b000000b007467a30076fso9087604qkg.18 for ; Thu, 30 Mar 2023 09:08:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680192520; 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=SqqRZE0+KdLihnYJHNBsrIiryhx5Vgf+EPtUaXiDnEk=; b=LlfrNExZ9oe4NuB654TousJiRAfblTD0APFQLIXZEtnfg5qcxnMKSPUFSz92dAt0xt /Y5UUthsaJKYGGk1Nb0N/dUvpWpBPp2RZHNqzrEE5DlhCVkw4ircnu1auNAI1xZTItJ7 /e0Hnv3PRBW9tnk2L9HHpAlznEu/mhWIztDMmab7OmsKYOdYRNQLOTOTpYxaZeh/XQkW YitqS/BMmVMBrIOkv4T++vZBX0N6zpS331DLywbRUaETkGUnzEkzEAP5JeE1L5aoCEHd LcPYpJncW0ma0HxgWlRqGWzB5oEmOmMKt9+sSZFbB4kviIIBPXmAkU8wkwvXxj/8GR2u jUcw== X-Gm-Message-State: AAQBX9fnDwIzIn5m6c4qehSMivnonwYCUm8OrFIaIIhB25zYBRenZ4fj SoAxs4+oqlfP77kSUEfUTMj5PiQDgD3wZ6uE9AECCg6T57zty+7rssD0QOj2Wc15+tIWZNsqikH EH9gxkb5dePQ= X-Received: by 2002:a05:6214:519e:b0:5df:55b5:b1a with SMTP id kl30-20020a056214519e00b005df55b50b1amr3622813qvb.4.1680192520215; Thu, 30 Mar 2023 09:08:40 -0700 (PDT) X-Google-Smtp-Source: AKy350bqP/iX2AlNio2XqzWARNgLqKc/rTJrU3oBSu0UdCvPePSSbjDMbIS03DCF8/QdFFI9R5EhrQ== X-Received: by 2002:a05:6214:519e:b0:5df:55b5:b1a with SMTP id kl30-20020a056214519e00b005df55b50b1amr3622788qvb.4.1680192519977; Thu, 30 Mar 2023 09:08:39 -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 mn15-20020a0562145ecf00b005dd8b93458dsm5543495qvb.37.2023.03.30.09.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 09:08:39 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz , Mike Rapoport , Andrea Arcangeli , peterx@redhat.com, Leonardo Bras Soares Passos , Andrew Morton , David Hildenbrand , Axel Rasmussen , Nadav Amit Subject: [PATCH 28/29] selftests/mm: Drop sys/dev test in uffd-stress test Date: Thu, 30 Mar 2023 12:08:37 -0400 Message-Id: <20230330160837.3107624-1-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230330155707.3106228-1-peterx@redhat.com> References: <20230330155707.3106228-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Queue-Id: C81F5140022 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: wromodk54tsnaqke6f7pci9fw8ogecy7 X-HE-Tag: 1680192522-471678 X-HE-Meta: U2FsdGVkX186H3tzNk0SWvkK3tJTTPVtWmQzkfdiU8mUvhQNGJs8U2GJGNEzcOPgFvKAtQgYtkLXRNLpCKFLCzUi9ZDBac6iXdni+Boo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iJy4ffjHkD1pHlW/AAUBPoMuBHTs2PVbtw7ES9mBEqLxxTpwBviMS90+cNVQDH2f1w9x4AN7AcPmd9Nj8prLeNjlqkKjEXjUe24gr7d+dgYkQkkRnCQ9WJTwdN3fNJZskDzESMJ+S/Nrd0J9JMl6lGRy4R9TtRGn6vuLDCT3FUM13dGEUIer77LO8nEWS21HOX5FuFS++W3BBWoB8dsYenv2PPg/+vrS46EJN8yd+jyOd9RLZFwYbwYs2NDhzmHsWxBn3ueuQjEJ22+wjiwPGdFsvGGWF6Ci3Sieb+3vq8 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 af7bbc74cd83..845ce8a48204 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 964fa57b710a..f14bf0941077 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; @@ -229,10 +229,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 07d00e9809dc..f2e2fbb37cda 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 8f41bef2fbda..7461021dd4af 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); @@ -401,21 +390,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);