Received: by 10.223.176.46 with SMTP id f43csp809068wra; Fri, 26 Jan 2018 07:15:47 -0800 (PST) X-Google-Smtp-Source: AH8x225zo2W2vWh1ELSpFVM0YFXJjDct5khLYE17xO24SsE4f4enI6wQXKX43Lhyidzxu0T/kd9+ X-Received: by 2002:a17:902:2943:: with SMTP id g61-v6mr12753256plb.435.1516979747651; Fri, 26 Jan 2018 07:15:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516979747; cv=none; d=google.com; s=arc-20160816; b=iHuG8leBpbcVXLrMAWuCc7/i6hVXkYy9t+GBBLMjcOJH2ikaG/6RUV2FN/2WyT3uti i4e+RDIMpE2afYRldlLv1+23r+Htm+kygWmCFY27ckbvg2tMkd1KU2oVYsy0iauYdNcy RPAXYx0gC3PpPPneOyLZkxP2n4TScb9j9pv+gI4u/zfX0oB7RAPoQHOLB5+2qLajKxLD JyDzd6Vfw27GljMSM/FOjj0RJWJ1kGOVwYMO/dwwzJW+sj+tDnOjkFtxZcImrJeGyi4E paUnh9OwySY58MOWvRxZrMOBsHZQIF5wBCosfJv+kwXt6oCr8r4gpHT8VjUS6Rl3WQCW PGMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=9EVdRXMzPpssoqZIw7kxyGUAT0H/dt5NX/0QuVzWs1U=; b=FtPgLmBtz7auh+qDkw5YRF2CUk+BZw6y/0v3ptE/9OXcNmxQLoWupPmJOMp+Tywd2h SbnD/zeHSZeDjp8OglPcHCn0pF5B3e6tP5id/EvXf83S3tJ9jXqWVfCr1hcQKryF1PLY JDYbORLdIFY8nndfyFmy8ZgdQFNrr7H32kKRebvVYBTUKhbNRajm0TIuL8oKpF/7dfk0 uta32ox6BYdgUpZm2O6vvs5m9vLERMoRoi9bs+WVb5m9UH8JFRAx3lPRajk4aeWA98Qk 16N9EOGRjdIAiFSr86QJWEj1pjlT0pQPLDGZIrd20RJPhyn6jrBo+A3XXAFqUQjY36kb +i0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GB1hUF2z; dkim=pass header.i=@codeaurora.org header.s=default header.b=kHUr9I5u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l8-v6si3952706pls.65.2018.01.26.07.15.33; Fri, 26 Jan 2018 07:15:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=GB1hUF2z; dkim=pass header.i=@codeaurora.org header.s=default header.b=kHUr9I5u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753676AbeAZPOi (ORCPT + 99 others); Fri, 26 Jan 2018 10:14:38 -0500 Received: from smtp.codeaurora.org ([198.145.29.96]:50736 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753393AbeAZPOf (ORCPT ); Fri, 26 Jan 2018 10:14:35 -0500 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E3D9560AD1; Fri, 26 Jan 2018 15:14:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516979674; bh=hS1e2PNhZL3X9Y3ClRLbFKVL8OWJecmN/2i9/LUgFY0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=GB1hUF2zcn1bQMn4L8QkDyCtjwLq/ojvuwAa00+rAOl6SRaLhunD3i9uD95KCcnSd lB5qT+HN2pXvHlIjlWxcrSx+cvyAIJyCW6RmeFzg4W2RyPiAVKzxDDQLtPuUCADTPO 848mfJh5kFTgIyGGreh+pwEQ1e57i0JXjgyX913Y= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.2.11] (unknown [183.83.202.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: cpandya@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0FDBC600C9; Fri, 26 Jan 2018 15:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1516979673; bh=hS1e2PNhZL3X9Y3ClRLbFKVL8OWJecmN/2i9/LUgFY0=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=kHUr9I5uee4Jj6Jluyv/FiFCTHi/kGHWK8YL4HluLzsSmSQzNpWBBr7Vw9XL1nEiS 3XkvdRSJAwZt5bIsabaTulp/8HfxqdCstmGFhczj+Thhewuf/Bz1mWTs6M14LvswRF OndOHvKfEHGC3mkRVVduGrBe0txpirSVR082nZj0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0FDBC600C9 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=cpandya@codeaurora.org Subject: Re: [PATCH v2] of: use hash based search in of_find_node_by_phandle To: Rasmus Villemoes , robh+dt@kernel.org, frowand.list@gmail.com, devicetree@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org References: <1516955496-17236-1-git-send-email-cpandya@codeaurora.org> From: Chintan Pandya Message-ID: Date: Fri, 26 Jan 2018 20:44:22 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > I'm probably missing something obvious, but: Aren't phandles in practice > small consecutive integers assigned by dtc? If so, why not just have a > smallish static array mapping the small phandle values directly to > device node, instead of adding a pointer to every struct device_node? Or > one could determine the size of the array dynamically (largest seen > phandle value, capping at something sensible, e.g. 1024). Haven't noticed this earlier !! If following is known or true, we can avoid using hash-table and save per device_node hlish_node.     1. How to know max phandle value without traversing tree once? In my case,        max is 1263.     2. Although, I haven't observed collision but is it like every device_node        is associated with unique phandle value ? > In either case, one would still need to keep the code doing the > whole-tree traversal for handling large phandle values, but I think the > above should make lookup O(1) in most cases. I would refrain doing this because that will make this API inconsistent in terms of time taken by different nodes. I see that people do change their device placing in DT and that changes time taken in of_* APIs for them but affecting others. > Alternatively, one could just count the number of nodes with a phandle, > allocate an array of that many pointers (so the memory use is certainly > no more than if adding a pointer to each device_node), and sort it by > phandle, so one can do lookup using a binary search. > > Rasmus This is certainly doable if current approach is not welcomed due to addition on hlish_node in device_node. Chintan Pandya -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project