From: Joe Perches <joe@perches.com>
To: Johannes Weiner <hannes@saeurebad.de>
Cc: James Kosin <jkosin@beta.intcomgrp.com>, linux-kernel@vger.kernel.org
Subject: Re: optimizing out inline functions
Date: Wed, 28 May 2008 20:04:22 -0700 [thread overview]
Message-ID: <1212030262.27103.20.camel@localhost> (raw)
In-Reply-To: <87lk1trdr8.fsf@saeurebad.de>
On Thu, 2008-05-29 at 05:27 +0200, Johannes Weiner wrote:
> James Kosin <jkosin@beta.intcomgrp.com> writes:
> >> But we do not have KCONFIG_DEBUG_SOMETHING available
> >> so the second best is to use an empty function
> >> to keep the typechecking in place.
> >> IIRC gcc optimize both away.
> > Another way would be to have:
> > static inline void some_debug_function(var1)
> > {
> > #ifdef KCONFIG_DEBUG_SOMETHING
> > something = var1;
> > printk(some debug text);
> > #endif
> > }
A potential issue is a possible unnecessary call of any
function used as an argument to some_debug_function.
int unnecessary_debug_test(void)
{
int foo;
[]
return foo;
}
static inline void some_debug_function(int bar)
{
}
some_debug_function(unnecessary_debug_test())
unnecessary_debug_test will still get called
Macro wrappers/statement expressions can be used to avoid
the function call. see kernel.h/pr_debug for an example.
#ifdef DEBUG
/* If you are writing a driver, please use dev_dbg instead */
#define pr_debug(fmt, arg...) \
printk(KERN_DEBUG fmt, ##arg)
#else
#define pr_debug(fmt, arg...) \
({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; })
#endif
next prev parent reply other threads:[~2008-05-29 3:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <ayzYV-7mv-5@gated-at.bofh.it>
[not found] ` <ayA8E-89e-29@gated-at.bofh.it>
2008-05-28 20:37 ` optimizing out inline functions James Kosin
2008-05-29 3:27 ` Johannes Weiner
2008-05-29 3:04 ` Joe Perches [this message]
2008-05-29 13:11 ` James Kosin
2008-05-29 13:13 ` James Kosin
2008-05-28 19:51 Steve French
2008-05-28 19:54 ` Pekka Enberg
2008-05-29 8:40 ` Andrew Morton
2008-05-28 20:00 ` Sam Ravnborg
2008-05-29 16:39 ` Steve French
2008-05-29 17:20 ` Sam Ravnborg
2008-06-02 9:38 ` Vegard Nossum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1212030262.27103.20.camel@localhost \
--to=joe@perches.com \
--cc=hannes@saeurebad.de \
--cc=jkosin@beta.intcomgrp.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox