Received: by 10.223.176.46 with SMTP id f43csp2228213wra; Thu, 25 Jan 2018 06:52:08 -0800 (PST) X-Google-Smtp-Source: AH8x225I8gy8dDvRIFjEWUoTrn6YnyWAujekhWqsjyRebHvl/eeS6J3AydTPW/FoO/qy2s+hcRXx X-Received: by 2002:a17:902:5a41:: with SMTP id f1-v6mr11687310plm.201.1516891928431; Thu, 25 Jan 2018 06:52:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516891928; cv=none; d=google.com; s=arc-20160816; b=cC/8ePB1M27Td+2EonG/RfKUrxuJmfA1MoZReGvX8mDcZSrnATMBqlyl6zBAP6E9RZ YI9Klb4kUwjIiHjinzLzSsyhEkzjWLzS2/AXO5F5CmX5qAEBnd0ZveVdLfTiK+DqOzk+ PGhk7COk7xnhSJu01WThp7R+//kpf37WEI6TLOFLKqY2ekSZdsQ/+9ZM/+FU290Ixw82 H6iwgdoIjoAcfUkGkXtPX81rLayWpTeSHA1TwErINicQ4UkevER1UK8Wjq/832panhYS IrxiErGs7G4xzLyFEuxdHVppMzHvNHIZEEXfSuTMbZ/Th8eviRcSmiMI+HIg/i0BdjmU cqiA== 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=nLNLzqr93rwb8VG+jEXLjJpW0kShv+I7A6P3v+Dg/Q8=; b=GWA0Uh1jTHEPISg99+ljGYMBrAduKj1z2ev6GZwATbvBYH9reURjKTYEi78RD7v6/S 2TWMitOmVjGVWwDro/gQsVPP1RRwqT5mEAZVCYjBSycGekqeGo2ACIXvKE2w+s1fJ8Du 9Glyv/I03fcHzSqjgHWETYCSmIJihGqJeebZcKjW3S2O+qUDZ0Wzcg/e/Tp+r1y5iUV3 hfE2eaxLs+AKZWV/Wj9QjInAHjG9jPU1TuqDnC+eQxdZYi8f/pav4LOH0tZUWRxW4QXQ IMrRHETRIRT44SJ92S8F01+wBIdkguT/+ZTW/lSYbBQnH9iWDStvcAo1zNfwgG197cNR cyvA== 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 l185si1649652pge.147.2018.01.25.06.51.54; Thu, 25 Jan 2018 06:52:08 -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 S1751636AbeAYOul (ORCPT + 99 others); Thu, 25 Jan 2018 09:50:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:59240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751241AbeAYOuk (ORCPT ); Thu, 25 Jan 2018 09:50:40 -0500 Received: from mail-qt0-f180.google.com (mail-qt0-f180.google.com [209.85.216.180]) (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 B5B2C21796; Thu, 25 Jan 2018 14:50:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5B2C21796 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-f180.google.com with SMTP id c2so19734375qtn.9; Thu, 25 Jan 2018 06:50:39 -0800 (PST) X-Gm-Message-State: AKwxytc0B9n2dNnqclhtQkyHJJidMTHsuxhU9exKgS1JEPG7IRBx/Jgz 7ESPx7nIdGCG9dL4red5RVQWK0EOPs3t5soG8w== X-Received: by 10.200.64.90 with SMTP id j26mr17834978qtl.29.1516891838928; Thu, 25 Jan 2018 06:50:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.147.20 with HTTP; Thu, 25 Jan 2018 06:50:18 -0800 (PST) In-Reply-To: <1516875247-19599-1-git-send-email-cpandya@codeaurora.org> References: <1516875247-19599-1-git-send-email-cpandya@codeaurora.org> From: Rob Herring Date: Thu, 25 Jan 2018 08:50:18 -0600 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] of: use hash based search in of_find_node_by_phandle To: Chintan Pandya Cc: Frank Rowand , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , "linux-kernel@vger.kernel.org" , linux-arm-msm 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 Thu, Jan 25, 2018 at 4:14 AM, Chintan Pandya wrote: > of_find_node_by_phandle() takes a lot of time finding Got some numbers for what is "a lot of time"? > right node when your intended device is too right-side > in the fdt. Reason is, we search each device serially > from the fdt, starting from left-most to right-most. By right side, you mean a deep path? > > Implement, device-phandle relation in hash-table so > that look up can be faster. > > Change-Id: I4a2bc7eff6de142e4f91a7bf474893a45e61c128 Run checkpatch.pl > Signed-off-by: Chintan Pandya > --- > drivers/of/base.c | 9 +++++++-- > drivers/of/fdt.c | 18 ++++++++++++++++++ > include/linux/of.h | 6 ++++++ > 3 files changed, 31 insertions(+), 2 deletions(-) [...] > diff --git a/include/linux/of.h b/include/linux/of.h > index 299aeb1..5b3f4f1 100644 > --- a/include/linux/of.h > +++ b/include/linux/of.h > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include > #include > @@ -61,6 +62,7 @@ struct device_node { > struct kobject kobj; > unsigned long _flags; > void *data; > + struct hlist_node hash; Always base your patches on the latest -rc at least. This won't apply. This grows struct device_node for every single node which we recently worked on to shrink (which is why this won't apply). So I'm now sensitive to anything that grows it. I'd really prefer something out of band. I'd guess that there's really only a few phandle lookups that occur over and over. The clock controller, interrupt controller, etc. What if you just had a simple array of previously found nodes for a cache and of_find_node_by_phandle can check that array first. Probably 8-16 entries would be enough. If that still has too much trashing, you could also have a lookup count for each entry and expel the least used first. Or maybe the list_lru would work here. Rob