Re: [PATCH v3] do_wait: make PIDTYPE_PID case O(1) instead of O(n)

From: Oleg Nesterov
Date: Wed Mar 10 2021 - 12:29:14 EST


On 03/09, Jim Newsome wrote:
>
> do_wait is an internal function used to implement waitpid, waitid,
> wait4, etc. To handle the general case, it does an O(n) linear scan of
> the thread group's children and tracees.
>
> This patch adds a special-case when waiting on a pid to skip these scans
> and instead do an O(1) lookup. This improves performance when waiting on
> a pid from a thread group with many children and/or tracees.
>
> Signed-off-by: James Newsome <jnewsome@xxxxxxxxxxxxxx>

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>