Re: [PATCH v4 1/2] pid: Replace pid bitmap implementation with IDR API

From: Rik van Riel
Date: Tue Oct 10 2017 - 13:52:44 EST


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

Attachment: signature.asc
Description: This is a digitally signed message part