Received: by 10.223.176.46 with SMTP id f43csp536113wra; Fri, 26 Jan 2018 02:58:55 -0800 (PST) X-Google-Smtp-Source: AH8x226HyixyATE+DGJYDtruKZZJInSZMaM9rRYmCFc6ItEay5Wy5g5EPoOwGYptGTJk+CaHHOHG X-Received: by 10.98.24.22 with SMTP id 22mr19144630pfy.65.1516964335051; Fri, 26 Jan 2018 02:58:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516964335; cv=none; d=google.com; s=arc-20160816; b=BnGJ/NvYzwKts2U4hN4daxUzrfsDfeJkHxhmtYgxMbx36zkFnotHtTAErTSleBvpIX aYIx7vI2+IkswNafNRvMqazoHigQjvpltRqRO6sbe+DtpVp1bvtDKKL/SI69bMQSOGvq NtZ3fJ/gIzGuxQ7G4gHScJe+GMVYovb1A/UtmXdxmsT3TlKJJWRurPoimn3DQ6N4Ec5b EY0Yo2sQOKQPcxMMPmV7TMo42copl7qeucqypSAP7hx7OiTgnPnPMRA9QFDgLPQZM5Rs cCvqIW5aT8QLUwCDj8vO0mHN/jNyWINf3fSTxgQmDEhpnPSRFGz1bWMURR8fEVJAuDqA Mq7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=OjMFQMo/gKYaOYJPup2Q0mwjAnnN2J4/qK5trukRkik=; b=C2jvbRFK6lwxjqkyOuh4lreKX/vfMbF159R9wxWcWu3rkLv+p5t/dpZk7XHH7pSytT a3TI6J2ksV+DxOUj3xlivnAl2o+FnTQzuUmWnmLD429qOnemP9CyhBHP0NkE6sKmLLwy +qC9Fp0z5j/1gQVQNwDhjN1uEyGmTJiVuHzGvfa1fMpFFA1XWLicW35Y7kXyS36GYWpP WQhuRTBFw+4p9AZIv7p5PK0SZZ7MTVe6d/2sOKmXTV7QgVeR3N9frTxGO+2f6Wt2/R6w 6QELvecQMi3aAwF9hivsmm9wir5PFkgFtapLWAnhpPkrzX5fYVwgOvGV+xao/bK4H0Af nNLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@prevas.dk header.s=ironport1 header.b=ye53y7jd; 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 z16si6106582pfh.370.2018.01.26.02.58.40; Fri, 26 Jan 2018 02:58:55 -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=fail header.i=@prevas.dk header.s=ironport1 header.b=ye53y7jd; 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 S1753223AbeAZK5I (ORCPT + 99 others); Fri, 26 Jan 2018 05:57:08 -0500 Received: from mail01.prevas.se ([62.95.78.3]:22529 "EHLO mail01.prevas.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752090AbeAZK5F (ORCPT ); Fri, 26 Jan 2018 05:57:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=prevas.dk; i=@prevas.dk; l=1188; q=dns/txt; s=ironport1; t=1516964225; x=1548500225; h=subject:to:cc:references:from:message-id:date: mime-version:in-reply-to:content-transfer-encoding; bh=6gBX0ntXwB6UGsI2AOQfbnSNowNkQb0iUKPWL0MrqY0=; b=ye53y7jdEu3f7JlN91XJn2owAMaswUh542+dk3suskBziGBGR5ldUmxz 6SHw9y8CD7qvJvO5k8IIcJ+j922GiDGoBi725gtgm9plQjP9mBEL7oDd5 1VLwnACapGMvxRdmdkZF5uXj3n5d3vcSHKiQGK/DykAQ3VPZQtkaY7uIw o=; X-IronPort-AV: E=Sophos;i="5.46,415,1511823600"; d="scan'208";a="3133014" Received: from vmprevas4.prevas.se (HELO smtp.prevas.se) ([172.16.8.104]) by ironport1.prevas.se with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jan 2018 11:57:03 +0100 Received: from [172.16.11.49] (172.16.8.31) by smtp.prevas.se (172.16.8.104) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 26 Jan 2018 11:57:02 +0100 Subject: Re: [PATCH v2] of: use hash based search in of_find_node_by_phandle To: Chintan Pandya , , , CC: , References: <1516955496-17236-1-git-send-email-cpandya@codeaurora.org> From: Rasmus Villemoes Message-ID: Date: Fri, 26 Jan 2018 11:57:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1516955496-17236-1-git-send-email-cpandya@codeaurora.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [172.16.8.31] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-01-26 09:31, Chintan Pandya wrote: > Implement, device-phandle relation in hash-table so > that look up can be faster, irrespective of where my > device is defined in the DT. > > There are ~6.7k calls to of_find_node_by_phandle() and > total improvement observed during boot is 400ms. 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). 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. 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