From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933580Ab2C2RSS (ORCPT ); Thu, 29 Mar 2012 13:18:18 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:49074 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759642Ab2C2RSJ (ORCPT ); Thu, 29 Mar 2012 13:18:09 -0400 Date: Thu, 29 Mar 2012 19:17:19 +0200 (CEST) From: John Kacur To: Borislav Petkov cc: John Kacur , Steven Rostedt , LKML Subject: Re: [PATCH] ftrace: Remove a superfluous check In-Reply-To: <20120329171140.GE6409@aftab> Message-ID: References: <1333039463-24268-1-git-send-email-bp@amd64.org> <20120329171140.GE6409@aftab> User-Agent: Alpine 2.02 (LFD 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 29 Mar 2012, Borislav Petkov wrote: > On Thu, Mar 29, 2012 at 07:03:23PM +0200, John Kacur wrote: > > If you're going to do this, then you can drop the label too. > > Jahaa... thanks. > > Here's an updated patch: > > -- > From 135c25a609739bbdf1c33e62119517b47f0e1d07 Mon Sep 17 00:00:00 2001 > From: Borislav Petkov > Date: Thu, 29 Mar 2012 18:41:15 +0200 > Subject: [PATCH] ftrace: Remove a superfluous check > > register_ftrace_function() checks ftrace_disabled and calls > __register_ftrace_function which does it again. > > Drop the first check and add the unlikely hint to the second one. Also, > drop the label as John correctly notices. > > No functional change. > > Cc: John Kacur > Signed-off-by: Borislav Petkov > --- > kernel/trace/ftrace.c | 8 ++------ > 1 file changed, 2 insertions(+), 6 deletions(-) > > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c > index 867bd1dd2dd0..0df8f8088ffe 100644 > --- a/kernel/trace/ftrace.c > +++ b/kernel/trace/ftrace.c > @@ -311,7 +311,7 @@ static int remove_ftrace_list_ops(struct ftrace_ops **list, > > static int __register_ftrace_function(struct ftrace_ops *ops) > { > - if (ftrace_disabled) > + if (unlikely(ftrace_disabled)) > return -ENODEV; > > if (FTRACE_WARN_ON(ops == &global_ops)) > @@ -4304,16 +4304,12 @@ int register_ftrace_function(struct ftrace_ops *ops) > > mutex_lock(&ftrace_lock); > > - if (unlikely(ftrace_disabled)) > - goto out_unlock; > - > ret = __register_ftrace_function(ops); > if (!ret) > ret = ftrace_startup(ops, 0); > > - > - out_unlock: > mutex_unlock(&ftrace_lock); > + > return ret; > } > EXPORT_SYMBOL_GPL(register_ftrace_function); > -- > 1.7.9.3.362.g71319 > It looks okay to me. Technically it's not functionally equivalent though, because now when __register_ftrace_function is called directly, (in other paths), the test has an unlikely there. See what Steven says, otherwise, you can have my reviewed by. Thanks John