lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <172b608c-ce59-4096-b5b0-d403eb772c85@redhat.com>
Date: Thu, 6 Jun 2024 23:09:04 +0200
From: David Hildenbrand <david@...hat.com>
To: "Pankaj Raghav (Samsung)" <kernel@...kajraghav.com>,
 Andrew Morton <akpm@...ux-foundation.org>, Shuah Khan <shuah@...nel.org>
Cc: linux-mm@...ck.org, gost.dev@...sung.com, willy@...radead.org,
 mcgrof@...nel.org, linux-kselftest@...r.kernel.org,
 linux-kernel@...r.kernel.org, Zi Yan <zi.yan@...t.com>,
 Pankaj Raghav <p.raghav@...sung.com>
Subject: Re: [PATCH v3] selftests/mm: use asm volatile to not optimize mmap
 read variable

On 06.06.24 22:36, Pankaj Raghav (Samsung) wrote:
> From: Pankaj Raghav <p.raghav@...sung.com>
> 
> create_pagecache_thp_and_fd() in split_huge_page_test.c used the
> variable dummy to perform mmap read.
> 
> However, this test was skipped even on XFS which has large folio
> support. The issue was compiler (gcc 13.2.0) was optimizing out the
> dummy variable, therefore, not creating huge page in the page cache.
> 
> Use asm volatile() trick to force the compiler not to optimize out
> the loop where we read from the mmaped addr. This is similar to what is
> being done in other tests (cow.c, etc)
> 
> As the variable is now used in the asm statement, remove the unused
> attribute.
> 
> Signed-off-by: Pankaj Raghav <p.raghav@...sung.com>
> ---
> Changes since v2:
> - Use the asm volatile trick to force the compiler to not optimize the
>    read into dummy variable. (David)
> 
>   tools/testing/selftests/mm/split_huge_page_test.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index d3c7f5fb3e7b..e5e8dafc9d94 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -300,7 +300,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd,
>   		char **addr)
>   {
>   	size_t i;
> -	int __attribute__((unused)) dummy = 0;
> +	int dummy = 0;
>   
>   	srand(time(NULL));
>   
> @@ -341,6 +341,7 @@ int create_pagecache_thp_and_fd(const char *testfile, size_t fd_size, int *fd,
>   
>   	for (size_t i = 0; i < fd_size; i++)
>   		dummy += *(*addr + i);
> +	asm volatile("" : "+r" (dummy));
>   
>   	if (!check_huge_file(*addr, fd_size / pmd_pagesize, pmd_pagesize)) {
>   		ksft_print_msg("No large pagecache folio generated, please provide a filesystem supporting large folio\n");
> 
> base-commit: d97496ca23a2d4ee80b7302849404859d9058bcd

Acked-by: David Hildenbrand <david@...hat.com>

I was wondering if we should factor that out into a mm-selftest helper 
function, but that can be done later.

-- 
Cheers,

David / dhildenb


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ