Received: by 10.223.185.116 with SMTP id b49csp1918012wrg; Mon, 12 Feb 2018 00:44:23 -0800 (PST) X-Google-Smtp-Source: AH8x227imk43wdJ4HotqT5xz8Sk1b3lOVAWIjCCivzMGY/V11MJ5SsmokCPBA1qp6pLBDp1xbjid X-Received: by 10.99.143.69 with SMTP id r5mr8710546pgn.160.1518425063293; Mon, 12 Feb 2018 00:44:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518425063; cv=none; d=google.com; s=arc-20160816; b=i6fC0nn5zlZIrERPRfV4TOJ7lIeQ5xx5Z1XwaB/CHyXuGQf+1AGtkIggerXJ3zN9el vk+4e/mVkD2x6skcS+gz24xThDafmum3m9HOvm8soaVYmKv9n7JvseglipJORic8+Eja I7zMg//Lqxse7NE6eqtr7dmC/F7hwdJ0FCEM7wUlf5/O1aCd8Iti1HW8dJsEnf58cTwd jex8LWeeiQ0pbKLYl6ZuumfiE9aVigsHYFzBQlQsxhLqOqvO3lMsxysXXMEP5KeWeQSE Exf3esuk9EC7hCmqLldCBDxY9viKu8YgQdhAGJgdczzypR4tCc4CvOs3QpUrNgB79oiS SbmA== 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:references:cc:to:from:subject:dkim-signature :arc-authentication-results; bh=OAPmFJsYPFxXL9qDNoiPBSKUxn9WQ4vZrRh4KhhP6fc=; b=VtmQbvIljfpMYKZqlV+qSJ341I3h7tssDVOFx6hmRz7rBmWEKoIApPySqwYjPYeUWg QKZ0nmft6aEzVFzIsScegb9lY4gH3Oupd0sZx122N1vNMEYZuWzABPPeyh+B0MmKu0eV BnNIZg5WRlbxIfbEw1VaA0mvzNs6jZCqDtFXyHIA4lzWvpI86XF98KQ1yCF/M9Tfp0jU 0m1Byx0npcis48qFqeNgsTmVnP28nM/bai7QCu+0ATSo7XzrZtIZErJn+OAkGUoZAupD rzrviutRahcDXvW5c7iy2iFG1CyGBpbxZd2FxpV/aW8SSKavTHDE2UUZOJkg1ainTmDo yV0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b+UT3svc; 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 206si3214774pgb.647.2018.02.12.00.43.57; Mon, 12 Feb 2018 00:44:23 -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=b+UT3svc; 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 S1751549AbeBLG7B (ORCPT + 99 others); Mon, 12 Feb 2018 01:59:01 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33241 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750768AbeBLG67 (ORCPT ); Mon, 12 Feb 2018 01:58:59 -0500 Received: by mail-oi0-f68.google.com with SMTP id l8so10392490oig.0; Sun, 11 Feb 2018 22:58:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OAPmFJsYPFxXL9qDNoiPBSKUxn9WQ4vZrRh4KhhP6fc=; b=b+UT3svcUXoEvxZvwfBHj6NKIRq4oQ9gIQ/pt4b8Evslvy4eFyq0/9tbYXcKgXzN+5 8d3f+LV5Cl988IAE/5WH9m3+GB/Ya14T/LUuiRdQAyhHUPI39eSzmiW3FtNW1Z0pNwiK MBAlWus0xicVJkCjkwaD7VZ1q1ih/SMHvDRRL6ugxksAIyxJ5gVJXJH66pb63Y4pdEEH sczeCj1hdy4dNWueMJ7NJY8CH8ANr0wM8PHyO4Pz6yte1HG5vWF5q5ryfK+K/at5VNMe Nmw1a0e+8vSKfzBga7u0VUPrER2djVJFpgXC1csq0mumRu9azz3tuRpllNEGWznB1dH3 ZucA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=OAPmFJsYPFxXL9qDNoiPBSKUxn9WQ4vZrRh4KhhP6fc=; b=RBA8bBwmqim4SiTrKOuotkl/4oKGBA5gvsuZ7IHq3biVK8QJO8UGtHy02kE2vbLekM sRhNykhvRdOnfQaXQPMgbOcKjpeXQCHtXSa7eZ2UC+K4LfFrZ+zOGux/vFIF0znGedQw 1OrVlR0zN9zFKnwLr/lF6t9QiTt/8vqepuytYDvPcd1q/oR8sF6jQc6dsxEZlRy+uuSL c3phK7m52uKHH71ZFIuOWfd3vFNiv89+T4nQDqlqUtqmB5Pr8ELdlQN5bIN94ta1uC5Z D1b3HLvJXspvUqCQYNxFS344SOBMzP3Jt+W3BW7dxAf40OmPRXRSCXupJfJv89I45zod S3Hg== X-Gm-Message-State: APf1xPAvqorhJxG/YnCyT1Ge2jWmzcAWnMmrPu4GA/cS3lrf0y0YA5D/ 8lID7OpwFdKSdyx4Uljhop0= X-Received: by 10.202.87.203 with SMTP id l194mr7462467oib.356.1518418738953; Sun, 11 Feb 2018 22:58:58 -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 m22sm4241907otf.18.2018.02.11.22.58.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Feb 2018 22:58:58 -0800 (PST) Subject: Re: [PATCH v2] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() From: Frank Rowand To: cpandya@codeaurora.org Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org References: <1518416868-8804-1-git-send-email-frowand.list@gmail.com> Message-ID: Date: Sun, 11 Feb 2018 22:58:57 -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: <1518416868-8804-1-git-send-email-frowand.list@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/11/18 22:27, 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. > > Signed-off-by: Frank Rowand > --- > > Changes since v1: > - change short description from > of: cache phandle nodes to reduce cost of of_find_node_by_phandle() > - rebase on v4.16-rc1 > - reorder new functions in base.c to avoid forward declaration > - add locking around kfree(phandle_cache) for memory ordering > - add explicit check for non-null of phandle_cache in > of_find_node_by_phandle(). There is already a check for !handle, > which prevents accessing a null phandle_cache, but that dependency > is not obvious, so this check makes it more apparent. > - do not free phandle_cache if modules are enabled, so that > cached phandles will be available when modules are loaded > > drivers/of/base.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++--- > drivers/of/of_private.h | 5 +++ > drivers/of/resolver.c | 21 ----------- > 3 files changed, 94 insertions(+), 25 deletions(-) > < snip > Hi Chintan, Just as in the previous version, this part of the patch will not apply on older kernel versions, and can just be deleted: > diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c > index 740d19bde601..a7580c24737a 100644 > --- a/drivers/of/resolver.c > +++ b/drivers/of/resolver.c > @@ -19,27 +19,6 @@ > > #include "of_private.h" > > -/* illegal phandle value (set when unresolved) */ > -#define OF_PHANDLE_ILLEGAL 0xdeadbeef > - > -static phandle live_tree_max_phandle(void) > -{ > - struct device_node *node; > - phandle phandle; > - unsigned long flags; > - > - raw_spin_lock_irqsave(&devtree_lock, flags); > - phandle = 0; > - for_each_of_allnodes(node) { > - if (node->phandle != OF_PHANDLE_ILLEGAL && > - node->phandle > phandle) > - phandle = node->phandle; > - } > - raw_spin_unlock_irqrestore(&devtree_lock, flags); > - > - return phandle; > -} > - > static void adjust_overlay_phandles(struct device_node *overlay, > int phandle_delta) > { >