All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 4/4] syscalls/msgstress: tune limit of processes for small machines
Date: Wed, 23 Jun 2021 15:59:12 +0200	[thread overview]
Message-ID: <20210623135912.81156-5-krzysztof.kozlowski@canonical.com> (raw)
In-Reply-To: <20210623135912.81156-1-krzysztof.kozlowski@canonical.com>

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
500) for the OS so the test won't fail on fork failure.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
---
 lib/tst_pid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/tst_pid.c b/lib/tst_pid.c
index c1ea3fe90e83..1b2e85959430 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 500
 
 pid_t tst_get_unused_pid_(void (*cleanup_fn) (void))
 {
@@ -106,7 +108,7 @@ static int get_session_pids_limit(void (*cleanup_fn) (void))
 	if (max_pids < 0)
 		return -1;
 
-	return max_pids;
+	return max_pids > PIDS_RESERVE ? max_pids - PIDS_RESERVE : 0;
 }
 
 int tst_get_free_pids_(void (*cleanup_fn) (void))
-- 
2.27.0


      parent reply	other threads:[~2021-06-23 13:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 13:59 [LTP] [PATCH v3 0/4] syscalls/msgstress: fixes for small systems Krzysztof Kozlowski
2021-06-23 13:59 ` [LTP] [PATCH v3 1/4] include/tst_pid.h: fix language typo (subtraction) Krzysztof Kozlowski
2021-06-28 14:49   ` Petr Vorel
2021-06-28 15:50     ` Krzysztof Kozlowski
2021-06-28 19:29       ` Petr Vorel
2021-06-23 13:59 ` [LTP] [PATCH v3 2/4] syscalls/msgstress04: fix fork failure on small memory systems Krzysztof Kozlowski
2021-06-28 14:47   ` Petr Vorel
2021-06-28 16:05     ` Krzysztof Kozlowski
2021-06-23 13:59 ` [LTP] [PATCH v3 3/4] syscalls/msgstress03: " Krzysztof Kozlowski
2021-06-23 13:59 ` Krzysztof Kozlowski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210623135912.81156-5-krzysztof.kozlowski@canonical.com \
    --to=krzysztof.kozlowski@canonical.com \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.