Received: by 10.223.176.5 with SMTP id f5csp2818651wra; Thu, 1 Feb 2018 06:35:46 -0800 (PST) X-Google-Smtp-Source: AH8x224gKOTMdDVppngzhaiDdOyMdY/W0vZaWNbdDZV5SxprpHEleiJhZjCyAEOcjM89EjosOLs8 X-Received: by 10.101.65.9 with SMTP id w9mr29181353pgp.214.1517495746016; Thu, 01 Feb 2018 06:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517495745; cv=none; d=google.com; s=arc-20160816; b=s/eFpUyJ7QmFA/ENlvIK4VgWpnEBNqEf3vkFC19P0YxR/H+xrV4Bt7eAMEkL6gTUSI +NowHAq8K3G8Ige7SJd1M63mcdKbvHItsUyFp5gqmUs/z7mrWT/ydaxcKEtIbrRnx34O 4+F6nX9qs+oBy3gMWmmNYD4GJ/9lqhDl04dB2nuehQ0BiI8XTwOpzyapvsWfTugvqWo5 QiA1FYHoJo8sfvdTv0kgPAhvY86ghfBPOzlXYqAtc8+emQ5BivR8bSAMRkWt39Imyozl cLdm5jMdUhm8fLV5SoL94r+tKfNEv0joo0Au1F6caq0zvsJJOuGHkzUYXtQZFbuAL4bK oqwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dmarc-filter :arc-authentication-results; bh=T3aqPO0p151juKaMh1VTKEZB5G6q51kdXulknANXWvY=; b=mTsRIeuYCAguPIBBuR4/WtbYcYJa2b0rCMgADsS0I+Faz+mux7cXjEYyl1CCYJAvz5 8NHPmV8eJ2KfytKx4KcRdvFOTeck9V4WgU+E6SF1hnWah1UUOFdzVrRCrbSbT8KjlNyo jgQf1WHR/evu0xSGe1clrNyxJHCokMdftID0Dr9ouDVgBZ0pa+sOek5ilsA1uqXTqbKd SOX4yB/UHcGO32od3A3ajrohIB1R4tqm3B8Tj0Bwn/30dQAJHN+0UOtJyRiMkJ5UnDEP pFw0MiKOJ5vwqZH9uqHDue9e3olV3DtGBd9t4yDZItho7/ZC+9xV4uKBa738/JtQxBPR JBNw== 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 30-v6si1597879plc.548.2018.02.01.06.35.31; Thu, 01 Feb 2018 06:35:45 -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 S1751690AbeBAOe6 (ORCPT + 99 others); Thu, 1 Feb 2018 09:34:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:57782 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751378AbeBAOe5 (ORCPT ); Thu, 1 Feb 2018 09:34:57 -0500 Received: from mail-qt0-f181.google.com (mail-qt0-f181.google.com [209.85.216.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5C13F217A0; Thu, 1 Feb 2018 14:34:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5C13F217A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=robh+dt@kernel.org Received: by mail-qt0-f181.google.com with SMTP id z10so26661583qti.5; Thu, 01 Feb 2018 06:34:56 -0800 (PST) X-Gm-Message-State: AKwxytezJGyYXjkcL2AtmafQWKeIrsfXSEOxCIJEdD9GJW18tgd4csEh NxTbhVLtTMWfyn6KXmcpuQQ/owWVtLtC/90Gdw== X-Received: by 10.200.26.69 with SMTP id q5mr55720954qtk.174.1517495695543; Thu, 01 Feb 2018 06:34:55 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.147.20 with HTTP; Thu, 1 Feb 2018 06:34:35 -0800 (PST) In-Reply-To: <1517429142-25727-1-git-send-email-frowand.list@gmail.com> References: <1517429142-25727-1-git-send-email-frowand.list@gmail.com> From: Rob Herring Date: Thu, 1 Feb 2018 08:34:35 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: cache phandle nodes to decrease cost of of_find_node_by_phandle() To: Frank Rowand Cc: Chintan Pandya , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jan 31, 2018 at 2:05 PM, 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(). > > Signed-off-by: Frank Rowand > --- > > Some of_find_by_phandle() calls may occur before the cache is > initialized or after it is freed. For example, for the qualcomm > qcom-apq8074-dragonboard, 11 calls occur before the initialization > and 80 occur after the cache is freed (out of 516 total calls.) We should be able to do this earlier. We already walk the tree twice in unflattening. We can get the max phandle (or number of phandles IMO) on the first pass, allocate with the early allocator and then populate the cache in the 2nd pass. AIUI, you can alloc with memblock and then free with kfree as the memblock allocations get transferred to the slab. Rob