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

2021-03-11 Thread Eric W. Biederman
Oleg Nesterov writes: > On 03/10, Eric W. Biederman wrote: >> >> Jim Newsome writes: >> >> > +static int do_wait_pid(struct wait_opts *wo) >> > +{ >> > + struct task_struct *target = pid_task(wo->wo_pid, PIDTYPE_PID); >> ^ >>

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

2021-03-11 Thread Eric W. Biederman
Jim Newsome writes: > On 3/10/21 16:40, Eric W. Biederman wrote: >>> +// Optimization for waiting on PIDTYPE_PID. No need to iterate > through child >>> +// and tracee lists to find the target task. >> >> Minor nit: C++ style comments look very out of place in this file >> which

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

2021-03-11 Thread Jim Newsome
On 3/11/21 09:15, Oleg Nesterov wrote: > On 03/10, Jim Newsome wrote: >> On 3/10/21 16:40, Eric W. Biederman wrote: >> +static int do_wait_pid(struct wait_opts *wo) +{ + struct task_struct *target = pid_task(wo->wo_pid, PIDTYPE_PID); >>>

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

2021-03-11 Thread Oleg Nesterov
On 03/10, Jim Newsome wrote: > > On 3/10/21 16:40, Eric W. Biederman wrote: > > >> +static int do_wait_pid(struct wait_opts *wo) > >> +{ > >> + struct task_struct *target = pid_task(wo->wo_pid, PIDTYPE_PID); > > ^ > > This is

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

2021-03-11 Thread Oleg Nesterov
On 03/10, Eric W. Biederman wrote: > > Jim Newsome writes: > > > +static int do_wait_pid(struct wait_opts *wo) > > +{ > > + struct task_struct *target = pid_task(wo->wo_pid, PIDTYPE_PID); > ^ > This is subtle change in

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

2021-03-10 Thread Jim Newsome
On 3/10/21 16:40, Eric W. Biederman wrote: >> +// Optimization for waiting on PIDTYPE_PID. No need to iterate through child >> +// and tracee lists to find the target task. > > Minor nit: C++ style comments look very out of place in this file > which uses old school C /* */ comment

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

2021-03-10 Thread Eric W. Biederman
Jim Newsome writes: > 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

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

2021-03-10 Thread Oleg Nesterov
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

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

2021-03-09 Thread Jim Newsome
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