Check for maximum available pids in dio_sparse.c
PATCH v2 1/1 Check for maximum available pids in dio_sparse.c
Signed-off-by Andrea Cervesato <[email protected]>
---
In v2 setup message for children has been moved from TCONF to TINFO. And other small fixes.
testcases/kernel/io/ltp-aiodio/dio_sparse.c | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-)
testcases/kernel/io/ltp-aiodio/dio_sparse.c +21 -5
@@ -54,14 +54,29 @@ static void dio_sparse(int fd, int align, long long fs, int ws, long long off) w =SAFE_WRITE (0 , fd, bufptr, ws); i += w; } + +free (bufptr); }static void setup (void ) {struct stat sb; +int max_pids; + +if (tst_parse_int (str_numchildren, &numchildren,1 ,INT_MAX )) { +tst_brk (TBROK ,"Invalid number of children '%s'" , + str_numchildren); + } -if (tst_parse_int (str_numchildren, &numchildren,1 ,INT_MAX )) -tst_brk (TBROK ,"Invalid number of children '%s'" , str_numchildren); + max_pids =tst_get_free_pids (); +if (numchildren > max_pids) { + numchildren = max_pids; + +tst_res (TINFO , +"Number of children reduced to %d due to system " +"limitations" , + numchildren); + }if (tst_parse_filesize (str_writesize, &writesize,1 ,LLONG_MAX ))tst_brk (TBROK ,"Invalid write blocks size '%s'" , str_writesize);
@@ -75,7 +90,8 @@ static void setup(void)SAFE_STAT ("." , &sb); alignment = sb.st_blksize; - run_child =SAFE_MMAP (NULL ,sizeof (int ),PROT_READ |PROT_WRITE ,MAP_SHARED |MAP_ANONYMOUS ,-1 ,0 ); + run_child =SAFE_MMAP (NULL ,sizeof (int ),PROT_READ |PROT_WRITE , +MAP_SHARED |MAP_ANONYMOUS ,-1 ,0 );tst_res (TINFO ,"Dirtying free blocks" );dirty_freeblocks (100 *1024 *1024 );
@@ -91,7 +107,7 @@ static void cleanup(void)static void run (void ) { -char *filename ="dio_sparse" ; +char *filename ="file.bin" ;int status;int fd;int i;
@@ -129,7 +145,7 @@ static struct tst_test test = { {"w:", &str_writesize, "Size of writing blocks (default 1K)"}, {"s:", &str_filesize, "Size of file (default 100M)"}, {"o:", &str_offset, "File offset (default 0)"}, - {} + {}, }, .skip_filesystems = (const char *[]) { "tmpfs",
Signature · 5 lines
2.34.1 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi!
Quoted 4 lines
Signed-off-by Andrea Cervesato <[email protected]>---
In v2 setup message for children has been moved from TCONF to TINFO. And other small fixes.
Please send the small fixes in a separate patch.
Quoted 26 lines
testcases/kernel/io/ltp-aiodio/dio_sparse.c | 26 +++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-)testcases/kernel/io/ltp-aiodio/dio_sparse.c +8
-1@@ -54,14 +54,29 @@ static void dio_sparse(int fd, int align, long long fs, int ws, long long off) w =SAFE_WRITE (0 , fd, bufptr, ws); i += w; } + +free (bufptr); }static void setup (void ) {struct stat sb; +int max_pids; + +if (tst_parse_int (str_numchildren, &numchildren,1 ,INT_MAX )) { +tst_brk (TBROK ,"Invalid number of children '%s'" , + str_numchildren); + } -if (tst_parse_int (str_numchildren, &numchildren,1 ,INT_MAX ))
testcases/kernel/io/ltp-aiodio/dio_sparse.c static void dio_sparse(int fd, int align, long long fs, int ws, long long off) · line 79
Quoted 10 lines
testcases/kernel/io/ltp-aiodio/dio_sparse.c +9
-1-tst_brk (TBROK ,"Invalid number of children '%s'" , str_numchildren); + max_pids =tst_get_free_pids (); +if (numchildren > max_pids) { + numchildren = max_pids; + +tst_res (TINFO , +"Number of children reduced to %d due to system " +"limitations" , + numchildren); + }
Can we put this piece of code into a some common place and use it in all the I/O tests?
I guess that we can as well add a function parse_numchildren() into common.h that would call tst_parse_int() and then apply the limits and use that in all the tests...
Signature · 5 lines
Cyril Hrubis [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp