From mboxrd@z Thu Jan 1 00:00:00 1970 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 DEA16CD1288 for ; Wed, 3 Apr 2024 11:04:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 79B576B0089; Wed, 3 Apr 2024 07:04:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 74A866B008A; Wed, 3 Apr 2024 07:04:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EA976B008C; Wed, 3 Apr 2024 07:04:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3FC416B0089 for ; Wed, 3 Apr 2024 07:04:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DA09AA0E0B for ; Wed, 3 Apr 2024 11:04:05 +0000 (UTC) X-FDA: 81967936050.23.7017AAA Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf22.hostedemail.com (Postfix) with ESMTP id DDCDEC0020 for ; Wed, 3 Apr 2024 11:04:03 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712142244; 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; bh=Umcsaowphf6CEhLw+DzPLcw0v4pjWkVCHL5JMILAei0=; b=AxYf313ZLpywGTgW81lQ3MPJsiBshlG8UJX7ED8abOzjvBo+VtZFx6V08QrZPUDBXiR/c6 lJxsyyHEpzAKz2OoyuLTsNdIKbisFz2adm4QSie3U2/AlOBlyLCbJCKZ/9o41NjXdBqXG+ JyrLnqeY1/MoJJIygRkQzNHTHhSVMrc= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf22.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712142244; a=rsa-sha256; cv=none; b=FAVqRP1ppmI/5w3o1Q/JU7ECotH3EbFk8umjvrxatkon3wratDHnMZTQJeDBeetQDj3w8q not3f8PoYpBhRIpiMqfB0ZqaVzT/kK3Fpch4of3/Z3YMN+4NLLT6wEid3luXU/fKu8iueo V+P1ZQBWewG2sA3lnkZIkb9MUIFXmbU= 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 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 X-Rspamd-Queue-Id: DDCDEC0020 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fmid11goq7z8ex1pgrh9q9fcbosteubb X-HE-Tag: 1712142243-612215 X-HE-Meta: U2FsdGVkX18fgJuWPZajqKH71xpxrOALZEbFwhDzr9FG3LNBQM5oy4dRQMPtwD9z7x13wCfCnzpqi68EHS0o4bGKK1Ur4IUGHyhnMGusEtP2xqyW0MF2r321Dj2Fna6RAL04sY4gR1WQEp6DiD5Nir/BtO7NeID5Di1pB0WG40lMMjHqBBh4zEJttcuTgzICSoM5gtRYQ7cAQzElxm8x7ZdeVWFXm1g0j3LYHgeHRFkDdzxMVxWbsu4MgtUUk+p4ypSh+CarXFy3QKxkPgxKg45NKK+SHxSdF/VwgGtRQLeLk8q6/r88/X0UL1bOntlpQbNG0kKeU8Cn0I1zgZtQyCDhsZ6BoDP3e6JcJE1kX0uOI2PppAAsuWev+VbulrRsw5/6hGzM7AQrrnCBreThZ4z8RscS1oE3GLNmLQLm9X9FKgy4ARANPD50NwQO7Vx1OMfrkY4TeCODTTeRSqirpqnZFwBCiMIln/3ca0SCPu18Hs5n/TeVYK2yomATBXuIbHgfitcZ01l99TuhOE9K80na97J9qG4V3tyo7wPuySrR3wJFew2Tx9fkR50T6oNj5A6ohvY2JwFJQBLqDNPTFHI7FIIF/1TujAVn/ig086Y4qixdgN+FBhPOo3VX4e6GpuZYXG/X/3q+SbSPXJqBu84iQaZQ6IINWbpdp4Sjt9MYKaV4hC+YhQYQAbnN9K2bzo3/L4TJu3Rtazpcxzma/8hD+VSdqxZ54WFn5v50Asgyi5cquTaGXsTl/4GhiUi3W97z8BwPgHrQbagZJZ5uRvGodJ/3U2fpZdmVNMp6e+jrX7j2mHygyrvYW+yWUsxwFvCx6ZyNcV/bwT84HIElH3E++Gu+nqqiNBcKirbpREudgwEJaM9QUlG3JMnhRg70RXxFnzBq89IcM8RqdlK2jjB+ayeBbRI+Pqvv7aaZxIugWJsYQDSuuQfk7aC9ExYymhrjOl6iLHzLklxu4kL NtTtU+qR 9usnQ7/wMoMdU+WrJMdzKNumJ5mItw90md4Wy3Nf2PVqnSchr3zWsmhbLzp3DFWgEAyJ6ZaWxKdoo1NCLfuRIKavi7OC8fvnpSm/cemGZUjZWgRtb7ovtfoq/dhVYacp3Iviea7G0uRQLC7YS8hQO3ZI8epBNuJntWddHnpRRftE1TMSvfp7tB3UtecC3rVzBeuoW+wN0JgYovsattCVusopBtxW2OryF8wo/8U6o9GRKeLumpylufI6VolVhLuuKrdhUPACku4mqbVlxG2mxE0p6RQ== 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: List-Subscribe: List-Unsubscribe: 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