From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932515AbdJJRwk (ORCPT ); Tue, 10 Oct 2017 13:52:40 -0400 Received: from shelob.surriel.com ([96.67.55.147]:42544 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755794AbdJJRwj (ORCPT ); Tue, 10 Oct 2017 13:52:39 -0400 Message-ID: <1507657866.10046.44.camel@surriel.com> Subject: Re: [PATCH v4 1/2] pid: Replace pid bitmap implementation with IDR API From: Rik van Riel To: Gargi Sharma Cc: Oleg Nesterov , Andrew Morton , linux-kernel@vger.kernel.org, Julia Lawall , mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com, "Eric W. Biederman" , Christoph Hellwig Date: Tue, 10 Oct 2017 13:51:06 -0400 In-Reply-To: References: <1507583624-22146-1-git-send-email-gs051095@gmail.com> <1507583624-22146-2-git-send-email-gs051095@gmail.com> <20171009161737.ea8c62441cc12dfd909ee0b2@linux-foundation.org> <20171010115034.GA28545@redhat.com> <1507650370.10046.41.camel@surriel.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-CBwdX7OceZJKaY1V8yCh" X-Mailer: Evolution 3.22.6 (3.22.6-2.fc25) Mime-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-CBwdX7OceZJKaY1V8yCh Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, 2017-10-10 at 17:11 +0100, Gargi Sharma wrote: >=20 > 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. :) >=20 > void kill_task(int id, void *ptr, void *data) > { > =C2=A0=C2=A0=C2=A0=C2=A0struct *pid =3D ptr; > =C2=A0=C2=A0=C2=A0=C2=A0struct task_struct *task =3D pid_task(pid, PIDTYP= E_PID); > =C2=A0=C2=A0=C2=A0=C2=A0if (task && !__fatal_signal_pending(task)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0send_sig_info(SIGKI= LL, SEND_SIG_FORCED, task); > } >=20 > 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) { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0task =3D pid_= task(pid, PIDTYPE_PID); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if (task && != __fatal_signal_pending(task)) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0send_sig_info(SIGKILL, SEND_SIG_FORCED, task); > } >=20 > Thanks! > Gargi > >=20 > > -- > > All rights reversed >=20 >=20 --=20 All rights reversed --=-CBwdX7OceZJKaY1V8yCh Content-Type: application/pgp-signature; name="signature.asc" Content-Description: This is a digitally signed message part Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQEcBAABCAAGBQJZ3QiKAAoJEM553pKExN6D3jkH/iA3TkcU0AqQzlfJIwc0QNYA DJMxzDmJ724P9E7D1FWyn+LvaNl3aPjU7lOg6Fk6rj0FyS/7aaWFnlUQm/tgRXqJ sQ4nqgl06dpzA7Qwto2XW/v377mpFEnuUv95k4xpdPK7bh8wjirxfIAMRlM9kPV7 kFV7guQckKAFH7YNWZGhrHKWc6UdfuXMQsidRtgl+ft2rSNTxZdtivZ8qxp5ISj4 3yEKYzoWmIElL/IqSUU1HgSz9m+YWEHMK1/4oqdoD/Iz90C7xrS2rqcOPj/CCIAI LniR6qSkDZqk+lm6CTqn/M0jucZ/2mQ1djhnVLKiXx5DNoYhiYfeI7Y21myDjsg= =dtUv -----END PGP SIGNATURE----- --=-CBwdX7OceZJKaY1V8yCh--