lkml.org 
[lkml]   [2021]   [Mar]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4] do_wait: make PIDTYPE_PID case O(1) instead of O(n)
From
Date

On 3/12/21 10:41, Oleg Nesterov wrote:
> On 03/11, Jim Newsome wrote:
>> +
>> + if (target && is_effectively_child(wo, ptrace, target)) {
>> + retval = wait_consider_task(wo, ptrace, target);
> No, this is not right... You need to check target->ptrace != 0.

Shoot; got lost in the shuffle. Sorry about that and thanks for catching!

> I know that Eric suggests to not use thread_group_leader() and I won't argue
> even if I don't really agree.
>
> Up to you, but to me something like
>
> do_wait_pid()
> {
> target = pid_task(wo->wo_pid, PIDTYPE_PID);
>
> if (!target)
> return 0;
>
> if (thread_group_leader(target) &&
> is_effectively_child(wo, 0, target) {
> ...
> }
>
> if (target->ptrace &&
> is_effectively_child(wo, 1, target) {
> ...
> }
>
> return 0;
>
> }
>
> looks more simple/clean.

I like that a little better too. I'll go this way since Eric seemed Ok
with either way.

If we do that then it might make sense to move the `thread_group_leader`
filter into `is_effectively_child`, but maybe that obscures what the
latter is doing too much. It'd at least have to be renamed, and I'm not
sure of a clear name that'd capture exactly what it's doing. Maybe
`is_valid_waitee`?

If I don't hear anything I'll just go with how you've already proposed.

v5 coming in a bit. I'll drop your (Oleg's) reviewed-by since it's
changed substantially since then.

\
 
 \ /
  Last update: 2021-03-12 17:52    [W:0.055 / U:0.028 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site