linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/mm: use volatile keyword to not optimize mmap read variable
@ 2024-06-06 13:58 Pankaj Raghav (Samsung)
  2024-06-06 14:21 ` Zi Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Pankaj Raghav (Samsung) @ 2024-06-06 13:58 UTC (permalink / raw)
  To: Shuah Khan, Andrew Morton
  Cc: willy, linux-kernel, linux-mm, kernel, gost.dev, mcgrof,
	linux-kselftest, Zi Yan, Pankaj Raghav

From: Pankaj Raghav <p.raghav@samsung.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.

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@samsung.com>
---
 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
-- 
2.44.1



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-06-06 20:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06 13:58 [PATCH] selftests/mm: use volatile keyword to not optimize mmap read variable Pankaj Raghav (Samsung)
2024-06-06 14:21 ` Zi Yan
2024-06-06 14:35 ` Matthew Wilcox
2024-06-06 15:19   ` Zi Yan
2024-06-06 15:28   ` Pankaj Raghav (Samsung)
2024-06-06 15:56 ` David Hildenbrand
2024-06-06 15:57   ` David Hildenbrand
2024-06-06 20:18     ` Pankaj Raghav (Samsung)
2024-06-06 20:21       ` David Hildenbrand
2024-06-06 20:30         ` Pankaj Raghav (Samsung)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox