From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751554AbeCJBUx (ORCPT ); Fri, 9 Mar 2018 20:20:53 -0500 Received: from mail-pf0-f195.google.com ([209.85.192.195]:43950 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbeCJBUw (ORCPT ); Fri, 9 Mar 2018 20:20:52 -0500 X-Google-Smtp-Source: AG47ELsTsjFumghaSjXHhm70ICL8AKMxbnCgLBdnznaYp5DZ+FgBwEOGegan4xQJXb1cN0NsGJf6LQ== Subject: Re: [PATCH v5 1/3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() To: Rob Herring Cc: cpandya@codeaurora.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1520208889-3908-1-git-send-email-frowand.list@gmail.com> <1520208889-3908-2-git-send-email-frowand.list@gmail.com> <20180309230346.7mphnvsdxugpmtmc@rob-hp-laptop> From: Frank Rowand Message-ID: Date: Fri, 9 Mar 2018 17:20:50 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180309230346.7mphnvsdxugpmtmc@rob-hp-laptop> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/18 15:03, Rob Herring wrote: > On Sun, Mar 04, 2018 at 04:14:47PM -0800, frowand.list@gmail.com wrote: >> From: Frank Rowand >> >> Create a cache of the nodes that contain a phandle property. Use this >> cache to find the node for a given phandle value instead of scanning >> the devicetree to find the node. If the phandle value is not found >> in the cache, of_find_node_by_phandle() will fall back to the tree >> scan algorithm. >> >> The cache is initialized in of_core_init(). >> >> The cache is freed via a late_initcall_sync() if modules are not >> enabled. >> >> If the devicetree is created by the dtc compiler, with all phandle >> property values auto generated, then the size required by the cache >> could be 4 * (1 + number of phandles) bytes. This results in an O(1) >> node lookup cost for a given phandle value. Due to a concern that the >> phandle property values might not be consistent with what is generated >> by the dtc compiler, a mask has been added to the cache lookup algorithm. >> To maintain the O(1) node lookup cost, the size of the cache has been >> increased by rounding the number of entries up to the next power of >> two. >> >> The overhead of finding the devicetree node containing a given phandle >> value has been noted by several people in the recent past, in some cases >> with a patch to add a hashed index of devicetree nodes, based on the >> phandle value of the node. One concern with this approach is the extra >> space added to each node. This patch takes advantage of the phandle >> property values auto generated by the dtc compiler, which begin with >> one and monotonically increase by one, resulting in a range of 1..n >> for n phandle values. This implementation should also provide a good >> reduction of overhead for any range of phandle values that are mostly >> in a monotonic range. >> >> Performance measurements by Chintan Pandya >> of several implementations of patches that are similar to this one >> suggest an expected reduction of boot time by ~400ms for his test >> system. If the cache size was decreased to 64 entries, the boot >> time was reduced by ~340 ms. The measurements were on a 4.9.73 kernel >> for arch/arm64/boot/dts/qcom/sda670-mtp.dts, contains 2371 nodes and >> 814 phandle values. >> >> Reported-by: Chintan Pandya >> Signed-off-by: Frank Rowand >> --- > > I've applied this one, but not the others. > > Rob > Thank you. I'll let the other two disappear into a distant memory. -Frank