From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752517AbdJFTJN (ORCPT ); Fri, 6 Oct 2017 15:09:13 -0400 Received: from shelob.surriel.com ([96.67.55.147]:47942 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751654AbdJFTJM (ORCPT ); Fri, 6 Oct 2017 15:09:12 -0400 Message-ID: <1507316934.21121.136.camel@surriel.com> Subject: Re: [PATCH v3 1/2] pid: Replace pid bitmap implementation with IDR API From: Rik van Riel To: Gargi Sharma , linux-kernel@vger.kernel.org Cc: julia.lawall@lip6.fr, akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com, oleg@redhat.com, ebiederm@xmission.com, hch@infradead.org Date: Fri, 06 Oct 2017 15:08:54 -0400 In-Reply-To: <1507290803-20708-2-git-send-email-gs051095@gmail.com> References: <1507290803-20708-1-git-send-email-gs051095@gmail.com> <1507290803-20708-2-git-send-email-gs051095@gmail.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-btmHyhBHNyE2yKU/1vwS" 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 --=-btmHyhBHNyE2yKU/1vwS Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, 2017-10-06 at 07:53 -0400, Gargi Sharma wrote: > @@ -308,8 +165,28 @@ struct pid *alloc_pid(struct pid_namespace *ns) The code looks like it addresses all of Oleg's comments now, but the comments could be a little clearer, IMHO. =C2=A0 > =C2=A0 tmp =3D ns; > =C2=A0 pid->level =3D ns->level; > + > =C2=A0 for (i =3D ns->level; i >=3D 0; i--) { > - nr =3D alloc_pidmap(tmp); > + int pid_min =3D 1; > + idr_preload(GFP_KERNEL); > + spin_lock_irq(&pidmap_lock); > + > + /* > + =C2=A0* init really needs pid 1, but after reaching the > maximum > + =C2=A0* wrap back to RESERVED_PIDS > + =C2=A0*/ > + if (idr_get_cursor(&tmp->idr) > RESERVED_PIDS) > + pid_min =3D RESERVED_PIDS; > + > + /* > + =C2=A0* allocate a NULL pointer so that find_pid_ns can't > + =C2=A0* find pid that is not fully initialized > + =C2=A0*/ /* * Store a null pointer so find_pid_ns does not find * a partially initialized PID (see below). */ > + nr =3D idr_alloc_cyclic(&tmp->idr, NULL, pid_min, > + =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0pid_max, GFP_ATOMIC); > + spin_unlock_irq(&pidmap_lock); > + idr_preload_end(); > + > =C2=A0 if (nr < 0) { > =C2=A0 retval =3D nr; > =C2=A0 goto out_free; > @@ -339,6 +216,7 @@ struct pid *alloc_pid(struct pid_namespace *ns) > =C2=A0 for ( ; upid >=3D pid->numbers; --upid) { > =C2=A0 hlist_add_head_rcu(&upid->pid_chain, > =C2=A0 &pid_hash[pid_hashfn(upid->nr, upid- > >ns)]); /* Make the PID visible to find_pid_ns. */ > + idr_replace(&upid->ns->idr, pid, upid->nr); > =C2=A0 upid->ns->nr_hashed++; > =C2=A0 } > =C2=A0 spin_unlock_irq(&pidmap_lock); >=20 Everything else looks great to me. Reviewed-by: Rik van Riel --=20 All Rights Reversed. --=-btmHyhBHNyE2yKU/1vwS 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 iQEcBAABCAAGBQJZ19TGAAoJEM553pKExN6DVskH/ibPMqdGQL/q32OsnGMtYnE9 RjjrjUnx6fpSxfvber6wCa6CQdaXjHqP2v6Aai6umMieJzqiLMwAWMBRVegHTQjR t55X9VBSeBzVZ+uYnqWuj1v2hn1Qh4kBt8qTq2LRxYxFIOHnucjAYNHxJEAIh51J XLwWT6dIVLceI5QmDwD79XlReT5XVdmAWUuY5wryR1KLswg0hjBxym5toXY+uGOJ 8Hl+PB9TdaPTJeOqQC5TZtv12NEQzMJe6HCoGv5shgqXexKv8QAcm1nkKjrKHT/u EuLFzcMYOgcJHIjc5/HJmf+R98fIQYI1WMBgoLlhfyHCZNLjXvLCOQlu3BnMbyQ= =4Ara -----END PGP SIGNATURE----- --=-btmHyhBHNyE2yKU/1vwS--