From patchwork Thu Mar 30 16:08:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13194500 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 5DD28C6FD1D for ; Thu, 30 Mar 2023 16:08:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E91A3900002; Thu, 30 Mar 2023 12:08:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E42C06B009C; Thu, 30 Mar 2023 12:08:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CE32C900002; Thu, 30 Mar 2023 12:08:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id BAF946B009B for ; Thu, 30 Mar 2023 12:08:17 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 99F91161033 for ; Thu, 30 Mar 2023 16:08:17 +0000 (UTC) X-FDA: 80626046634.06.626D3ED Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 782001A0026 for ; Thu, 30 Mar 2023 16:08:15 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AxuCaBAB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.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=1680192495; 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=gA0z3fLtS/53pi31HkFC8RYwaDcusvVg7bMc/ulU8j0=; b=zvfzqIUqeBS9qysxMEqr6vWuUekH0m+W8ZsUzF+gv0Rfucx09IyCnhr+lIfLQifpyhOGq1 gdOqY2VPVaYrXrUMOnp911GBupumc+qQ+JNOjBjbn46Ptz1/RF0+dwLIKPEf0xOV3zkMAr FYuvx/UUJJ3cumvPlwf3cVZhbjd8AVQ= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AxuCaBAB; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680192495; a=rsa-sha256; cv=none; b=2OUlWNWLmz7+H43yY6SmRaKJ/t5vNSc4t7NuagCUbix/fb/nV1gmsiSyBrTDPXmqkKg4CN 3DNhx2J9CKwkw6wPFxFcfTfmGfJgQzDF7AW6jU6jlvsg18XQiyc6vn+9br/BmyuC5Ng42y Eu5iMt0Onlmo0ovsrFLWMNxG3YgJbxA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680192494; 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=gA0z3fLtS/53pi31HkFC8RYwaDcusvVg7bMc/ulU8j0=; b=AxuCaBABBpTe0taGzseR/d94Ps8EW2+Dh+ipA8CNLNBu0EZyNVNyoUkcU/rxSYjBo/sQyL AOwC/rME7LUW0zhbBrSt2nDkVYHu5Pu5tWU3eeRbqZxSchc4d6P9swoYcS+Sy47MUkDyBf eFDE4En6KAhvN9jH6TXMVS+5nkgi8hI= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-L64jRtaUPPuQ4Ta872ob4A-1; Thu, 30 Mar 2023 12:08:13 -0400 X-MC-Unique: L64jRtaUPPuQ4Ta872ob4A-1 Received: by mail-qv1-f70.google.com with SMTP id 6a1803df08f44-57c67ea348eso12978056d6.1 for ; Thu, 30 Mar 2023 09:08:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680192492; 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=gA0z3fLtS/53pi31HkFC8RYwaDcusvVg7bMc/ulU8j0=; b=2m4GqaP1mK9ywDqHl++KbGs3IOnuKAySlXsyJA5CGMR08gvDsZGLiPamNCY2e7Ocu6 5OIBG3VjCdk7pUAVoewB5Pz23gRSVD2s1PyMIHqjzAzl4V7fLAv2iPw/e1nlBZ+QQvJf bg9eEacsaIsIU1vTqQsib+jSjXbpoV77/fGb82n3xwalW/jo0nSl7tf5B5nCRp0FVjXR D8ymyMBeYYX5Y1YyzasCevJmSXPqD/bSRuid/p2nf49EisB4CEazczg+28Str6mTaVDF 3qH5MQvi3FHsdd2KNXkfMw2P/Aujqvn7EhwlFUxx9KpI1AIgd7X4p2rsPUQR8jFW/5JZ PsEw== X-Gm-Message-State: AAQBX9eJ0xd+NzQS8xJA59RIpZvkWDQ/j7dIQMKGhPvDOXlKgMzDc+Fb OVRUoTbq4pAujfIXWdRDMSSBGg43hnWaumOKxqEbI8FgeZcs09frvuecX+mT0/sgZF8cX4ZE06F XzWrharMeq5PvXhOL298= X-Received: by 2002:a05:6214:d0c:b0:5df:a693:39e with SMTP id 12-20020a0562140d0c00b005dfa693039emr3572744qvh.5.1680192492171; Thu, 30 Mar 2023 09:08:12 -0700 (PDT) X-Google-Smtp-Source: AKy350a31IcuGsNWlBkf8cNmNuBl6n8qJKAWJr7SjOPxGZusPrloFA/ON2e0syMszVgcE7KnbiFCxQ== X-Received: by 2002:a05:6214:d0c:b0:5df:a693:39e with SMTP id 12-20020a0562140d0c00b005dfa693039emr3572696qvh.5.1680192491770; Thu, 30 Mar 2023 09:08:11 -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 mk5-20020a056214580500b005dd8b93459csm5534560qvb.52.2023.03.30.09.08.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 09:08:10 -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 18/29] selftests/mm: Drop global hpage_size in uffd tests Date: Thu, 30 Mar 2023 12:08:09 -0400 Message-Id: <20230330160809.3107511-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 782001A0026 X-Stat-Signature: 977x78cdjkbhs98cks551o5ixci9hz1d X-HE-Tag: 1680192495-524672 X-HE-Meta: U2FsdGVkX18Ivc+48TVQedOZvdUC63dm21xwVmuylO13mDg3ObQpgwowGv+Jb5kyYjKX4vZirEuaMBK4wnIqrLiKTEmM7VNVWhX5O7OjHYcgXuq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dwD04la72vqlynRdJ8XyLrZh/kKQ0e/8VfZkRxiuUgE4dT9p83O5nbeA2ZmefqNewgki7tOFtVq8kOqVEpW9wb/l+IBs+8q/HpbzIUFFfarv2tvEiEV4HI9520Cv1qS4VTg3zmWItKaMzu+oytOgPX2Dh3HdGoeMGbSh9U7NUD0bwGXj7kQw5oTiYbg7VH2xzaRZHOf+RB0G79Qw7yxd83MKh+S8VmxJhVjWIA6BfcHHQFpwqnc3B3DUshCfu8YmWYmVs3VNqJ9HbtfG4GBQ/37pSW7O9uFZu8NzaJrPvHdvqD61GZE7zRJQjRa45Hvu5yc1Hzom0= 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. Signed-off-by: Peter Xu Reviewed-by: Mike Rapoport (IBM) --- 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 a2b6e4957d0f..025e40ffc7bf 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;