Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4145244imm; Mon, 18 Jun 2018 09:52:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIddaLRxt8tozSrMVVj4burC/WfkArg5grAGBli/7rl27Q6cljZm63N4xBc69yyds83ivJM X-Received: by 2002:a62:c9ce:: with SMTP id l75-v6mr14181645pfk.179.1529340727092; Mon, 18 Jun 2018 09:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529340727; cv=none; d=google.com; s=arc-20160816; b=u2RWTxiipOwE+I5TQ2pDu89g9l8PalxfzYGwtrG7otYnOrSKfIjb9MisrTzK903+XA vs02VS8EIjHbQmq5ZcC6FknPrEuZaEBSRmPWup9SB3fZ6OIz/JvMUQ75pl6+2cBtidv6 N5DGyqDLBaIHzM8sRZlinrLsrxYRVyIr/o0LgmXgPbhhyqWQnXiFpBt8zgpI81i7CBHu d3VR8/C6PpHMYesFqw8DNhLFj0lfHBJBkNShYqG/QwClBSzpn3JM/QWf3QLgsl76UuFx TlAlOw76/+sM4dyZV+3h1R+N74G2arKawuZ9pSoxgJvCC7z87XqPyedsJnQvgRibJPQY A2Yw== 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:dkim-signature :arc-authentication-results; bh=8AXKOX6RMsca04C129BqMUoc/zukJf3mMw0R2YoUaqU=; b=RNlygM4Ubl956MA0gCwrVFLUy4zmVpOhoXjqFscFfNzZ2KDyIn5vfBtEIro3+D+kBx LgG++OkeXThfvUpu2gwwMtr+eLjTSXnZWOO70KhRVsMQHcpKwPo9XDL1NwSjO9O+7Tbi KGKqtAw+E2IHkN50pyfIVlctIMMZ9e/zseNuOPIVmHa0xS4xqRjYtXF/xQJ3dOQVtSCN Lv5DvhU1vjgUhsLAn3ipNhgk/aZiXJRk7iPaoQczYmn4fDrgc4gNXfIAksBaO+noigFV ZJ/56JZlF0V1TZ+iW3+7eOtxpBz+1gGoDYOz8B2ftail0AXN/i7qSFK3OzrSAiY6D3yt OzJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Wnc81QBx; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d37-v6si12867890plb.481.2018.06.18.09.51.53; Mon, 18 Jun 2018 09:52:07 -0700 (PDT) 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=@kernel.org header.s=default header.b=Wnc81QBx; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933476AbeFRQuy (ORCPT + 99 others); Mon, 18 Jun 2018 12:50:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:43012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755119AbeFRQux (ORCPT ); Mon, 18 Jun 2018 12:50:53 -0400 Received: from mail-yb0-f176.google.com (mail-yb0-f176.google.com [209.85.213.176]) (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 4B973208B1; Mon, 18 Jun 2018 16:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1529340652; bh=GFwzWGDN7Vwwmbm2hovlunAW3dXAB2YTMs64Y9Jjdds=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=Wnc81QBxGnAFb0xrCII9FiIhtHKvPBUlMYa6FJzWOrEYHXPmOlLRBX7Vbll6Tl15m D1En7AqHkVhAB8fZs3svSKYDCoVoSuNtiOsDu04ex6FrYQOU5+Kb+O6zRVS+B2RMi9 Y/rGfzYTZOLff5Q0lnNacSXxnE+dW+ZuIrs2Lw3E= Received: by mail-yb0-f176.google.com with SMTP id d123-v6so6207993ybh.9; Mon, 18 Jun 2018 09:50:52 -0700 (PDT) X-Gm-Message-State: APt69E39nFqwB+4lrpZJ7QRDATpwMsdguPn3K7BFWGspO070mPTq3DoJ MAcEuk5G7NW0Ev3mvVlMLkYVQdoXetnU9Q8rK3I= X-Received: by 2002:a25:40c2:: with SMTP id n185-v6mr6798486yba.122.1529340651526; Mon, 18 Jun 2018 09:50:51 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a5b:bcb:0:0:0:0:0 with HTTP; Mon, 18 Jun 2018 09:50:11 -0700 (PDT) In-Reply-To: <1529251416-14814-1-git-send-email-frowand.list@gmail.com> References: <1529251416-14814-1-git-send-email-frowand.list@gmail.com> From: Alan Tull Date: Mon, 18 Jun 2018 11:50:11 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH] of: overlay: update phandle cache on overlay apply and remove To: Frank Rowand Cc: Rob Herring , Pantelis Antoniou , Pantelis Antoniou , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , linux-kernel , Geert Uytterhoeven 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 Sun, Jun 17, 2018 at 11:03 AM, wrote: Hi Frank, Thanks again for the fast response while traveling. The RFC looks good in my testing and review. > From: Frank Rowand > > A comment in the review of the patch adding the phandle cache said that > the cache would have to be updated when modules are applied and removed. > This patch implements the cache updates. > > Fixes: 0b3ce78e90fc ("of: cache phandle nodes to reduce cost of of_find_node_by_phandle()") > Reported-by: Alan Tull > Suggested-by: Alan Tull > Signed-off-by: Frank Rowand Tested-by: Alan Tull Reviewed-by: Alan Tull > --- > > Compiles for one configuration. > NOT boot tested. > Not run through my normal process to check for new warnings, etc. > > It is late, I'm tired, my brain is fuzzy. I need to review this more to have > any confidence in it. But I wanted to get a version out for Alan to see (and > test if he wants). > > drivers/of/base.c | 6 +++--- > drivers/of/of_private.h | 2 ++ > drivers/of/overlay.c | 12 ++++++++++++ > 3 files changed, 17 insertions(+), 3 deletions(-) > > diff --git a/drivers/of/base.c b/drivers/of/base.c > index 848f549164cd..466e3c8582f0 100644 > --- a/drivers/of/base.c > +++ b/drivers/of/base.c > @@ -102,7 +102,7 @@ static u32 phandle_cache_mask; > * - the phandle lookup overhead reduction provided by the cache > * will likely be less > */ > -static void of_populate_phandle_cache(void) > +void of_populate_phandle_cache(void) > { > unsigned long flags; > u32 cache_entries; > @@ -134,8 +134,7 @@ static void of_populate_phandle_cache(void) > raw_spin_unlock_irqrestore(&devtree_lock, flags); > } > > -#ifndef CONFIG_MODULES > -static int __init of_free_phandle_cache(void) > +int of_free_phandle_cache(void) > { > unsigned long flags; > > @@ -148,6 +147,7 @@ static int __init of_free_phandle_cache(void) > > return 0; > } > +#if !defined(CONFIG_MODULES) > late_initcall_sync(of_free_phandle_cache); > #endif > > diff --git a/drivers/of/of_private.h b/drivers/of/of_private.h > index 891d780c076a..216175d11d3d 100644 > --- a/drivers/of/of_private.h > +++ b/drivers/of/of_private.h > @@ -79,6 +79,8 @@ int of_resolve_phandles(struct device_node *tree); > #if defined(CONFIG_OF_OVERLAY) > void of_overlay_mutex_lock(void); > void of_overlay_mutex_unlock(void); > +int of_free_phandle_cache(void); > +void of_populate_phandle_cache(void); > #else > static inline void of_overlay_mutex_lock(void) {}; > static inline void of_overlay_mutex_unlock(void) {}; > diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c > index 7baa53e5b1d7..3f76e58fbec4 100644 > --- a/drivers/of/overlay.c > +++ b/drivers/of/overlay.c > @@ -804,6 +804,8 @@ static int of_overlay_apply(const void *fdt, struct device_node *tree, > goto err_free_overlay_changeset; > } > > + of_populate_phandle_cache(); > + > ret = __of_changeset_apply_notify(&ovcs->cset); > if (ret) > pr_err("overlay changeset entry notify error %d\n", ret); > @@ -1046,8 +1048,18 @@ int of_overlay_remove(int *ovcs_id) > > list_del(&ovcs->ovcs_list); > > + /* > + * Empty and disable phandle cache. Must empty here so that > + * changeset notifiers do not use stale cache entry for a removed > + * phandle. > + */ > + of_free_phandle_cache(); > + > ret_apply = 0; > ret = __of_changeset_revert_entries(&ovcs->cset, &ret_apply); > + > + of_populate_phandle_cache(); > + > if (ret) { > if (ret_apply) > devicetree_state_flags |= DTSF_REVERT_FAIL; > -- > Frank Rowand >