From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D058C4332B for ; Thu, 14 Jan 2021 02:02:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 575DC23447 for ; Thu, 14 Jan 2021 02:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729789AbhANCBi (ORCPT ); Wed, 13 Jan 2021 21:01:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:51468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729470AbhAMXZG (ORCPT ); Wed, 13 Jan 2021 18:25:06 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 32DEC233ED; Wed, 13 Jan 2021 23:13:49 +0000 (UTC) Date: Wed, 13 Jan 2021 18:13:47 -0500 From: Steven Rostedt To: Al Viro Cc: LKML , linux-fsdevel@vger.kernel.org Subject: Re: [PATCH v2] fs/namei.c: Remove unlikely of status being -ECHILD in lookup_fast() Message-ID: <20210113181347.633356a7@gandalf.local.home> In-Reply-To: <20201209170928.26b4cda7@gandalf.local.home> References: <20201209170928.26b4cda7@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ping? -- Steve On Wed, 9 Dec 2020 17:09:28 -0500 Steven Rostedt wrote: > From: Steven Rostedt (VMware) > > Running my yearly branch profiling code, it detected a 100% wrong branch > condition in name.c for lookup_fast(). The code in question has: > > status = d_revalidate(dentry, nd->flags); > if (likely(status > 0)) > return dentry; > if (unlazy_child(nd, dentry, seq)) > return ERR_PTR(-ECHILD); > if (unlikely(status == -ECHILD)) > /* we'd been told to redo it in non-rcu mode */ > status = d_revalidate(dentry, nd->flags); > > If the status of the d_revalidate() is greater than zero, then the function > finishes. Otherwise, if it is an "unlazy_child" it returns with -ECHILD. > After the above two checks, the status is compared to -ECHILD, as that is > what is returned if the original d_revalidate() needed to be done in a > non-rcu mode. > > Especially this path is called in a condition of: > > if (nd->flags & LOOKUP_RCU) { > > And most of the d_revalidate() functions have: > > if (flags & LOOKUP_RCU) > return -ECHILD; > > It appears that that is the only case that this if statement is triggered > on two of my machines, running in production. > > As it is dependent on what filesystem mix is configured in the running > kernel, simply remove the unlikely() from the if statement. > > Signed-off-by: Steven Rostedt (VMware) > --- > Changes since v1: > > - Remove unlikely() instead of making it a likely() > > diff --git a/fs/namei.c b/fs/namei.c > index d4a6dd772303..c7b7e83853f3 100644 > --- a/fs/namei.c > +++ b/fs/namei.c > @@ -1495,7 +1495,7 @@ static struct dentry *lookup_fast(struct nameidata *nd, > return dentry; > if (unlazy_child(nd, dentry, seq)) > return ERR_PTR(-ECHILD); > - if (unlikely(status == -ECHILD)) > + if (status == -ECHILD) > /* we'd been told to redo it in non-rcu mode */ > status = d_revalidate(dentry, nd->flags); > } else {