Re: [PATCH] selftests/mm: use volatile keyword to not optimize mmap read variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 06.06.24 17:56, David Hildenbrand wrote:
On 06.06.24 15:58, Pankaj Raghav (Samsung) wrote:
From: Pankaj Raghav <p.raghav@xxxxxxxxxxx>

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.

Add volatile keyword to force compiler not to optimize out the loop
where we read from the mmaped addr.

Signed-off-by: Pankaj Raghav <p.raghav@xxxxxxxxxxx>
---
   tools/testing/selftests/mm/split_huge_page_test.c | 2 +-
   1 file changed, 1 insertion(+), 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..c573a58f80ab 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;
+	volatile int __attribute__((unused)) dummy = 0;
srand(time(NULL));
base-commit: d97496ca23a2d4ee80b7302849404859d9058bcd

The rick we do in some other tests is:

char *tmp;

tmp = *whatever;
asm volatile("" : "+r" (tmp));

char tmp; of course. See cow.c as an example.

--
Cheers,

David / dhildenb





[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux