From mboxrd@z Thu Jan 1 00:00:00 1970 From: Krzysztof Kozlowski Date: Fri, 20 Aug 2021 12:00:28 +0200 Subject: [LTP] [PATCH v5 3/3] syscalls/msgstress: tune limit of processes for small machines In-Reply-To: <20210820100028.97487-1-krzysztof.kozlowski@canonical.com> References: <20210820100028.97487-1-krzysztof.kozlowski@canonical.com> Message-ID: <20210820100028.97487-4-krzysztof.kozlowski@canonical.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it 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 --- 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 23753988ca57..435a0c63af34 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)) { @@ -97,7 +99,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.30.2