public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH v6] syscalls/msgstress: tune limit of processes for small machines
@ 2021-08-26 10:27 Krzysztof Kozlowski
  2021-08-26 12:40 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Kozlowski @ 2021-08-26 10:27 UTC (permalink / raw)
  To: ltp

Forking the exactly amount of processes as the limit (either from
max_pids or from cgroups) is risky - OS might be doing some work and
interfere with the test.  Instead leave some reserve (hard-coded
to 50) for the OS so the test won't fail on fork failure.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

---

Changes since v5:
1. Move the max-pid-reserve to cover non-systemd case.
---
 lib/tst_pid.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/tst_pid.c b/lib/tst_pid.c
index 23753988ca57..897a1b96ac1d 100644
--- a/lib/tst_pid.c
+++ b/lib/tst_pid.c
@@ -32,6 +32,8 @@
 #define PID_MAX_PATH "/proc/sys/kernel/pid_max"
 #define CGROUPS_V1_SLICE_FMT "/sys/fs/cgroup/pids/user.slice/user-%d.slice/pids.max"
 #define CGROUPS_V2_SLICE_FMT "/sys/fs/cgroup/user.slice/user-%d.slice/pids.max"
+/* Leave some available processes for the OS */
+#define PIDS_RESERVE 50
 
 pid_t tst_get_unused_pid_(void (*cleanup_fn) (void))
 {
@@ -124,6 +126,11 @@ int tst_get_free_pids_(void (*cleanup_fn) (void))
 	if ((max_session_pids > 0) && (max_session_pids < max_pids))
 		max_pids = max_session_pids;
 
+	if (max_pids > PIDS_RESERVE)
+		max_pids -= PIDS_RESERVE;
+	else
+		max_pids = 0;
+
 	/* max_pids contains the maximum PID + 1,
 	 * used_pids contains used PIDs + 1,
 	 * so this additional '1' is eliminated by the substraction */
-- 
2.30.2


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

end of thread, other threads:[~2021-08-26 12:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-26 10:27 [LTP] [PATCH v6] syscalls/msgstress: tune limit of processes for small machines Krzysztof Kozlowski
2021-08-26 12:40 ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox