Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2626319lqz; Wed, 3 Apr 2024 04:04:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVE5gvRVOT3UQR17Lw7DxxDTLeAmOAKiAKEXjqIrgsGbttx1R8zv8Hy88UFvPopgUlDG1oJcN39BT3zdPLEC4JIOZNo5gqat3O9xbXAmQ== X-Google-Smtp-Source: AGHT+IG6DJU3B5KSAvSSBeRTq5DcM9Gp/cS9/cUKUHd/yg+81Wi6D6flKH8f2r1AxBCxlLao1bik X-Received: by 2002:a50:950b:0:b0:56b:a7b0:bbc with SMTP id u11-20020a50950b000000b0056ba7b00bbcmr9583759eda.22.1712142262537; Wed, 03 Apr 2024 04:04:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712142262; cv=pass; d=google.com; s=arc-20160816; b=wh2lLdVT8wOtkL5iZfsewe1892soFwuSxcGTSwFFas2QE627br2KV/D4Tr/HfGtfpF 2CxqvNpSeuSsbH0w45q3r9yoW99lv9NXSNM4DXPNCFkviTljjLkgqrmxZv6w8a95ised YYL/bTZxTrjy8g0LIW2pEsLdg+l5DWigV50cV1k0BCF/88shMH+rJJWsmifd/1V8LbnT NbE2aW5nKYR/JDcCWF8pBfU+QEFb2ACPHInQpl+HcBuIeJPZu3uIfOuypziZ7EhSMy4P cpZ3u26baCqw+J54wyh6/v+NNumjSFm5Usvk0sb8J1+qbXNk/u+UA/Pv8K/v+wh8/N+w QKtw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=Umcsaowphf6CEhLw+DzPLcw0v4pjWkVCHL5JMILAei0=; fh=+WMwJ4fagAzGQPUZcEiyjwt6P5r60dlpY1J4ZvSeVqA=; b=TiD007tTg25cu/NuAogaF51tHFcrLtj4Q2PRg3Zj0sptyaEOemMF7do+NtId18EktI hVm+csRDsWgKOYidTovh8BYIxb8xOP3fEqg40IwbLFlZ2rPIpTwFX93bZQrpgs72bLM4 uL0u8wl101rgw7jYh9RTlE8LaDzuLpr1tpSlftXf7wJsReUdfy2Y4zyG3Ta9TZ9w98fA 896OYaCBUl4JS34Il+1RkB6LT5SCDTdo4pTCvI7+OARGSorRb+p7tdem6tuw6aHw1Owu ZZvWmnfgiEd8hAarHuso1wxwy0maA9HnearbjLRXqNGK0PzkvPgUCUwPyudmEVITc/3S 7U9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-129634-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id m2-20020a50c182000000b00568386368c5si6564968edf.690.2024.04.03.04.04.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 04:04:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129634-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-129634-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129634-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 343A51F2729C for ; Wed, 3 Apr 2024 11:04:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BC5BF1411F2; Wed, 3 Apr 2024 11:04:09 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D6CB135A5F for ; Wed, 3 Apr 2024 11:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712142249; cv=none; b=cbFMQnRd4AC7lIZ4H6y8jjkhBArcNKzm6BIz3IJUvWhN00Ebk6y9BgB3yvONLd6QRll7hBaBSRe/N45OR0Q35W0Uwj9nmMxxn6RbTYevQ4J/TXTZsQG1j2A5ZnWHI5uctAvoWa8vIkPsMVUdwlbWnmXQjGEn4J1PnkRGMZZm6+U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712142249; c=relaxed/simple; bh=BbwddR6/RNAakXtOlCpMOZ9Mx5a16dbieqopNhfP2qQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=TlbfEBH327lNZC90EVNqiwF2wWHRFy5+Yudd5ereKdW/DZgKQP4VP7osBdZO2m6zdpxI96fPGYSyHKAFuteOBgelD+S1ggI4uPBglXvPdjVYn+Xw/JjDtRZpX5+6cNbZ1TeqnwJPg8FulTtGRhic4t/ZrJ96Bm+bsBfX+vuMt30= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 03A461007; Wed, 3 Apr 2024 04:04:34 -0700 (PDT) Received: from [10.57.72.245] (unknown [10.57.72.245]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB7543F64C; Wed, 3 Apr 2024 04:04:01 -0700 (PDT) Message-ID: <1c20b717-c5b5-4bdf-8fcd-d46db135b7fa@arm.com> Date: Wed, 3 Apr 2024 12:04:00 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] selftests/mm: run_vmtests.sh: Fix hugetlb mem size calculation Content-Language: en-GB To: peterx@redhat.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Andrew Morton , Muhammad Usama Anjum , David Hildenbrand , Nico Pache , Muchun Song References: <20240321215047.678172-1-peterx@redhat.com> From: Ryan Roberts In-Reply-To: <20240321215047.678172-1-peterx@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Peter, On 21/03/2024 21:50, peterx@redhat.com wrote: > From: Peter Xu > > The script calculates a mininum required size of hugetlb memories, but > it'll stop working with <1MB huge page sizes, reporting all zeros even if > huge pages are available. > > In reality, the calculation doesn't really need to be as comlicated either. > Make it simpler and work for KB-level hugepages too. > > Cc: Muhammad Usama Anjum > Cc: David Hildenbrand > Cc: Nico Pache > Cc: Muchun Song > Signed-off-by: Peter Xu > --- > tools/testing/selftests/mm/run_vmtests.sh | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/mm/run_vmtests.sh b/tools/testing/selftests/mm/run_vmtests.sh > index c2c542fe7b17..b1b78e45d613 100755 > --- a/tools/testing/selftests/mm/run_vmtests.sh > +++ b/tools/testing/selftests/mm/run_vmtests.sh > @@ -152,9 +152,13 @@ done < /proc/meminfo > # both of these requirements into account and attempt to increase > # number of huge pages available. > nr_cpus=$(nproc) > -hpgsize_MB=$((hpgsize_KB / 1024)) > -half_ufd_size_MB=$((((nr_cpus * hpgsize_MB + 127) / 128) * 128)) Removing this has broken the uffd-stress "hugetlb" and "hugetlb-private" tests (further down the file), which rely on $half_ufd_size_MB. Now that this is not defined, they are called with too few params: # # --------------------------------- # # running ./uffd-stress hugetlb 32 # # --------------------------------- # # ERROR: invalid MiB (errno=0, @uffd-stress.c:454) # # # # Usage: ./uffd-stress # # # # Supported : anon, hugetlb, hugetlb-private, shmem, shmem-private # # # # Examples: # # # # # Run anonymous memory test on 100MiB region with 99999 bounces: # # ./uffd-stress anon 100 99999 # # # # # Run share memory test on 1GiB region with 99 bounces: # # ./uffd-stress shmem 1000 99 # # # # # Run hugetlb memory test on 256MiB region with 50 bounces: # # ./uffd-stress hugetlb 256 50 # # # # # Run the same hugetlb test but using private file: # # ./uffd-stress hugetlb-private 256 50 # # # # # 10MiB-~6GiB 999 bounces anonymous test, continue forever unless an error triggers # # while ./uffd-stress anon $[RANDOM % 6000 + 10] 999; do true; done # # # # [FAIL] # not ok 16 uffd-stress hugetlb 32 # exit=1 # # ----------------------------------------- # # running ./uffd-stress hugetlb-private 32 # # ----------------------------------------- # # ERROR: invalid MiB (errno=0, @uffd-stress.c:454) # # # # Usage: ./uffd-stress # # # # Supported : anon, hugetlb, hugetlb-private, shmem, shmem-private # # # # Examples: # # # # # Run anonymous memory test on 100MiB region with 99999 bounces: # # ./uffd-stress anon 100 99999 # # # # # Run share memory test on 1GiB region with 99 bounces: # # ./uffd-stress shmem 1000 99 # # # # # Run hugetlb memory test on 256MiB region with 50 bounces: # # ./uffd-stress hugetlb 256 50 # # # # # Run the same hugetlb test but using private file: # # ./uffd-stress hugetlb-private 256 50 # # # # # 10MiB-~6GiB 999 bounces anonymous test, continue forever unless an error triggers # # while ./uffd-stress anon $[RANDOM % 6000 + 10] 999; do true; done # # # # [FAIL] # not ok 17 uffd-stress hugetlb-private 32 # exit=1 Thanks, Ryan > -needmem_KB=$((half_ufd_size_MB * 2 * 1024)) > +uffd_min_KB=$((hpgsize_KB * nr_cpus * 2)) > +hugetlb_min_KB=$((256 * 1024)) > +if [[ $uffd_min_KB -gt $hugetlb_min_KB ]]; then > + needmem_KB=$uffd_min_KB > +else > + needmem_KB=$hugetlb_min_KB > +fi > > # set proper nr_hugepages > if [ -n "$freepgs" ] && [ -n "$hpgsize_KB" ]; then