Received: by 10.223.185.116 with SMTP id b49csp1207422wrg; Fri, 16 Feb 2018 14:35:51 -0800 (PST) X-Google-Smtp-Source: AH8x224d9R9Ul+OUthhPZmqCUxj05BRUNuL0MY7DIBYps8Z6jzP9GavTfOUmD2hU+6d4NlW/Gl49 X-Received: by 2002:a17:902:8216:: with SMTP id x22-v6mr3145027pln.439.1518820551732; Fri, 16 Feb 2018 14:35:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518820551; cv=none; d=google.com; s=arc-20160816; b=WexR0Cv+v8TTiUYae5g/LOStgDXp6302LCxkRiWmg+w7Swx/4J770mkeKc6HMILPpX dBpDzjuqtjZ2sCmK76F/jwxOdYsTkzsXib6lWTUqu26c9nr2KsmhmaIbnkRLgo+X+VnM rXo0pa0Q2yFbQYYpX/NiOANGN6fEOvqDC4LVIBBAg2yennVoWM29MhyxVqXAMIw0wCRL fWfQF54qnNMNyl7310bH0Wi+K0KS+TC0iIY7Bql3c9f5m4wv/bekej/z31YilsZLTr3m yb8UjP1mDqf2vHbNeiOSWq+ij39vWBD9ZyJ34BjKtkqcgdcGShbKGBuF6wY9yPIpUyHb C8vw== 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=28ohJTwdNCs+rOq4xrFPKztKzyfanmgB3AkGIgw9zeE=; b=vT0xxeG0ZAuuHBWqlvqqUI1YdCqdwOZuzWzT5SvhDek5n4J3267CTiOnpnL4RJAXYi Hq66HQY3rgBqf51eUFWgLiUqvNCbHH9KnNgYNm6EKVfcH1OW7bxjc/+ldCeaxPM7IwrF 79u6AOdPzkfSFd3MbBrybzr9Tw2bu8d4kNKPTGT7rFxAWvg7ah89AL1REQc2mU/etOzE VfKIJzDwZ89JGVDilvDGAVmEKQGOmW/g6vu9yGUqsJHYNxklwgJ+i7GX+zIGvLFmWN5m 9iGnI+EVOPDqVLQcBwNOdTLqp/uR4JpsuHa+0yb5ss/BSZg2QDwNCR1Bm8q9P4DCRxaR nwEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b4Z8eX6Q; 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 41-v6si372133plf.521.2018.02.16.14.35.37; Fri, 16 Feb 2018 14:35: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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b4Z8eX6Q; 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 S1751023AbeBPWdg (ORCPT + 99 others); Fri, 16 Feb 2018 17:33:36 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:46810 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbeBPWde (ORCPT ); Fri, 16 Feb 2018 17:33:34 -0500 Received: by mail-pl0-f67.google.com with SMTP id x19so2415115plr.13; Fri, 16 Feb 2018 14:33:34 -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=28ohJTwdNCs+rOq4xrFPKztKzyfanmgB3AkGIgw9zeE=; b=b4Z8eX6Q2iG/U6QHMoynNK821nOTLaIjOQOrplioAm3pkkCItd8bl2bMAAnkbHqv1k 0OxSRnnOGLHZINEl53doyOibgwrApFyi8zTFuoExu5pmYcx0BM/K6LrXorJ0kt/Ks8Jx 2adn4BrjOHluoSBDSwcG7kk0D9FwbUykvKD+nAEv/R2swaMtCSSMyQA8X2aUtjAYsNB8 cSLj6zuXtGpjnFknBWty2zsvmwVcC+LngIpCqVRqxEwgdb0jnxZvdLIX2xE73bYTw2U0 kasQnpC5q8uieopDQI3WyNyo8ZrwK0FwuUvhz4AfbJUE+cAU93KD4AtssUABvKFa0MQC Hq/Q== 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=28ohJTwdNCs+rOq4xrFPKztKzyfanmgB3AkGIgw9zeE=; b=FcnkwpGAHezYH6bBOMKQelxLVXsBDnOZNe03firSkEBSgyJYSQW4FLYtVY8L3Vqnv7 LdCjubauwJNE723U3898cr05SU223avSfyY1u7vYQ8C3i3DYb3Ae72LMKK+Xyf8PkYHN T6Ota5sV5E5liyZemrT4EM3hcT0G3SbLeO6dom0IZU8WSgBE8IPT6JNeDR103vuUdtrq 0NAjdXM7lQYLQCKbcwxp+PSfZdSYp9+yj2bEeSRc/NzSJ/E9TXJwpPVeXjTCJVi2Q5ZG 7lUDl4P1ltk4cHMLLhKrdUFjkd3UpLEDvlWsAcjdUyb0RtgSR9UOshzMcWXcwdeBjUWS jq8Q== X-Gm-Message-State: APf1xPB0JTwBcnjrH0MSzzm8Y1rwVwl+x/i+zUfxec/gcSMVW8NBey2Y kT886d22HmLdiS0Co6Ii/gP90Pfv X-Received: by 2002:a17:902:367:: with SMTP id 94-v6mr7275788pld.140.1518820414053; Fri, 16 Feb 2018 14:33:34 -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 v186sm43383816pfb.5.2018.02.16.14.33.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 14:33:33 -0800 (PST) Subject: Re: [PATCH v3] of: cache phandle nodes to reduce cost of of_find_node_by_phandle() From: Frank Rowand 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> <46d5fc76-33e3-d54a-26b8-e9bb8332924d@gmail.com> Message-ID: <40e5df43-4422-9209-01c8-3aea487da722@gmail.com> Date: Fri, 16 Feb 2018 14:33:32 -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: <46d5fc76-33e3-d54a-26b8-e9bb8332924d@gmail.com> 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 14:20, Frank Rowand wrote: > 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 ^^^^ this > 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 > >