On 4/22/26 22:11, Bjoern Doebel wrote:
> The pid_max kselftest hardcodes pid_max values of 400 and 500, but the
> kernel enforces a minimum of PIDS_PER_CPU_MIN * num_possible_cpus().
> On machines with many possible CPUs (e.g. nr_cpu_ids=128 yields a
> minimum of 1024), writing 400 or 500 to /proc/sys/kernel/pid_max
> returns EINVAL and all three tests fail.
> 
> Compute these limits the same way as the kernel does and set outer_limit
> and inner_limit dynamically based on the result. Original test semantics
> are preserved (outer < inner, nested namespace capped by parent).
> 

Reviewed-by: Pavel Tikhomirov <[email protected]>

> Signed-off-by: Bjoern Doebel <[email protected]>
> Assisted-by: Kiro:claude-opus-4.6
> ---
> v2:
> - use global outer_limit/inner_limit instead of complicated config
>   struct
> - make use of FIXTURE/TEST_F macros
> - reduce buffer size in write_int_to_fd() to 12
> 
>  .../testing/selftests/pid_namespace/pid_max.c | 156 ++++++++++++++----
>  1 file changed, 124 insertions(+), 32 deletions(-)
> 
...
> @@ -328,17 +405,32 @@ static int pid_max_nested_limit_outer(void *data)
>       return 0;
>  }
>  
> -TEST(pid_max_simple)
> +FIXTURE(pid_max) {
> +     int dummy;

nit: Having dummy variable here does not seem to be required.

> +};
> +
> +FIXTURE_SETUP(pid_max)
>  {
> -     pid_t pid;
> +     int min = pid_min();
>  
> +     outer_limit = min + 100;
> +     inner_limit = min + 200;
> +}
> +
> +FIXTURE_TEARDOWN(pid_max)
> +{
> +}
> +
> +TEST_F(pid_max, simple)


-- 
Best regards, Pavel Tikhomirov
Senior Software Developer, Virtuozzo.


Reply via email to