selftests: hugetlb_dio: Check for initial conditions to skip in the start
Subsystems (3)
PATCH 1/1 selftests: hugetlb_dio: Check for initial conditions to skip in the start
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
--- tools/testing/selftests/mm/hugetlb_dio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)
tools/testing/selftests/mm/hugetlb_dio.c +12 -7
@@ -44,13 +44,6 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd <0 )ksft_exit_fail_perror ("Error opening file\n" ); -/* Get the free huge pages before allocation */ - free_hpage_b =get_free_hugepages (); -if (free_hpage_b ==0 ) { -close (fd); -ksft_exit_skip ("No free hugepage, exiting!\n" ); - } -/* Allocate a hugetlb page */ orig_buffer =mmap (NULL , h_pagesize, mmap_prot, mmap_flags,-1 ,0 );if (orig_buffer ==MAP_FAILED ) {
@@ -94,8 +87,20 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)int main (void ) {size_t pagesize =0 ; +int fd;ksft_print_header (); + +/* Open the file to DIO */ + fd =open ("/tmp" ,O_TMPFILE |O_RDWR |O_DIRECT ,0664 ); +if (fd <0 ) +ksft_exit_skip ("Unable to allocate file: %s\n" ,strerror (errno)); +close (fd); + +/* Check if huge pages are free */ +if (!get_free_hugepages ()) +ksft_exit_skip ("No free hugepage, exiting\n" ); +ksft_set_plan (4 );/* Get base page size */
Signature · 1 line
2.39.5
Andrew Morton
maintainerQuoted 5 lines · On Fri, 1 Nov 2024 19:15:57 +0500 Muhammad Usama Anjum…
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.
Cc Donet Tom.
I added
Quoted 9 lines
---
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
Quoted 4 lines
After:
TAP version 13
1..0 # SKIP Unable to allocate file: Read-only file system
---
And I moved this useful information to the changelog.
Quoted 28 lines · Muhammad Usama Anjum
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.Signed-off-by Muhammad Usama Anjum <[email protected]>---
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:0After:
TAP version 13
1..0 # SKIP Unable to allocate file: Read-only file system--- tools/testing/selftests/mm/hugetlb_dio.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-)tools/testing/selftests/mm/hugetlb_dio.c +0
-0
tools/testing/selftests/mm/hugetlb_dio.c void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) · line 48
Quoted 5 lines
tools/testing/selftests/mm/hugetlb_dio.c +0
-2@@ -44,13 +44,6 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd <0 )ksft_exit_fail_perror ("Error opening file\n" ); -/* Get the free huge pages before allocation */ - free_hpage_b =get_free_hugepages ();
Hi Muhammed Usman Anjum
Reading the free pages is required before starting the test. This value will be compared to the free pages after the test. If they are not the same, the test will be considered a failure.
Since reading the free pages before the test was removed,|free_hpage_b| is always 0, causing the test to fail.
./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 1 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 3 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0 I think below changes are required. --- a/tools/testing/selftests/mm/hugetlb_dio.c +++ b/tools/testing/selftests/mm/hugetlb_dio.c @@ -44,6 +44,9 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n"); + /* Get the free huge pages before allocation */ + free_hpage_b = get_free_hugepages(); + /* Allocate a hugetlb page */ orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer == MAP_FAILED) { With this change the tests are passing. ./tools/testing/selftests/mm/hugetlb_dio TAP version 13 1..4 # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 1 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 2 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 3 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 4 : Huge pages freed successfully ! # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0 Thank
Donet
Quoted 29 lines
tools/testing/selftests/mm/hugetlb_dio.c +12
-5-if (free_hpage_b ==0 ) { -close (fd); -ksft_exit_skip ("No free hugepage, exiting!\n" ); - } -/* Allocate a hugetlb page */ orig_buffer =mmap (NULL , h_pagesize, mmap_prot, mmap_flags,-1 ,0 );if (orig_buffer ==MAP_FAILED ) {@@ -94,8 +87,20 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)int main (void ) {size_t pagesize =0 ; +int fd;ksft_print_header (); + +/* Open the file to DIO */ + fd =open ("/tmp" ,O_TMPFILE |O_RDWR |O_DIRECT ,0664 ); +if (fd <0 ) +ksft_exit_skip ("Unable to allocate file: %s\n" ,strerror (errno)); +close (fd); + +/* Check if huge pages are free */ +if (!get_free_hugepages ()) +ksft_exit_skip ("No free hugepage, exiting\n" ); +ksft_set_plan (4 );/* Get base page size */
Quoted 38 lines · Donet Tom
Quoted 31 lines · Muhammad Usama Anjum
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.Signed-off-by Muhammad Usama Anjum <[email protected]>---
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:0After:
TAP version 13
1..0 # SKIP Unable to allocate file: Read-only file system
---
tools/testing/selftests/mm/hugetlb_dio.c| 19 ++++++++++++-------1 file changed, 12 insertions(+), 7 deletions(-)tools/testing/selftests/mm/hugetlb_dio.c +0
-0@@ -44,13 +44,6 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n");Quoted 2 lines
- /* Get the free huge pages before allocation */ -
free_hpage_b=get_free_hugepages();Hi Muhammed Usman Anjum
Quoted 9 lines
Reading the free pages is required before starting the test. This value will be compared to the free pages after the test. If they are not the same, the test will be considered a failure.
Since reading the free pages before the test was removed,|free_hpage_b| is always 0, causing the test to fail.
./tools/testing/selftests/mm/hugetlb_dioTAP version 13 1..4 # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 1 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 2 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 3 : Huge pages not freed! # No. Free pages before allocation : 0 # No. Free pages after munmap : 100 not ok 4 : Huge pages not freed! # Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0 I think below changes are required. ---a/tools/testing/selftests/mm/hugetlb_dio.c+++b/tools/testing/selftests/mm/hugetlb_dio.c@@ -44,6 +44,9 @@ voidrun_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd < 0)ksft_exit_fail_perror("Error opening file\n"); + /* Get the free huge pages before allocation */ +free_hpage_b=get_free_hugepages(); + /* Allocate a hugetlb page */orig_buffer=mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer==MAP_FAILED) { With this change the tests are passing../tools/testing/selftests/mm/hugetlb_dioTAP version 13 1..4 # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 1 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 2 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 3 : Huge pages freed successfully ! # No. Free pages before allocation : 100 # No. Free pages after munmap : 100 ok 4 : Huge pages freed successfully ! # Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0 ThankDonet
Sorry. Please ignore above mail.
Reading the free pages is required before starting the test. This
value will be compared to the free pages after the test. If they are not the same, the test will be considered a failure.
Since reading the free pages before the test was removed,free_hpage_b is always 0, causing the test to fail.
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0
I think below changes are required.
iff --git a/tools/testing/selftests/mm/hugetlb_dio.c b/tools/testing/selftests/mm/hugetlb_dio.c index 60001c142ce9..4b52106b8124 100644
tools/testing/selftests/mm/hugetlb_dio.c +0 -0
@@ -44,6 +44,9 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)
if (fd < 0)
ksft_exit_fail_perror("Error opening file\n");
+ /* Get the free huge pages before allocation */ + free_hpage_b = get_free_hugepages();
+
/* Allocate a hugetlb page */
orig_buffer = mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);
if (orig_buffer == MAP_FAILED) {
With this change the tests are passing.
./tools/testing/selftests/mm/hugetlb_dio
TAP version 131..4
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 1 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 2 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 3 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 4 : Huge pages freed successfully !
# Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
Thanks
Donet
Quoted 29 lines
Quoted 29 lines
- if (
free_hpage_b== 0) {
- close(fd);
-ksft_exit_skip("No free hugepage, exiting!\n");
- }
-
/* Allocate a hugetlb page */
orig_buffer=mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0); if (orig_buffer==MAP_FAILED) {tools/testing/selftests/mm/hugetlb_dio.c +12
-0@@ -94,8 +87,20 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) int main(void) { size_t pagesize = 0; + int fd; ksft_print_header(); + + /* Open the file to DIO */ + fd = open("/tmp", O_TMPFILE | O_RDWR | O_DIRECT, 0664); + if (fd < 0) + ksft_exit_skip("Unable to allocate file: %s\n",strerror (errno)); + close(fd); + + /* Check if huge pages are free */ + if (!get_free_hugepages()) + ksft_exit_skip("No free hugepage, exiting\n"); + ksft_set_plan(4); /* Get base page size */
Quoted 15 lines · Donet Tom
I think below changes are required.
iff --git
a/tools/testing/selftests/mm/hugetlb_dio.cb/tools/testing/selftests/mm/hugetlb_dio.cindex60001c142ce9..4b52106b8124100644tools/testing/selftests/mm/hugetlb_dio.c +0
-0@@ -44,6 +44,9 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n");
+ /* Get the free huge pages before allocation */ +free_hpage_b=get_free_hugepages();
+
/* Allocate a hugetlb page */
Quoted 3 lines
orig_buffer=mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);if (
orig_buffer==MAP_FAILED) {
Please can you send a fixup patch as you have working test setup? Otherwise I'll take it up and try to test on working setup before posting the fixup patch. Please let me know.
Quoted 24 lines
With this change the tests are passing.
./tools/testing/selftests/mm/hugetlb_dioTAP version 131..4
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 1 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 2 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 3 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 4 : Huge pages freed successfully !
# Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0Thanks
Donet
Signature · 2 lines
BR, Muhammad Usama Anjum
Andrew Morton
maintainerQuoted 17 lines · On Fri, 8 Nov 2024 19:13:04 +0500 Muhammad Usama Anjum…
Quoted 15 lines · Donet Tom
I think below changes are required.
iff --git
a/tools/testing/selftests/mm/hugetlb_dio.cb/tools/testing/selftests/mm/hugetlb_dio.cindex60001c142ce9..4b52106b8124100644tools/testing/selftests/mm/hugetlb_dio.c +0
-0@@ -44,6 +44,9 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n");
+ /* Get the free huge pages before allocation */ +free_hpage_b=get_free_hugepages();
+
/* Allocate a hugetlb page */
Quoted 6 lines
Quoted 3 lines
orig_buffer=mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);if (
orig_buffer==MAP_FAILED) {Please can you send a fixup patch as you have working test setup? Otherwise I'll take it up and try to test on working setup before posting the fixup patch. Please let me know.
I've removed this patch from mm-hotfixes-stable.
Andrew Morton
maintainerQuoted 19 lines · On Sat, 9 Nov 2024 22:20:01 -0800 Andrew Morton <[email protected]>…
Quoted 17 lines · On Fri, 8 Nov 2024 19:13:04 +0500 Muhammad Usama Anjum…
Quoted 15 lines · Donet Tom
I think below changes are required.
iff --git
a/tools/testing/selftests/mm/hugetlb_dio.cb/tools/testing/selftests/mm/hugetlb_dio.cindex60001c142ce9..4b52106b8124100644tools/testing/selftests/mm/hugetlb_dio.c +0
-0@@ -44,6 +44,9 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) if (fd < 0) ksft_exit_fail_perror("Error opening file\n");
+ /* Get the free huge pages before allocation */ +free_hpage_b=get_free_hugepages();
+
/* Allocate a hugetlb page */
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
orig_buffer=mmap(NULL, h_pagesize, mmap_prot, mmap_flags, -1, 0);if (
orig_buffer==MAP_FAILED) {Please can you send a fixup patch as you have working test setup? Otherwise I'll take it up and try to test on working setup before posting the fixup patch. Please let me know.
I've removed this patch from mm-hotfixes-stable.
I changed my mind. Please send any fixup against the previous patch.
PATCH 1/1 selftests: hugetlb_dio: Fixup Check for initial conditions to skip in the start
This test verifies that a hugepage, used as a user buffer for DIO operations, is correctly freed upon unmapping. To test this, we read the count of free hugepages before and after the mmap, DIO, and munmap operations, then check if the free hugepage count is the same.
Reading free hugepages before the test was removed by commit 0268d4579901 ('selftests: hugetlb_dio: check for initial conditions to skip at the start'), causing the test to always fail.
This patch adds back reading the free hugepages before starting the test. With this patch, the tests are now passing.
Test Results without this patch
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0
Test results with this patch.
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0
--- tools/testing/selftests/mm/hugetlb_dio.c | 7 +++++++ 1 file changed, 7 insertions(+)
tools/testing/selftests/mm/hugetlb_dio.c +7 -0
@@ -44,6 +44,13 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd <0 )ksft_exit_fail_perror ("Error opening file\n" ); +/* Get the free huge pages before allocation */ + free_hpage_b =get_free_hugepages (); +if (free_hpage_b ==0 ) { +close (fd); +ksft_exit_skip ("No free hugepage, exiting!\n" ); + } +/* Allocate a hugetlb page */ orig_buffer =mmap (NULL , h_pagesize, mmap_prot, mmap_flags,-1 ,0 );if (orig_buffer ==MAP_FAILED ) {
Signature · 1 line
2.43.5
Re: [PATCH] selftests: hugetlb_dio: Fixup Check for initial conditions to skip in the start
Quoted 67 lines · Donet Tom
This test verifies that a hugepage, used as a user buffer for DIO operations, is correctly freed upon unmapping. To test this, we read the count of free hugepages before and after the mmap, DIO, and munmap operations, then check if the free hugepage count is the same.
Reading free hugepages before the test was removed by commit
0268d4579901('selftests:hugetlb_dio: check for initial conditions to skip at the start'), causing the test to always fail.This patch adds back reading the free hugepages before starting the test. With this patch, the tests are now passing.
Test Results without this patch
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0Test results with this patch.
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0Fixes 0268d4579901 ("selftests: hugetlb_dio: check for initial conditions to skip in the start")Signed-off-by Donet Tom <[email protected]>--- tools/testing/selftests/mm/hugetlb_dio.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/testing/selftests/mm/hugetlb_dio.c +0
-0@@ -44,6 +44,13 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd <0 )ksft_exit_fail_perror ("Error opening file\n" );
tools/testing/selftests/mm/hugetlb_dio.c void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off) · line 56
Quoted 10 lines
tools/testing/selftests/mm/hugetlb_dio.c +7
-0+/* Get the free huge pages before allocation */ + free_hpage_b =get_free_hugepages (); +if (free_hpage_b ==0 ) { +close (fd); +ksft_exit_skip ("No free hugepage, exiting!\n" ); + } +/* Allocate a hugetlb page */ orig_buffer =mmap (NULL , h_pagesize, mmap_prot, mmap_flags,-1 ,0 );if (orig_buffer ==MAP_FAILED ) {
Hi Andrew
Would you prefer I send this fixup patch as a new series, or is it okay as is?
Thanks
Donet
Andrew Morton
maintainerRe: [PATCH] selftests: hugetlb_dio: Fixup Check for initial conditions to skip in the start
Quoted 5 lines · On Sun, 10 Nov 2024 12:22:12 +0530 Donet Tom <[email protected]> wrote:
Quoted 1 line
Fixes 0268d4579901 ("selftests: hugetlb_dio: check for initial conditions to skip in the start")...
Would you prefer I send this fixup patch as a new series, or is it okay as is?
All looks good, thanks. I added cc:stable, because 0268d4579901 was cc:stable.
Re: [PATCH] selftests: hugetlb_dio: Fixup Check for initial conditions to skip in the start
In reply to Donet TomQuoted 32 lines · Donet Tom
This test verifies that a hugepage, used as a user buffer for DIO operations, is correctly freed upon unmapping. To test this, we read the count of free hugepages before and after the mmap, DIO, and munmap operations, then check if the free hugepage count is the same.
Reading free hugepages before the test was removed by commit
0268d4579901('selftests:hugetlb_dio: check for initial conditions to skip at the start'), causing the test to always fail.This patch adds back reading the free hugepages before starting the test. With this patch, the tests are now passing.
Test Results without this patch
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0
Quoted 1 line
Test results with this patch.
Sorry the test results with this patch is below.
Test results With this patch
/tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 1 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 2 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 3 : Huge pages freed successfully !
# No. Free pages before allocation : 100
# No. Free pages after munmap : 100
ok 4 : Huge pages freed successfully !
# Totals: pass:4 fail:0 xfail:0 xpass:0 skip:0 error:0
Thank
Donet
Quoted 42 lines
./tools/testing/selftests/mm/hugetlb_dio
TAP version 13
1..4
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 1 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 2 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 3 : Huge pages not freed!
# No. Free pages before allocation : 0
# No. Free pages after munmap : 100
not ok 4 : Huge pages not freed!
# Totals: pass:0 fail:4 xfail:0 xpass:0 skip:0 error:0Fixes 0268d4579901 ("selftests: hugetlb_dio: check for initial conditions to skip in the start")Signed-off-by Donet Tom <[email protected]>--- tools/testing/selftests/mm/hugetlb_dio.c | 7 +++++++ 1 file changed, 7 insertions(+)tools/testing/selftests/mm/hugetlb_dio.c +7
-0@@ -44,6 +44,13 @@ void run_dio_using_hugetlb(unsigned int start_off, unsigned int end_off)if (fd <0 )ksft_exit_fail_perror ("Error opening file\n" ); +/* Get the free huge pages before allocation */ + free_hpage_b =get_free_hugepages (); +if (free_hpage_b ==0 ) { +close (fd); +ksft_exit_skip ("No free hugepage, exiting!\n" ); + } +/* Allocate a hugetlb page */ orig_buffer =mmap (NULL , h_pagesize, mmap_prot, mmap_flags,-1 ,0 );if (orig_buffer ==MAP_FAILED ) {