Skip to content

Commit e2c791f

Browse files
Muhammad Usama Anjumgregkh
authored andcommitted
selftests: hugetlb_dio: check for initial conditions to skip in the start
commit 0268d45 upstream. The test should be skipped if initial conditions aren't fulfilled in the start instead of failing and outputting non-compliant TAP logs. This kind of failure pollutes the results. The initial conditions are: - The test should only execute if /tmp file can be allocated. - The test should only execute if huge pages are free. Before: TAP version 13 1..4 Bail out! Error opening file : Read-only file system (30) # Planned tests != run tests (4 != 0) # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:0 error:0 After: TAP version 13 1..0 # SKIP Unable to allocate file: Read-only file system Link: https://lkml.kernel.org/r/20241101141557.3159432-1-usama.anjum@collabora.com Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com> Fixes: 3a103b5 ("selftest: mm: Test if hugepage does not get leaked during __bio_release_pages()") Cc: Muhammad Usama Anjum <usama.anjum@collabora.com> Cc: Shuah Khan <shuah@kernel.org> Cc: Donet Tom <donettom@linux.ibm.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 30fe6b1 commit e2c791f

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

tools/testing/selftests/mm/hugetlb_dio.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)
4444
if (fd < 0)
4545
ksft_exit_fail_perror("Error opening file\n");
4646

47-
/* Get the free huge pages before allocation */
48-
free_hpage_b = get_free_hugepages();
49-
if (free_hpage_b == 0) {
50-
close(fd);
51-
ksft_exit_skip("No free hugepage, exiting!\n");
52-
}
53-
5447
/* Allocate a hugetlb page */
5548
orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);
5649
if (orig_buffer == MAP_FAILED) {
@@ -94,8 +87,20 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)
9487
int main(void)
9588
{
9689
size_t pagesize = 0;
90+
int fd;
9791

9892
ksft_print_header();
93+
94+
/* Open the file to DIO */
95+
fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664);
96+
if (fd < 0)
97+
ksft_exit_skip("Unable to allocate file: %s\n", strerror(errno));
98+
close(fd);
99+
100+
/* Check if huge pages are free */
101+
if (!get_free_hugepages())
102+
ksft_exit_skip("No free hugepage, exiting\n");
103+
99104
ksft_set_plan(4);
100105

101106
/* Get base page size */

0 commit comments

Comments
 (0)