ltp.lists.linux.it archive mirror
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] Check for maximum available pids in dio_sparse.c
@ 2021-12-16  9:31 Andrea Cervesato via ltp
  2022-01-31 16:18 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2021-12-16  9:31 UTC (permalink / raw)
  To: ltp

Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
---
 testcases/kernel/io/ltp-aiodio/dio_sparse.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/testcases/kernel/io/ltp-aiodio/dio_sparse.c b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
index 929adbfba..5236539ff 100644
--- a/testcases/kernel/io/ltp-aiodio/dio_sparse.c
+++ b/testcases/kernel/io/ltp-aiodio/dio_sparse.c
@@ -59,6 +59,7 @@ static void dio_sparse(int fd, int align, long long fs, int ws, long long off)
 static void setup(void)
 {
 	struct stat sb;
+	int max_pids;
 
 	numchildren = 1000;
 	writesize = 1024;
@@ -69,6 +70,13 @@ static void setup(void)
 	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(TCONF, "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);
 
@@ -129,10 +137,10 @@ static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.forks_child = 1,
 	.options = (struct tst_option[]) {
-		{"n:", &str_numchildren, "Number of threads (default 1000)"},
-		{"w:", &str_writesize, "Size of writing blocks (default 1K)"},
-		{"s:", &str_filesize, "Size of file (default 100M)"},
-		{"o:", &str_offset, "File offset (default 0)"},
-		{}
+		{"n:", &str_numchildren, "-n\t Number of threads (default 1000)"},
+		{"w:", &str_writesize, "-w\t Size of writing blocks (default 1K)"},
+		{"s:", &str_filesize, "-s\t Size of file (default 100M)"},
+		{"o:", &str_offset, "-o\t File offset (default 0)"},
+		{},
 	},
 };
-- 
2.34.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v1] Check for maximum available pids in dio_sparse.c
  2021-12-16  9:31 [LTP] [PATCH v1] Check for maximum available pids in dio_sparse.c Andrea Cervesato via ltp
@ 2022-01-31 16:18 ` Cyril Hrubis
  2022-02-01  9:27   ` Andrea Cervesato via ltp
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2022-01-31 16:18 UTC (permalink / raw)
  To: Andrea Cervesato; +Cc: ltp

Hi!
>  static void setup(void)
>  {
>  	struct stat sb;
> +	int max_pids;
>  
>  	numchildren = 1000;
>  	writesize = 1024;
> @@ -69,6 +70,13 @@ static void setup(void)
>  	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(TCONF, "Number of children reduced to %d due to system limitations", numchildren);
                          ^
			  If we are going to limit the number of
			  children this should be TINFO

And if we are going to skip the test it should be tst_brk(TCONF, ...)

Either way tst_res(TCONF, ...) does not make much sense in this case.

> +	}

I guess that we should do a similar check in all the io tests that fork
children, so we may as well put it into some kind of library function.

Maybe just the common.h with something as:

static inline void check_children(unsigned int numchildren)
{
	if (numchildren > tst_get_free_pids)
		tst_brk(TCONF, "....");
}

or:

static inline void check_children(unsigned int *numchilren)
{
	...
}

In case that we want to print the info message and modify the value.

>  	if (tst_parse_filesize(str_writesize, &writesize, 1, LLONG_MAX))
>  		tst_brk(TBROK, "Invalid write blocks size '%s'", str_writesize);
>  
> @@ -129,10 +137,10 @@ static struct tst_test test = {
>  	.needs_tmpdir = 1,
>  	.forks_child = 1,
>  	.options = (struct tst_option[]) {
> -		{"n:", &str_numchildren, "Number of threads (default 1000)"},
> -		{"w:", &str_writesize, "Size of writing blocks (default 1K)"},
> -		{"s:", &str_filesize, "Size of file (default 100M)"},
> -		{"o:", &str_offset, "File offset (default 0)"},
> -		{}
> +		{"n:", &str_numchildren, "-n\t Number of threads (default 1000)"},
> +		{"w:", &str_writesize, "-w\t Size of writing blocks (default 1K)"},
> +		{"s:", &str_filesize, "-s\t Size of file (default 100M)"},
> +		{"o:", &str_offset, "-o\t File offset (default 0)"},
> +		{},

This part is certainly wrong.

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [PATCH v1] Check for maximum available pids in dio_sparse.c
  2022-01-31 16:18 ` Cyril Hrubis
@ 2022-02-01  9:27   ` Andrea Cervesato via ltp
  0 siblings, 0 replies; 3+ messages in thread
From: Andrea Cervesato via ltp @ 2022-02-01  9:27 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp


[-- Attachment #1.1: Type: text/plain, Size: 2273 bytes --]

Hi!

On 1/31/22 17:18, Cyril Hrubis wrote:
> Hi!
>>   static void setup(void)
>>   {
>>   	struct stat sb;
>> +	int max_pids;
>>   
>>   	numchildren = 1000;
>>   	writesize = 1024;
>> @@ -69,6 +70,13 @@ static void setup(void)
>>   	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(TCONF, "Number of children reduced to %d due to system limitations", numchildren);
>                            ^
> 			  If we are going to limit the number of
> 			  children this should be TINFO
>
> And if we are going to skip the test it should be tst_brk(TCONF, ...)
>
> Either way tst_res(TCONF, ...) does not make much sense in this case.
>
>> +	}
> I guess that we should do a similar check in all the io tests that fork
> children, so we may as well put it into some kind of library function.
Yes, this can be done in another patch for all the tests
> Maybe just the common.h with something as:
>
> static inline void check_children(unsigned int numchildren)
> {
> 	if (numchildren > tst_get_free_pids)
> 		tst_brk(TCONF, "....");
> }
>
> or:
>
> static inline void check_children(unsigned int *numchilren)
> {
> 	...
> }
>
> In case that we want to print the info message and modify the value.
>
>>   	if (tst_parse_filesize(str_writesize, &writesize, 1, LLONG_MAX))
>>   		tst_brk(TBROK, "Invalid write blocks size '%s'", str_writesize);
>>   
>> @@ -129,10 +137,10 @@ static struct tst_test test = {
>>   	.needs_tmpdir = 1,
>>   	.forks_child = 1,
>>   	.options = (struct tst_option[]) {
>> -		{"n:", &str_numchildren, "Number of threads (default 1000)"},
>> -		{"w:", &str_writesize, "Size of writing blocks (default 1K)"},
>> -		{"s:", &str_filesize, "Size of file (default 100M)"},
>> -		{"o:", &str_offset, "File offset (default 0)"},
>> -		{}
>> +		{"n:", &str_numchildren, "-n\t Number of threads (default 1000)"},
>> +		{"w:", &str_writesize, "-w\t Size of writing blocks (default 1K)"},
>> +		{"s:", &str_filesize, "-s\t Size of file (default 100M)"},
>> +		{"o:", &str_offset, "-o\t File offset (default 0)"},
>> +		{},
> This part is certainly wrong.
>

[-- Attachment #1.2: Type: text/html, Size: 3276 bytes --]

[-- Attachment #2: Type: text/plain, Size: 60 bytes --]


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-02-01  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-16  9:31 [LTP] [PATCH v1] Check for maximum available pids in dio_sparse.c Andrea Cervesato via ltp
2022-01-31 16:18 ` Cyril Hrubis
2022-02-01  9:27   ` Andrea Cervesato via ltp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).