Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936377AbdIYRnc (ORCPT ); Mon, 25 Sep 2017 13:43:32 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:36782 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934514AbdIYRnb (ORCPT ); Mon, 25 Sep 2017 13:43:31 -0400 X-Google-Smtp-Source: AOwi7QD20khLcI90KRHYQZcucpvSd1KNMlDmVu6EbrJexvszAcE+bQlV60Zt4nWPW5n8n65UOvwH7hk5VmQ7hChpjMk= MIME-Version: 1.0 In-Reply-To: <20170925141258.GA9328@redhat.com> References: <6d2d9a99d9047a38ae3b8442e537e76c54511c51.1506342921.git.gs051095@gmail.com> <20170925141258.GA9328@redhat.com> From: Gargi Sharma Date: Mon, 25 Sep 2017 23:13:00 +0530 Message-ID: Subject: Re: [PATCH 2/4] idr: Add a function idr_get() To: Oleg Nesterov Cc: linux-kernel@vger.kernel.org, Rik van Riel , Julia Lawall , akpm@linux-foundation.org, mingo@kernel.org, pasha.tatashin@oracle.com, ktkhai@virtuozzo.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 854 Lines: 28 On Mon, Sep 25, 2017 at 7:42 PM, Oleg Nesterov wrote: > On 09/25, 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. > > Could you explain why find_pid_ns() can't use idr_find() ? It can. I missed this macro from the IDR library. Will change this and drop this patch in the next version. Thanks! Gargi > >> +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); > > so why it takes "int *", not just "int" ? > > Oleg. >