procfs-util: fix confusion wrt. quantity limit and maximum value
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 2 Nov 2021 17:18:21 +0000 (18:18 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 3 Nov 2021 08:36:08 +0000 (09:36 +0100)
commitc3dead53d50e334f2d072a2248256983d6dc9f8c
tree2926cf5000538c86ae1f221328eeac49523919e5
parentdb2aef5a1d95cea835d2a76db6da266cc4af61d6
procfs-util: fix confusion wrt. quantity limit and maximum value

From packit/rawhide-arm64 logs:
Assertion 'limit >= INT_MAX || get_process_ppid(limit+1, NULL) == -ESRCH' failed at src/test/test-process-util.c:855, function test_get_process_ppid(). Aborting.
――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

The kernel has a few different limits. In particular kernel.threads-max can be
set to some lower value, and kernel.pid_max can be set to a higher value. This
is nice because it reduces PID reuse, even if the number of threads that is
allowed is limited. But the tests assumed that we cannot have a thread with
PID above MIN(kernel.threads-max, kernel.pid_max-1), which is not valid.

So let's rework the whole thing: let's expose the helpers to read
kernel.threads-max and kernel.pid_max, and print what they return in tests.
procfs_tasks_get_limit() was something that is only used in tests, and wasn't
very well defined, so let's drop it.

Fixes #21193.
src/basic/limits-util.c
src/basic/procfs-util.c
src/basic/procfs-util.h
src/test/test-process-util.c
src/test/test-procfs-util.c