Message ID | 20210629121047.100391-5-krzysztof.kozlowski@canonical.com |
---|---|
State | Superseded |
Headers | show |
Series | syscalls/msgstress: fixes for small systems | expand |
Hi! > 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. Isn't 500 far too many? I would expect that 50 would be more than enough.
On 19/08/2021 18:00, Cyril Hrubis wrote: > Hi! >> 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. > > Isn't 500 far too many? I would expect that 50 would be more than > enough. I wanted to stay on the safe side to avoid false failures especially that even with 500 reserve there will be plenty of PIDs to stress the system. I can change it to 50. Best regards, Krzysztof
diff --git a/lib/tst_pid.c b/lib/tst_pid.c index c408172675a7..338235f13a6a 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)) { @@ -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))
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(-)