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
signature.asc
Description: This is a digitally signed message part

