The patch titled Subject: selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2 has been added to the -mm mm-unstable branch. Its filename is selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Donet Tom <donettom@xxxxxxxxxxxxx> Subject: selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2 Date: Tue, 4 Jun 2024 08:28:01 -0500 address review comments from Muhammad Link: https://lkml.kernel.org/r/20240604132801.23377-1-donettom@xxxxxxxxxxxxx Signed-off-by: Donet Tom <donettom@xxxxxxxxxxxxx> Co-developed-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx> Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@xxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Jens Axboe <axboe@xxxxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Mike Rapoport (IBM) <rppt@xxxxxxxxxx> Cc: Muchun Song <songmuchun@xxxxxxxxxxxxx> Cc: Shuah Khan <shuah@xxxxxxxxxx> Cc: Tony Battersby <tonyb@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- tools/testing/selftests/mm/hugetlb_dio.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) --- a/tools/testing/selftests/mm/hugetlb_dio.c~selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2 +++ a/tools/testing/selftests/mm/hugetlb_dio.c @@ -29,6 +29,8 @@ void run_dio_using_hugetlb(unsigned int size_t writesize; int free_hpage_b = 0; int free_hpage_a = 0; + const int mmap_flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB; + const int mmap_prot = PROT_READ | PROT_WRITE; writesize = end_off - start_off; @@ -40,7 +42,7 @@ void run_dio_using_hugetlb(unsigned int /* Open the file to DIO */ fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT); if (fd < 0) - ksft_exit_fail_msg("Error opening file"); + ksft_exit_fail_perror("Error opening file\n"); /* Get the free huge pages before allocation */ free_hpage_b = get_free_hugepages(); @@ -50,11 +52,10 @@ void run_dio_using_hugetlb(unsigned int } /* Allocate a hugetlb page */ - orig_buffer = mmap(NULL, h_pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE - | MAP_ANONYMOUS | MAP_HUGETLB, -1, 0); + orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer == MAP_FAILED) { close(fd); - ksft_exit_fail_msg("Error mapping memory"); + ksft_exit_fail_perror("Error mapping memory\n"); } buffer = orig_buffer; buffer += start_off; @@ -65,7 +66,7 @@ void run_dio_using_hugetlb(unsigned int if (write(fd, buffer, writesize) != (writesize)) { munmap(orig_buffer, h_pagesize); close(fd); - ksft_exit_fail_msg("Error writing to file"); + ksft_exit_fail_perror("Error writing to file\n"); } /* unmap the huge page */ @@ -80,12 +81,12 @@ void run_dio_using_hugetlb(unsigned int * not match - that means there could still be a page which is pinned. */ if (free_hpage_a != free_hpage_b) { - printf("No. Free pages before allocation : %d\n", free_hpage_b); - printf("No. Free pages after munmap : %d\n", free_hpage_a); + ksft_print_msg("No. Free pages before allocation : %d\n", free_hpage_b); + ksft_print_msg("No. Free pages after munmap : %d\n", free_hpage_a); ksft_test_result_fail(": Huge pages not freed!\n"); } else { - printf("No. Free pages before allocation : %d\n", free_hpage_b); - printf("No. Free pages after munmap : %d\n", free_hpage_a); + ksft_print_msg("No. Free pages before allocation : %d\n", free_hpage_b); + ksft_print_msg("No. Free pages after munmap : %d\n", free_hpage_a); ksft_test_result_pass(": Huge pages freed successfully !\n"); } } @@ -113,6 +114,5 @@ int main(void) run_dio_using_hugetlb(pagesize / 2, (pagesize * 3) + (pagesize / 2)); ksft_finished(); - return 0; } _ Patches currently in -mm which might be from donettom@xxxxxxxxxxxxx are selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages.patch selftest-mm-test-if-hugepage-does-not-get-leaked-during-__bio_release_pages-v2.patch