Received: by 10.223.176.5 with SMTP id f5csp3246331wra; Thu, 1 Feb 2018 13:15:12 -0800 (PST) X-Google-Smtp-Source: AH8x224+Yok/zjz7T8FGcD3SA3VkZBkpfYpTlk9MwlsWD6S1VzSkqMDJ2ZajyfgPSTRL5TbDeWZd X-Received: by 2002:a17:902:868f:: with SMTP id g15-v6mr30752117plo.137.1517519712479; Thu, 01 Feb 2018 13:15:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517519712; cv=none; d=google.com; s=arc-20160816; b=FgPo4Lv2TGe0OwjdpKBE5gvWDI8Ka4ikIZW+ljhFcFW9fR9D4dg6Mf8tkOhQFW4xwr s3Ys10qw4QR6NwtcjpBjuhKOGuealZyQ9WDmAvNDJZbJkjTXrfFGbAnNWOGXNJ3RvDr3 NJJn7WLZuEVLZfTNc1QiXbDU0aUIwTiViB1fyIR0KFk+BmL5fOK6GAlsnXqpXPRFrx6V o3Pq34DquvuGwiSM4Ayvnl02qNNW/IR5Tvz0c9+1/aV0NdNH6546ry9pNrwWKXAHvHdo eSQklh6G8UhdLbUtDN1YBEkTXdoSIUU157dMbaBYAHQqABz3Nt2a+/+uRvxO8QBJ+sSe 0fhA== 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=AnOjsqxZqF5vmLnwBiWCFzNLX6dyd17z1ePxXWb7kAU=; b=NE3h0Mt6pbxoWCTjX8XOnGZzeyGpPyZNCRoeq9RIsoQ9YacFs8RzhxK586X2OxWZYG plVJi4sUetgJKvkr+gquOWbgFriq8hY0DCkHfJ0FS/k5UFGAwztsYKlEI7TL1hnFMi1R RwHqSqXndoWFe4RVeVrsZbJIcWzPH9UM/aIGQCf6gkRROD7cAhPjO4/zV8hZw7+OqNL8 MBbAFKGDNQHe/9/u5CwnGsClqeuEy096i0UBooDWp4KUFUveKW616onO39a7UeUHFCF0 qtU3rQ/DxRXqtYWN9FwttPaWzj7Rbc7L3NxMqmYQqVqBwWpsme9IDC3JCEb5cVfxuhHf WB/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HyvjrsC3; 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=NONE 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 w85si378082pfi.137.2018.02.01.13.14.57; Thu, 01 Feb 2018 13:15:12 -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=HyvjrsC3; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751904AbeBAVN4 (ORCPT + 99 others); Thu, 1 Feb 2018 16:13:56 -0500 Received: from mail-pl0-f68.google.com ([209.85.160.68]:45803 "EHLO mail-pl0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751575AbeBAVNv (ORCPT ); Thu, 1 Feb 2018 16:13:51 -0500 Received: by mail-pl0-f68.google.com with SMTP id p5so4490169plo.12; Thu, 01 Feb 2018 13:13:50 -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=AnOjsqxZqF5vmLnwBiWCFzNLX6dyd17z1ePxXWb7kAU=; b=HyvjrsC3Ue60czopl1OzJw5DxXgtzhp5kntSnOs71HJI2OtXvbbjfCB4C5/hgHIqDv OqoZ8RnpJyTivAhzLOdtInnE0tT3aHgscvXzdsAqmyDIF+3S1WzP0vxBMcteWgX6eiHy iVN2PLQR0poIpjQV6RPOSt09R8DKnwejRj940JSxUO8eA5lKLdXN7cIaj2jSxjrrGXxF SnkJG1hKz2YKKY5tW662PGMpGhDMHoZVhP0S4K2od9UG/OOMikmJJD718DhErOZKcYV7 aDw2Erzvdmsf725ESFhAPu8EieUDVSQ4WYTSNQBz6pHqrVk+1JTBdZk4G+6Q6QQ8hcWZ ivRQ== 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=AnOjsqxZqF5vmLnwBiWCFzNLX6dyd17z1ePxXWb7kAU=; b=DR+yhIlNwV2e9Ud8HrOdMYwJRueJlY29Nd0m5bM2ba0WkgvpXHzYNwEaxbpJ2qHHk7 53juwcel0OxUTtXL4sBZkpYzZ6ZcwadnIPbrf+DSZ0P3FzE5Di/F+wh9hw41Sdly4thy tKUm7oCGs+yh8sjO814fEhDtW0SXKAhekY5CXmgAd34YjkFz7hauBdsru81B+83lj8hF 7+qfuahAOq7BwEgXulixQQEF4Dexw70TCVnFwSrIZtkv3NG9X+cpQP9f4Na5SM/vEY1y HyybSWMSE9DYVZq0jwVSrbj+nKYpZ05IWkGIpcKBsz/9zHg6CJ6HzMEJK33FFCVn5/5H CPzA== X-Gm-Message-State: AKwxytebGuXqbh3zQHPvM6DSgYtIOetqZl8LOrGStZgrH2wG3KCtUFVp pzbV/3+MlOyzLyCIXMS/u4I= X-Received: by 2002:a17:902:b189:: with SMTP id s9-v6mr2491289plr.243.1517519630705; Thu, 01 Feb 2018 13:13:50 -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 r81sm25755pfe.157.2018.02.01.13.13.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 13:13:50 -0800 (PST) Subject: Re: [PATCH] of: cache phandle nodes to decrease cost of of_find_node_by_phandle() To: Rob Herring Cc: Chintan Pandya , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" References: <1517429142-25727-1-git-send-email-frowand.list@gmail.com> From: Frank Rowand Message-ID: Date: Thu, 1 Feb 2018 13:13:49 -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: 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/01/18 06:34, Rob Herring wrote: > 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. Thanks for pointing out that kfree() can be used for memory alloced with memblock. I'll change to populate the cache earlier.