From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934308AbdIYNrN (ORCPT ); Mon, 25 Sep 2017 09:47:13 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:43910 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751336AbdIYNrM (ORCPT ); Mon, 25 Sep 2017 09:47:12 -0400 Date: Mon, 25 Sep 2017 06:47:08 -0700 From: Christoph Hellwig To: Rik van Riel Cc: Gargi Sharma , linux-kernel@vger.kernel.org, julia.lawall@lip6.fr, akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com, oleg@redhat.com Subject: Re: [PATCH 2/4] idr: Add a function idr_get() Message-ID: <20170925134708.GA14314@infradead.org> References: <6d2d9a99d9047a38ae3b8442e537e76c54511c51.1506342921.git.gs051095@gmail.com> <1506345607.21121.81.camel@surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1506345607.21121.81.camel@surriel.com> User-Agent: Mutt/1.8.3 (2017-05-23) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 25, 2017 at 09:20:07AM -0400, Rik van Riel wrote: > > +++ b/lib/idr.c > > @@ -135,6 +135,17 @@ void *idr_get_next_ext(struct idr *idr, unsigned > > long *nextid) > >  } > >  EXPORT_SYMBOL(idr_get_next_ext); > >   > > +void * idr_get(struct idr *idr, int *id) > > +{ > > + struct radix_tree_node *node; > > + void __rcu **slot = 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? It also seems rather odd to pass id by reference here just to dereference it a little later.