lkml.org 
[lkml]   [2017]   [Oct]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v4 1/2] pid: Replace pid bitmap implementation with IDR API
From
Date
On Tue, 2017-10-10 at 17:11 +0100, Gargi Sharma wrote:
>
> I have listed down the code for both idr_for_each and
> idr_for_each_entry.
> IMHO idr_for_each_entry is easier to read, but YMMV. :)
>
> void kill_task(int id, void *ptr, void *data)
> {
>     struct *pid = ptr;
>     struct task_struct *task = pid_task(pid, PIDTYPE_PID);
>     if (task && !__fatal_signal_pending(task))
>          send_sig_info(SIGKILL, SEND_SIG_FORCED, task);
> }
>
> rcu_read_unlock();
> idr_for_each(&pid_ns->idr, &kill_task, NULL);
> rcu_read_unlock();

It also looks like idr_for_each has no easy
way to skip over PID 1, like you can do with
idr_for_each_entry_continue().

I agree with you, the code below is easier to
read than the code above.

> 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);
> }
>
> Thanks!
> Gargi
> >
> > --
> > All rights reversed
>
>
--
All rights reversed[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2017-10-10 19:53    [W:0.123 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site