From patchwork Thu Mar 30 16:08:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 77301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1252536vqo; Thu, 30 Mar 2023 09:25:17 -0700 (PDT) X-Google-Smtp-Source: AKy350auS1qg2XEpdRgz9ZdkVrnmqAP/y1mOfeBXMl58ewoeKOm2sRFmgsCtC76vauDaePu+3MfF X-Received: by 2002:a17:903:283:b0:19f:e9e7:4cb with SMTP id j3-20020a170903028300b0019fe9e704cbmr29019582plr.45.1680193517254; Thu, 30 Mar 2023 09:25:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680193517; cv=none; d=google.com; s=arc-20160816; b=ycSTETJqcJc1E62AaH1lJAK2GWELQF5FOv8BkUP8V6TYPNUu0naOianRgw8cmFoLzR kthoS4CP/JyEUyO2jyau0vXeh55MzDZ3bAMvpei5Fw5bMqODLDiHEFeB0Fzrazja/go4 WSZRNK/O680W4xYJb94rP0RVQFaiO4BuCZMrNOlDFiuiIxARG+Y5gYfYT4QH3wmFvV2n 4V588oxWldAHRMEedfGmweAj1d+N0xpNbOl1I8HQFGcYC6inBnk6vOWTISkWVIRgnf6U BxEVG46IF9Lqb/DiDDcOESbZ5Wut5h5jc7utVz8r/UAwRyga4i97WAX+7ro1qnF9llMU Cb8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QgmTtu8OFjFdW8yq7WIzzTW/am1uahC9wawM1FIOBXg=; b=wP1eTrD14bvJ4u7zLeFhHrtg6ItZGVKhhve20vGnv+c65ztdniQ0C4dYUzkbsST5xB rzE95Umad63qbaLL4wAQTGBFMDigsLY/9PUNGdWDx2h0wLOi+YeORyyRpAEPBb59ygxH x4+1FcW69i/yd6S5fbhqRRpJD2ozK2DoeTg0ROaCyJJqREWeBwr2eJdAnWsJeYhwG9Lu 7iP49iba5HhPYsXxJebLRMFRpDwcLkJChZbYsikyP6A2D7RoI+4WzVhY0TEdQmr3mmD1 uIjk0uGAMGd+6FQBwzu6haC7jrSasqgdqL9nSyA0EpcEyggl0Jq/DjPKIE7MVGARSazx oy5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GIFEKQlc; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h6-20020a170902748600b001a05652e369si34067763pll.100.2023.03.30.09.25.01; Thu, 30 Mar 2023 09:25:17 -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=GIFEKQlc; 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 S229795AbjC3QKw (ORCPT + 99 others); Thu, 30 Mar 2023 12:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231698AbjC3QK0 (ORCPT ); Thu, 30 Mar 2023 12:10:26 -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 ESMTPS id 3AD5EE1A6 for ; Thu, 30 Mar 2023 09:09:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680192525; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QgmTtu8OFjFdW8yq7WIzzTW/am1uahC9wawM1FIOBXg=; b=GIFEKQlcSWWlvVLW8R33Now6EfDwxHz5cXJjAPIfbHWso2WAMeLqjZwglCNAtNjZCqb+2H /0TDD2obUQNYSRnNTbF3IhYfXUd1jimRmTZcLPa8GKj76o0W4ZTbC/Zk1oyp+ze40Jsqcn Ua+P7gp+eDr9l4bgw0Gepg0UnetlPlo= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-BQVzeRJbMEmlF5CTlsQfVg-1; Thu, 30 Mar 2023 12:08:44 -0400 X-MC-Unique: BQVzeRJbMEmlF5CTlsQfVg-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-57c67ea348eso12978976d6.1 for ; Thu, 30 Mar 2023 09:08:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680192522; 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=QgmTtu8OFjFdW8yq7WIzzTW/am1uahC9wawM1FIOBXg=; b=vLDUezW82rH7Gt7t7LO1/lTkFZClQEueXl//OIkgFm9ZEjKzf0DD4yyVtXvwMxVY5T wOnA913mTJ7JpNnIIMM8pw1qqeEV78CDCRmxa9IxVLWziaWnTK68p40ZSEz3NG/ExhTY qFYvbDwFaXHMBB4X66Bq1wyPANot/gJngZmv8U3r3BuAeqviB9C4gawik4sFpRr2AKWP /Ht2kOxTsBn59PdDtVG9AHWKWqpkJcCwfPG98MYwUoNa3GvUp4+0l64pYi1EZz+4kvdZ tpmBetTjx1dK60K60jaWNRXSfT5GrSY9cbvbhU6P/gxHcq8xLUE/BFkjRYu2/y0Sg0Db lkrw== X-Gm-Message-State: AAQBX9ctCKC03v0b06xLgOLzPGCYL4xB0rpAKcGujb38mze+xWZpYQjK 26qRhsdPpRytagzDii/eu2EvwKtcwUe1UwPx856SYbfEjF8rciSTTQ+gvlzJjVjx3ewTHTLM/YQ gsMBycE3AR9vMXfkqrL08+ejW+jBBo1qKIYnjqNlT5bpNfGeDOkrkJfYaKJeEyl2y1d0Kb8P53q GFZj2rxQ== X-Received: by 2002:a05:6214:3014:b0:5aa:14b8:e935 with SMTP id ke20-20020a056214301400b005aa14b8e935mr3724010qvb.2.1680192522488; Thu, 30 Mar 2023 09:08:42 -0700 (PDT) X-Received: by 2002:a05:6214:3014:b0:5aa:14b8:e935 with SMTP id ke20-20020a056214301400b005aa14b8e935mr3723957qvb.2.1680192522120; Thu, 30 Mar 2023 09:08:42 -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 k2-20020a0cc782000000b005e1235e6f2esm227430qvj.12.2023.03.30.09.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 09:08:41 -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 29/29] selftests/mm: Add shmem-private test to uffd-stress Date: Thu, 30 Mar 2023 12:08:40 -0400 Message-Id: <20230330160840.3107635-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-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761810597862234705?= X-GMAIL-MSGID: =?utf-8?q?1761810597862234705?= The userfaultfd stress test never tested private shmem, which I think was overlooked long due. Add it so it matches with uffd unit test and it'll cover all memory supported with the three memory types. Meanwhile, rename the memory types a bit. Considering shared mem is the major use case for both shmem / hugetlbfs, changing from: anon, hugetlb, hugetlb_shared, shmem To (with shmem-private added): anon, hugetlb, hugetlb-private, shmem, shmem-private Add the shmem-private to run_vmtests.sh too. Signed-off-by: Peter Xu --- tools/testing/selftests/mm/run_vmtests.sh | 3 ++- tools/testing/selftests/mm/uffd-stress.c | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh index 845ce8a48204..b8ab75bc731c 100644 --- a/tools/testing/selftests/mm/run_vmtests.sh +++ b/tools/testing/selftests/mm/run_vmtests.sh @@ -202,8 +202,9 @@ 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} hugetlb-private "$half_ufd_size_MB" 32 CATEGORY="userfaultfd" run_test ${uffd_stress_bin} shmem 20 16 +CATEGORY="userfaultfd" run_test ${uffd_stress_bin} shmem-private 20 16 #cleanup echo "$nr_hugepgs" > /proc/sys/vm/nr_hugepages diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index 7461021dd4af..6172ebfe732e 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -59,8 +59,8 @@ const char *examples = "./userfaultfd shmem 1000 99\n\n" "# Run hugetlb memory test on 256MiB region with 50 bounces:\n" "./userfaultfd hugetlb 256 50\n\n" - "# Run the same hugetlb test but using shared file:\n" - "./userfaultfd hugetlb_shared 256 50\n\n" + "# Run the same hugetlb test but using private file:\n" + "./userfaultfd hugetlb-private 256 50\n\n" "# 10MiB-~6GiB 999 bounces anonymous test, " "continue forever unless an error triggers\n" "while ./userfaultfd anon $[RANDOM % 6000 + 10] 999; do true; done\n\n"; @@ -69,7 +69,7 @@ static void usage(void) { fprintf(stderr, "\nUsage: ./userfaultfd \n\n"); fprintf(stderr, "Supported : anon, hugetlb, " - "hugetlb_shared, shmem\n\n"); + "hugetlb-private, shmem, shmem-private\n\n"); fprintf(stderr, "Examples:\n\n"); fprintf(stderr, "%s", examples); exit(1); @@ -377,14 +377,17 @@ static void set_test_type(const char *type) } else if (!strcmp(type, "hugetlb")) { test_type = TEST_HUGETLB; uffd_test_ops = &hugetlb_uffd_test_ops; - } else if (!strcmp(type, "hugetlb_shared")) { map_shared = true; + } else if (!strcmp(type, "hugetlb-private")) { test_type = TEST_HUGETLB; uffd_test_ops = &hugetlb_uffd_test_ops; } else if (!strcmp(type, "shmem")) { map_shared = true; test_type = TEST_SHMEM; uffd_test_ops = &shmem_uffd_test_ops; + } else if (!strcmp(type, "shmem-private")) { + test_type = TEST_SHMEM; + uffd_test_ops = &shmem_uffd_test_ops; } }