lkml.org 
[lkml]   [2017]   [Sep]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/2] pid: Replace pid bitmap implementation with IDR API
On 09/27, Rik van Riel wrote:
>
> > @@ -240,17 +230,18 @@ void zap_pid_ns_processes(struct pid_namespace
> > *pid_ns)
> >    *
> >    */
> >   read_lock(&tasklist_lock);
> > - nr = next_pidmap(pid_ns, 1);
> > - while (nr > 0) {
> > - rcu_read_lock();
> > + pid = idr_get_next(&pid_ns->idr, &nr);
> > + while (pid) {
> >  
> > - task = pid_task(find_vpid(nr), PIDTYPE_PID);
> > - if (task && !__fatal_signal_pending(task))
> > - send_sig_info(SIGKILL, SEND_SIG_FORCED,
> > task);
> > + rcu_read_lock();
> >  
> > + idr_for_each_entry_continue(&pid_ns->idr, pid, nr) {
> > + task = pid_task(pid, PIDTYPE_PID);
> > + if (task && !__fatal_signal_pending(task))
> > + send_sig_info(SIGKILL,
> > SEND_SIG_FORCED, task);
> > + }
> >   rcu_read_unlock();
> >  
> > - nr = next_pidmap(pid_ns, nr);
> >   }
> >   read_unlock(&tasklist_lock);
> >  
>
> I believe we should be fine with just the idr_for_each_entry_continue()
> surrounding the loop,

Yes, and please move "nr = 2" close to idr_for_each_entry_continue() to
make it clear why do we use _continue (to skip nr == 1).

> and not need the while (pid) around that.
>
> That should still iterate over all the pids in the namespace, and
> simplify the code even more.

And make this patch correct ;)

because currently it is wrong, zap_pid_ns_processes() won't kill the pid
returned by the first idr_get_next().

Oleg.

\
 
 \ /
  Last update: 2017-09-27 16:07    [W:0.148 / U:4.752 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site