Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934597AbdIYNUL (ORCPT ); Mon, 25 Sep 2017 09:20:11 -0400 Received: from shelob.surriel.com ([96.67.55.147]:51377 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932107AbdIYNUK (ORCPT ); Mon, 25 Sep 2017 09:20:10 -0400 Message-ID: <1506345607.21121.81.camel@surriel.com> Subject: Re: [PATCH 2/4] idr: Add a function idr_get() 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 Date: Mon, 25 Sep 2017 09:20:07 -0400 In-Reply-To: <6d2d9a99d9047a38ae3b8442e537e76c54511c51.1506342921.git.gs051095@gmail.com> References: <6d2d9a99d9047a38ae3b8442e537e76c54511c51.1506342921.git.gs051095@gmail.com> Content-Type: multipart/signed; micalg="pgp-sha256"; protocol="application/pgp-signature"; boundary="=-GkPC2iTik+0lGbJY8rrH" 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 Content-Length: 1801 Lines: 55 --=-GkPC2iTik+0lGbJY8rrH Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, 2017-09-25 at 08:56 -0400, Gargi Sharma wrote: > idr_get(namespace, id) returns a NULL if id is not present > in the idr tree or returns the pointer to the struct if id is > present in the idr tree. With this function in the idr library, > code for pid allocation can be simplified by calling this function > instead of looking through the pidhash. > +++ b/lib/idr.c > @@ -135,6 +135,17 @@ void *idr_get_next_ext(struct idr *idr, unsigned > long *nextid) > =C2=A0} > =C2=A0EXPORT_SYMBOL(idr_get_next_ext); > =C2=A0 > +void * idr_get(struct idr *idr, int *id) > +{ > + struct radix_tree_node *node; > + void __rcu **slot =3D NULL; > + > + __radix_tree_lookup(&idr->idr_rt, *id, &node, &slot); > + if (!slot) > + return NULL; > + return node; > +} I should have noticed this (much) earlier, but doesn't idr_get do essentially the same thing as idr_find? Also, wouldn't you want to return the pid pointer from slot, rather than a pointer to the entire radix tree node? --=20 All Rights Reversed. --=-GkPC2iTik+0lGbJY8rrH 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 iQEcBAABCAAGBQJZyQKHAAoJEM553pKExN6DUrIH/R+N+EB3FjTYCmvdGxPo1MOQ jzI/BGQFGaO/s3t3N4scFY5n4HXZBrLXfzeRCJZhPA2EoyYDr/o2Rlf6VOKEMhOu dqYQ8/3+eLf69UQn87I9cHGaikhxpKh6uAvACflXMiB1KEJ6T1gra5TnO7riVH6S uIrx/db+kNB7qhWtG1De0G2wiV/nhLbHsVbq12LMZqx9petrH8raFuEja6K50G6M NbpK0CCgo0eWBk327+HgbBYlMuiCRwVIQDPGYJ9NlDH3WeUk1Jha/Na1HrOwSPzJ ti9moDXC0pehaMNlcR6vlblW0NZaYqvoH70hiCR1L2aJBQhB9p2DmybvDZlwKjo= =BMlL -----END PGP SIGNATURE----- --=-GkPC2iTik+0lGbJY8rrH--