Received: by 10.223.185.116 with SMTP id b49csp1196940wrg; Fri, 16 Feb 2018 14:21:18 -0800 (PST) X-Google-Smtp-Source: AH8x225HS1DpB8pXrpBwebKSO8GcajuEpsXhhcEPqZ/cLPAxbQe4mKl+E6TYYQd+XH8ZbDD0SCs6 X-Received: by 10.98.103.136 with SMTP id t8mr2446182pfj.177.1518819677983; Fri, 16 Feb 2018 14:21:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518819677; cv=none; d=google.com; s=arc-20160816; b=bCoB4qJaA2vOfHXKL3ctYwzDG8ZZsCswI8+dIOjgTxXLiojXZUTwvDCxbbzMDDiPtb wW0wkIfEp2qkHrTF95vFRYglzzaXCTBkIqua4YMBttkfZw2CSVUNxK3DkswPI3xJv3wg +NbcCYEi+eZ9D6EhBd5+uJnbPw5QMcIisj3Tuh+TV3kdFYiti7hRLmqgX3eyxHEtlBWU FCEsotM9+gMjx6wopHoXidd95aUITBZlcdtMbbS0H/ug3eqyVuNvKLauNpntM2O8X+0E TK+WCtdzriKm9PruEhyrpgdUFQ4tsdLunSookzNRqUSSWN6WJVnrbd+MTqqMLGS+k8It HLcQ== 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=at3RyIMWDT3MZmmDSmEM723DEdnn0exYKi7/T65tSfs=; b=kj4zhBW7I2fVoMGYh9L6prNxqefdXFngeCPDMGx3hB7LD1JKfU3VbgzHBUS46nIj/a Gxr0LU/Wi7VUTnKoPgnTgGR/D9OEO7kyi164QiMhCb2UWNGH7wDq8KVgH3jfTDD/S/wm BS94TYQNWPA3Ad8eggvP47XvZ83hDVPD3xAwd1xhydgxpNBvKFmGMnesZ94qpjVzulRd HuF+wS8DXlMZJb63O0Pow0ifNGzaqHM4eJPdGX00b4nzeZV61l/QMyzbckBBxtjqp9QQ Zy1mUacadA46pQ58wa9hnxq1uFjNN5D1HXMRpb3lHXTD7Sefih51p8MS/ozVp9ls/s+5 oPpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S8DBRSfG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r11-v6si1309375pls.318.2018.02.16.14.21.02; Fri, 16 Feb 2018 14:21:17 -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=@gmail.com header.s=20161025 header.b=S8DBRSfG; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750813AbeBPWU0 (ORCPT + 99 others); Fri, 16 Feb 2018 17:20:26 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:33272 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750727AbeBPWUY (ORCPT ); Fri, 16 Feb 2018 17:20:24 -0500 Received: by mail-pl0-f68.google.com with SMTP id t4so2420279plo.0; Fri, 16 Feb 2018 14:20:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=at3RyIMWDT3MZmmDSmEM723DEdnn0exYKi7/T65tSfs=; b=S8DBRSfGvDdFKwRXyuUADH8KemcqVCGGglxrrWZ3XPZxssQCdCaDPLp+cizok2AO8B bgXFC1klscvbMeG8ygSDn1TrD8Nt1siLTkQNVDIiFNQZo8nkRyJwS7xpq+nA11O2iZ3R 7yZ3lmZlD3Skt8YyOq9C3faWW+CsnPuXYWTRAimK2xv4xLvu3VeGib7z5kna4uGfgmJS B3CQ0Njo4pUk3CITSHHRP5k8TbVoqQ7sfbWuINOBWH9l/HdNeKy3ioor6HvoA6KDLijX yMfG9ZncC4aG7HLhLm3F8sISaUNTFGAOohgzIAlrsz+kA2bjDFR1v1yPUDorXVoJu0+Q Holw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=at3RyIMWDT3MZmmDSmEM723DEdnn0exYKi7/T65tSfs=; b=LQtV5IH8iSLL6rcEm7JYvfX5uGPNq4rkxvpal4wYqkW7OdHJsIct9NDy0U4i5/RQcA FUkeoTxV7dADr3qchGUahjOjlfcrvoqhRwjMGNcRkRUIOI4mrCw8fjIlOZklcinu/3rK MP6q24QN3YEcp3LVwvtNNXtJ0O8f8Dq1PsevwjttDpQ3qZyf3Ukbk7ZcCYfZF+lqLgq6 MNUfRnIw4+h1vIEd72XtmgXVY6IIBtcfo/9ymf2o6FXSvSn+PLqC1pk9em2nZsKVwqxc afmWbd43ookMK4udRb9OlqKzMlCaV6kED7ctcby/d49C6mkyoaERHXZynzHiEaEo0+lj sxHA== X-Gm-Message-State: APf1xPAI45C6gGIrHyj5P5Vkhozbsz1TbqBxYGJ7k6o3GP+LISv+L66o c72MM8dYin9aFUYBJzyRK5w= X-Received: by 2002:a17:902:930a:: with SMTP id bc10-v6mr7227377plb.19.1518819623878; Fri, 16 Feb 2018 14:20:23 -0800 (PST) Received: from [192.168.1.70] (c-73-93-215-6.hsd1.ca.comcast.net. [73.93.215.6]) by smtp.gmail.com with ESMTPSA id z25sm45312720pfe.0.2018.02.16.14.20.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 14:20:23 -0800 (PST) Subject: Re: [PATCH v3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() To: Chintan Pandya , Rob Herring Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1518655979-10910-1-git-send-email-frowand.list@gmail.com> <207e055e-1074-9010-e719-2a4c13ede9f9@codeaurora.org> From: Frank Rowand Message-ID: <46d5fc76-33e3-d54a-26b8-e9bb8332924d@gmail.com> Date: Fri, 16 Feb 2018 14:20:22 -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: <207e055e-1074-9010-e719-2a4c13ede9f9@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/16/18 01:04, Chintan Pandya wrote: > > > On 2/15/2018 6:22 AM, 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. >> < snip > >> diff --git a/drivers/of/base.c b/drivers/of/base.c >> index ad28de96e13f..ab545dfa9173 100644 >> --- a/drivers/of/base.c >> +++ b/drivers/of/base.c >> @@ -91,10 +91,69 @@ int __weak of_node_to_nid(struct device_node *np) >>   } >>   #endif >>   +static struct device_node **phandle_cache; >> +static u32 phandle_cache_mask; >> + >> +/* >> + * Assumptions behind phandle_cache implementation: >> + *   - phandle property values are in a contiguous range of 1..n >> + * >> + * If the assumptions do not hold, then >> + *   - the phandle lookup overhead reduction provided by the cache >> + *     will likely be less >> + */ >> +static void of_populate_phandle_cache(void) >> +{ >> +    unsigned long flags; >> +    u32 cache_entries; >> +    struct device_node *np; >> +    u32 phandles = 0; >> + >> +    raw_spin_lock_irqsave(&devtree_lock, flags); >> + >> +    kfree(phandle_cache); > > I couldn't understood this. Everything else looks good to me. I will be adding a call to of_populate_phandle_cache() from the devicetree overlay code. I put the kfree here so that the previous cache memory is freed when a new cache is created. Adding the call from the overlay code is not done in this series because I have a patch series modifying overlays and I do not want to create a conflict or ordering between that series and that patch. The lack of the call from overlay code means that overlay code will gain some of the overhead reduction from this patch, but possibly not the entire reduction. > >> +    phandle_cache = NULL; >> + >> +    for_each_of_allnodes(np) < snip >