]> www.infradead.org Git - users/jedix/linux-maple.git/commit
selftests/mm: use asm volatile to not optimize mmap read variable
authorPankaj Raghav <p.raghav@samsung.com>
Thu, 6 Jun 2024 20:36:19 +0000 (20:36 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 02:30:07 +0000 (19:30 -0700)
commitecc1793b2d08efeb2d1795814d2ea350c9d6992b
tree84425627831c710c6dcc980e4939a8004ac058c8
parent20dfa5b7adc5a1f8b5b7ff9b014d0bd1845c990b
selftests/mm: use asm volatile to not optimize mmap read variable

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.

Link: https://lkml.kernel.org/r/20240606203619.677276-1-kernel@pankajraghav.com
Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
tools/testing/selftests/mm/split_huge_page_test.c