Received: by 10.223.185.111 with SMTP id b44csp846261wrg; Fri, 9 Mar 2018 15:04:51 -0800 (PST) X-Google-Smtp-Source: AG47ELvM0C36FwiOFMIAO/kgnkJ75ShtkKd9OxQ5TqjQfG0eE1nVp8TVZ+Nvm37KQ53WhI+jy4i+ X-Received: by 2002:a17:902:76c2:: with SMTP id j2-v6mr142092plt.250.1520636691197; Fri, 09 Mar 2018 15:04:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520636691; cv=none; d=google.com; s=arc-20160816; b=PMdsC5ZA4L1wkSgrCr1PPquJDIS+H44hUvx1RLNsstcCBhpaHFeYIcYNbsBIIIzHMr Qp1s7JixKiqMxPxfU73xej6c+N9pkuFXgsZbXtzYYt13O1+taEUQqG8L4f8/mIFIvn5s 620mFZhvBnG3od2Uh4zYCMikF2g5r1v3FE5U6EQGDXeBn+Ll3koSEmg+bNa27PuHryc5 s3dlLgYsJiWgCbsgd1gfNXdSMPevkVERCPhQDY30zbBbOSZcaUDQ6Ae4LjzYjdl7CAV0 tAQkPEe5wAlv4DB7uXQGGu+GlFiWlaw/8wujbEp1Ag34aJQ2PyxhgoRR++nO65Qa1cu9 CejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=B79sW9Ps6iAOKNmAAz2ThxzeEaceCSj6vjOfYaotkl4=; b=jsNRCpT58qWGifVMlJ5fLKrGB4pxXFkUNJHZYkETg4QYLS47CJE+0J2mtbMoWGXNP7 RlnthE+0GfcH8QEVv+U4XNCJPJqiSr8GJJfXpMOE7f/7/0dNkDsiHa3eFKTS44X4mlmD 3XvYtaV2MZNUf190iu0OWm6uEVm9EtEhL5TRe1MEMtb22GALfk1H6KJ59pXeU/NkNp5L moWG2ei4sfWPBp8413YihQSWszkYujnyctZ15i8M5vBrC2AoKWJhwVIO3VgZz3xZT+7J E1Vnv64O6dPHLuePBmV7di8/kY3w35DUxW/7OPxmJZneeBtSz5JR0snM8ee6PAh9VdDj Qu+g== ARC-Authentication-Results: i=1; mx.google.com; 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 i127si1393878pgc.100.2018.03.09.15.04.35; Fri, 09 Mar 2018 15:04:51 -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; 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 S932651AbeCIXDu (ORCPT + 99 others); Fri, 9 Mar 2018 18:03:50 -0500 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34944 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932373AbeCIXDs (ORCPT ); Fri, 9 Mar 2018 18:03:48 -0500 Received: by mail-oi0-f67.google.com with SMTP id x10so8195802oig.2; Fri, 09 Mar 2018 15:03:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=B79sW9Ps6iAOKNmAAz2ThxzeEaceCSj6vjOfYaotkl4=; b=VsEHgWB1mPw27IiQG7TFPuxyptdvxihoQyd8Ti8x3g3ZTF4V4c6KiPnckdBNrbyE0T dxpOBAnAsWyRnG/Rf3jSzOZ/QKIHpDEPV7CyLO7LFU5sD2Boix9fnJXId5eDFj5yDYvN jA/MVuIo+ax5sZdd/Zli1N6mFZZZZORVCfxieB8qpgOSUuopH0320S9WtoP4PtB+l7Y/ UZfRXGbbMHylTizOMhjOfUiiA5x50j9w56lhpaOCJdg9KU2dCuvqIenVFdYpRN93SrZV GcRWJ75RWTYFsoooClMnobkntN+gASIiaM9xmsyN4A4JY88u5wLLFWq6FX3d6OQnZsfn ywbA== X-Gm-Message-State: AElRT7E4DxcJA9Y9i18XI2ipFMSjSt1p9UOqfmFJ/yesHAeImWTPt+Lu yB6avp9yDRzGURLZsF36OQ== X-Received: by 10.202.197.135 with SMTP id v129mr100529oif.96.1520636627986; Fri, 09 Mar 2018 15:03:47 -0800 (PST) Received: from localhost (mobile-166-172-122-20.mycingular.net. [166.172.122.20]) by smtp.gmail.com with ESMTPSA id u137sm961939oia.49.2018.03.09.15.03.47 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Mar 2018 15:03:47 -0800 (PST) Date: Fri, 9 Mar 2018 17:03:46 -0600 From: Rob Herring To: frowand.list@gmail.com Cc: cpandya@codeaurora.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 1/3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() Message-ID: <20180309230346.7mphnvsdxugpmtmc@rob-hp-laptop> References: <1520208889-3908-1-git-send-email-frowand.list@gmail.com> <1520208889-3908-2-git-send-email-frowand.list@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1520208889-3908-2-git-send-email-frowand.list@gmail.com> User-Agent: NeoMutt/20170609 (1.8.3) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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