diff mbox series

[v4,3/4] syscalls/msgstress03: fix fork failure on small memory systems

Message ID 20210629121047.100391-4-krzysztof.kozlowski@canonical.com
State Superseded
Headers show
Series syscalls/msgstress: fixes for small systems | expand

Commit Message

Krzysztof Kozlowski June 29, 2021, 12:10 p.m. UTC
Running syscalls/msgstress03 on a system with less than ~4 GB of RAM fails:

    msgstress03    1  TFAIL  :  msgstress03.c:155: 	Fork failed (may be OK if under stress)

In dmesg:

    LTP: starting msgstress03
    cgroup: fork rejected by pids controller in /user.slice/user-1000.slice/session-1.scope

The reason is cgroups pid limit set by systemd user.slice.  The limit is
set for login session, also for root user.  For example on 2 GB RAM
machine it is set as:
    /sys/fs/cgroup/pids/user.slice/user-0.slice/pids.max:5207

Read the maximum number of pids and adjust the test limit.  For 2 GB RAM
machine with systemd this will result in:

    msgstress03    0  TINFO  :  Found limit of processes 5056 (from /sys/fs/cgroup/pids/user.slice/user-1000.slice/pids.max)
    msgstress03    0  TINFO  :  Requested number of processes higher than user session limit (10000 > 4556), setting to 4556

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 .../kernel/syscalls/ipc/msgstress/msgstress03.c   | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Cyril Hrubis Aug. 19, 2021, 3:58 p.m. UTC | #1
Hi!
> +	free_pids = tst_get_free_pids(cleanup);
> +	if (free_pids < 0) {
> +		tst_brkm(TBROK, cleanup, "Can't obtain free_pid count");
> +	} else if (!free_pids) {
> +		tst_brkm(TBROK, cleanup, "No free pids");
> +	}

This looks like copy&paste from msgstress04.c, can we please move this
snippet to the library function instead?

> +	if (nprocs >= free_pids) {
> +		tst_resm(TINFO,
> +			 "Requested number of processes higher than limit (%d > %d), "
> +			 "setting to %d", nprocs, free_pids, free_pids);
> +		nprocs = free_pids;
> +	}
> +
>  	srand(getpid());
>  	tid = -1;
>  
> -- 
> 2.27.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Cyril Hrubis Aug. 19, 2021, 4:02 p.m. UTC | #2
Hi!
And we do have a patchset that converts msgstress* to new library as
well which merges msgstress03 and msgstress01. I will try to have a look
into that as well.

http://patchwork.ozlabs.org/project/ltp/list/?series=233661
Krzysztof Kozlowski Aug. 20, 2021, 8:35 a.m. UTC | #3
On 19/08/2021 17:58, Cyril Hrubis wrote:
> Hi!
>> +	free_pids = tst_get_free_pids(cleanup);
>> +	if (free_pids < 0) {
>> +		tst_brkm(TBROK, cleanup, "Can't obtain free_pid count");
>> +	} else if (!free_pids) {
>> +		tst_brkm(TBROK, cleanup, "No free pids");
>> +	}
> 
> This looks like copy&paste from msgstress04.c, can we please move this
> snippet to the library function instead?
> 

I can move it.


Best regards,
Krzysztof
Krzysztof Kozlowski Aug. 20, 2021, 8:35 a.m. UTC | #4
On 19/08/2021 18:02, Cyril Hrubis wrote:
> Hi!
> And we do have a patchset that converts msgstress* to new library as
> well which merges msgstress03 and msgstress01. I will try to have a look
> into that as well.
> 
> http://patchwork.ozlabs.org/project/ltp/list/?series=233661

The question then would be who should rebase on whose work :)


Best regards,
Krzysztof
Cyril Hrubis Aug. 20, 2021, 12:44 p.m. UTC | #5
Hi!
> > And we do have a patchset that converts msgstress* to new library as
> > well which merges msgstress03 and msgstress01. I will try to have a look
> > into that as well.
> > 
> > http://patchwork.ozlabs.org/project/ltp/list/?series=233661
> 
> The question then would be who should rebase on whose work :)

Given that the patchset is not ready, I will push your fixes first.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c b/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
index 294b401b1b38..18e50e35ee07 100644
--- a/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
+++ b/testcases/kernel/syscalls/ipc/msgstress/msgstress03.c
@@ -78,7 +78,7 @@  static void usage(void)
 
 int main(int argc, char **argv)
 {
-	int i, j, ok, pid;
+	int i, j, ok, pid, free_pids;
 	int count, status;
 	struct sigaction act;
 
@@ -109,6 +109,19 @@  int main(int argc, char **argv)
 		}
 	}
 
+	free_pids = tst_get_free_pids(cleanup);
+	if (free_pids < 0) {
+		tst_brkm(TBROK, cleanup, "Can't obtain free_pid count");
+	} else if (!free_pids) {
+		tst_brkm(TBROK, cleanup, "No free pids");
+	}
+	if (nprocs >= free_pids) {
+		tst_resm(TINFO,
+			 "Requested number of processes higher than limit (%d > %d), "
+			 "setting to %d", nprocs, free_pids, free_pids);
+		nprocs = free_pids;
+	}
+
 	srand(getpid());
 	tid = -1;