From patchwork Wed Apr 12 16:43:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13209354 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 E76DFC77B6E for ; Wed, 12 Apr 2023 16:43:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 83100280002; Wed, 12 Apr 2023 12:43:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7E164280001; Wed, 12 Apr 2023 12:43:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68269280002; Wed, 12 Apr 2023 12:43:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 561D7280001 for ; Wed, 12 Apr 2023 12:43:42 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 1078280181 for ; Wed, 12 Apr 2023 16:43:42 +0000 (UTC) X-FDA: 80673310284.27.DD2793A Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf09.hostedemail.com (Postfix) with ESMTP id B9644140020 for ; Wed, 12 Apr 2023 16:43:39 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hq1PXmbj; spf=pass (imf09.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=1681317819; 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=0pO7URj8vYM+yjGhq+aT/ST6K4M19Q/F9Gc+2VYksqI=; b=dyS8TBHdHpgYB53sNtlGb9pIm5aRdWelYGuG6CUZZG76ao35Ps3CrCCwWOeyTXOITOKyd9 wKyeNTwp+rJQwcIeWGPfNMHHBxjUATZ2m0pzn83SUBkf0aPP7yxedAmbawLe2ii5KsIvlJ X1//eI9ICnNkohwn0oqjJz1FD7H9Dj0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Hq1PXmbj; spf=pass (imf09.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=1681317819; a=rsa-sha256; cv=none; b=OQ2s9O0vgEFylDtJCCUG3APGEaWMGv0QO4/TN9B/+/qWFDtfPd1XieLuqoQk+WzqU/nlm8 WQc3HnD8/UUdoQbippsTkh91csqqZEKvW5vuiMXqCMquoXXyZFS7hwuS/o7nQCR6n1iAzw AOVdmtQOxVrDwLGwMH4o5H0Z9h6/YOU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681317818; 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=0pO7URj8vYM+yjGhq+aT/ST6K4M19Q/F9Gc+2VYksqI=; b=Hq1PXmbjMD/9Zk+IpshVTTrXAN2+D5VDqbHviRWjOTpEu/YmHws6rqUXYWHEa2MilO4r8u 8tmd0h449X6Q/mmgL4uwDeyRLVl1SvAUiNnnskJaPZxc16LyLp/7BwHI/DCpguRCbcCj7M arTynnrCUwhED90xTea6w399uQ30K+U= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-104-4QhtNAzRPXyxjA8mqQf9MA-1; Wed, 12 Apr 2023 12:43:37 -0400 X-MC-Unique: 4QhtNAzRPXyxjA8mqQf9MA-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-74a9035256eso54269285a.0 for ; Wed, 12 Apr 2023 09:43:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681317817; x=1683909817; 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=0pO7URj8vYM+yjGhq+aT/ST6K4M19Q/F9Gc+2VYksqI=; b=Rhb9lV9OYqExAgJedS7Ycgkx7d2/OhEp8O+U+noBHiG0AVcJKSI4lN8UZdyiNchwTm 3Whef+rQbsJ0FAASQEEybf8pe1zA+NR1wP6d73e024U5MVqV0kbuNpYwYPDMeZl/Dvjw 07jzUB4FrklI+C6pnLMQeS/mbtC7zpNc8K4AzdcHA+e/av5bVdM8NKxEJdpfsDM9R1S5 rornGot5WzumdAl/Y8yfq6affH1C33rdlELXPpJt1VqrjcYo909N5RewqnZFefvlk4Bt SZ19U0L0oFI2M1iE5XFktZMr43uquJOWAt4LYx61Sr6n53kjRyCmqMqmFbTqX03LtPB7 FnHA== X-Gm-Message-State: AAQBX9eFnMFN+ZPiyXIWc/KMHOHgyveg7TPbACCE6DoQfb4ITG+XWlL3 1fs76YgyWBQhNe2jU3LhvT3m57TZjq/wsbX8r5QAnbLf8D7+2nED/wsyAKmQmg4sAcJoP3eoDCe XQQAy4WB2pLY= X-Received: by 2002:a05:6214:4105:b0:5de:5da:b873 with SMTP id kc5-20020a056214410500b005de05dab873mr4443932qvb.3.1681317817218; Wed, 12 Apr 2023 09:43:37 -0700 (PDT) X-Google-Smtp-Source: AKy350Z3R6M8KdFbyjyZ96tq0efKVR1IxKkDB07C26LLb6jjk8ZwbABfKxJGq8KdfFl/AQ+DyKIdCA== X-Received: by 2002:a05:6214:4105:b0:5de:5da:b873 with SMTP id kc5-20020a056214410500b005de05dab873mr4443916qvb.3.1681317816911; Wed, 12 Apr 2023 09:43:36 -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 mf18-20020a0562145d9200b005dd8b934579sm3677087qvb.17.2023.04.12.09.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Apr 2023 09:43:35 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: David Hildenbrand , Andrew Morton , Leonardo Bras Soares Passos , peterx@redhat.com, Andrea Arcangeli , Nadav Amit , Mike Rapoport , Axel Rasmussen , Mike Kravetz , Mike Rapoport Subject: [PATCH v2 18/31] selftests/mm: Drop global hpage_size in uffd tests Date: Wed, 12 Apr 2023 12:43:33 -0400 Message-Id: <20230412164333.328596-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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B9644140020 X-Stat-Signature: suupdhyxtx1diqdgen7b6xfrwjhobhha X-HE-Tag: 1681317819-527012 X-HE-Meta: U2FsdGVkX18Mn0/puOERw5afjuHVzkUhsIucW3s79nmS2JZSjoqMBepsBCsF012IErHEqUCtTCPjO94cwvQ15Filx8V0zjTrMu/y2BXZBgNvFNfGKFOy8r3K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TlnQ2vT0QAd2vxhGLrbr6q1Qb9HwC+x8FuM98Y4QFZJ7nCvQKhDrjv8wrosYuacB5zIPVIoRJ6NXLhwGi5UEuMpCdi15nzo2KF+7o/peCwtzmwFRAYaSiFKShy6eOFy4Nk4wjNtspBsFDqFmyyZ5ZFNM45GydFr4ECgo0l90i/Gl2QeA36nECQ9OfH+LKyx7eGG+0Zi9R3WQlEu9fHVZJwkP6+kgaxt6BxG8Kmdz4NAi0JRhmKVJMpegHGJv7rbbYkkLwP1RWfhrYVIDakfsgbSOwru6saUGH5EkbByjU+aMCz649vGh4W/bw8x7BTO7CDDveF+FcypPWAhCEudmlpTQLJXIOqGoFrYr9M3tz7FNU7GvKyKSdeYdSPR7Q+Z03Y= 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: hpage_size was wrongly used. Sometimes it means hugetlb default size, sometimes it was used as thp size. Remove the global variable and use the right one at each place. Reviewed-by: Mike Rapoport (IBM) Signed-off-by: Peter Xu --- tools/testing/selftests/mm/uffd-common.c | 7 ++++--- tools/testing/selftests/mm/uffd-common.h | 2 +- tools/testing/selftests/mm/uffd-stress.c | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-common.c b/tools/testing/selftests/mm/uffd-common.c index b1617f5d4517..f02dfcf10714 100644 --- a/tools/testing/selftests/mm/uffd-common.c +++ b/tools/testing/selftests/mm/uffd-common.c @@ -10,7 +10,7 @@ #define BASE_PMD_ADDR ((void *)(1UL << 30)) volatile bool test_uffdio_copy_eexist = true; -unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size, hpage_size; +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_collapse, test_dev_userfaultfd; @@ -115,7 +115,7 @@ static void shmem_release_pages(char *rel_area) static void shmem_allocate_area(void **alloc_area, bool is_src) { void *area_alias = NULL; - size_t bytes = nr_pages * page_size; + size_t bytes = nr_pages * page_size, hpage_size = read_pmd_pagesize(); unsigned long offset = is_src ? 0 : bytes; char *p = NULL, *p_alias = NULL; int mem_fd = uffd_mem_fd_create(bytes * 2, false); @@ -159,7 +159,8 @@ static void shmem_alias_mapping(__u64 *start, size_t len, unsigned long offset) static void shmem_check_pmd_mapping(void *p, int expect_nr_hpages) { - if (!check_huge_shmem(area_dst_alias, expect_nr_hpages, hpage_size)) + if (!check_huge_shmem(area_dst_alias, expect_nr_hpages, + read_pmd_pagesize())) err("Did not find expected %d number of hugepages", expect_nr_hpages); } diff --git a/tools/testing/selftests/mm/uffd-common.h b/tools/testing/selftests/mm/uffd-common.h index 0dfab7057295..47565b2f2dee 100644 --- a/tools/testing/selftests/mm/uffd-common.h +++ b/tools/testing/selftests/mm/uffd-common.h @@ -85,7 +85,7 @@ struct uffd_test_ops { }; typedef struct uffd_test_ops uffd_test_ops_t; -extern unsigned long nr_cpus, nr_pages, nr_pages_per_cpu, page_size, hpage_size; +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_collapse, test_dev_userfaultfd; diff --git a/tools/testing/selftests/mm/uffd-stress.c b/tools/testing/selftests/mm/uffd-stress.c index 4eca1a0276c2..54fc9b4ffa3c 100644 --- a/tools/testing/selftests/mm/uffd-stress.c +++ b/tools/testing/selftests/mm/uffd-stress.c @@ -655,7 +655,7 @@ static int userfaultfd_minor_test(void) uffd_test_ops->check_pmd_mapping(area_dst, nr_pages * page_size / - hpage_size); + read_pmd_pagesize()); /* * This won't cause uffd-fault - it purely just makes sure there * was no corruption. @@ -997,7 +997,7 @@ static void parse_test_type_arg(const char *raw_type) err("Unsupported test: %s", raw_type); if (test_type == TEST_HUGETLB) - page_size = hpage_size; + page_size = default_huge_page_size(); else page_size = sysconf(_SC_PAGE_SIZE); @@ -1035,6 +1035,7 @@ static void sigalrm(int sig) int main(int argc, char **argv) { size_t bytes; + size_t hpage_size = read_pmd_pagesize(); if (argc < 4) usage(); @@ -1043,7 +1044,6 @@ int main(int argc, char **argv) err("failed to arm SIGALRM"); alarm(ALARM_INTERVAL_SECS); - hpage_size = default_huge_page_size(); parse_test_type_arg(argv[1]); bytes = atol(argv[2]) * 1024 * 1024;