* [LTP] [PATCH v2] Check for maximum available pids in dio_sparse.c
@ 2022-02-01 9:39 Andrea Cervesato
2022-03-07 9:31 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Cervesato @ 2022-02-01 9:39 UTC (permalink / raw)
To: ltp
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
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(-)
diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index 0039daa8d..1da1ae37f 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -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",
--
2.34.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [LTP] [PATCH v2] Check for maximum available pids in dio_sparse.c
2022-02-01 9:39 [LTP] [PATCH v2] Check for maximum available pids in dio_sparse.c Andrea Cervesato
@ 2022-03-07 9:31 ` Cyril Hrubis
0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-03-07 9:31 UTC (permalink / raw)
To: Andrea Cervesato; +Cc: ltp
Hi!
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
> ---
> 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.
> testcases/kernel/io/ltp-aiodio/dio_sparse.c | 26 +++++++++++++++++----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> index 0039daa8d..1da1ae37f 100644
> --- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> +++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
> @@ -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);
> + }
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...
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-07 9:29 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 9:39 [LTP] [PATCH v2] Check for maximum available pids in dio_sparse.c Andrea Cervesato
2022-03-07 9:31 ` Cyril Hrubis
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.