From: "Vegard Nossum" <vegard.nossum@gmail.com>
To: "Geert Uytterhoeven" <geert@linux-m68k.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Kyle Moffett" <mrmacman_g4@mac.com>,
"Michael Holzheu" <holzheu@linux.vnet.ibm.com>,
"Joe Perches" <joe@perches.com>, "Rob Landley" <rob@landley.net>,
"Dick Streefland" <dick.streefland@altium.nl>,
"Jesse Barnes" <jesse.barnes@intel.com>,
"Arnd Bergmann" <arnd@arndb.de>,
"Jan Engelhardt" <jengelh@computergmbh.de>,
"Emil Medve" <Emilian.Medve@freescale.com>,
"Stephen Hemminger" <shemminger@linux-foundation.org>,
"linux@horizon.com" <linux@horizon.com>
Subject: Re: [RFC] New kernel-message logging API (take 2)
Date: Fri, 28 Sep 2007 13:46:00 +0200 [thread overview]
Message-ID: <19f34abd0709280446l47584141m4f89fe4d2eb6926d@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.64.0709280922230.32185@anakin>
> If-blocks spanning macros are really dangerous!
>
> E.g. an Ethernet driver may want to do:
>
> kprint_block(&block, "MAC ");
> for (i = 0; i < 6; i++) {
> card->mac[i] = obtain_mac_byte_from_hw(i);
> kprint_block(&block, "%02x", card->mac[i]);
> }
>
> This looks (and should be) innocent, but the actual MAC addres retrieval
> would never be executed if loglevel <= CONFIG_KPRINT_LOGLEVEL_MAX.
Yup. Okay, so it's definitely NOT an option.
> Can't you store the loglevel in the kprint_block and check it in all
> successive kprint_*() macros? If gcc knows it's constant, it can optimize
> the non-wanted code away. As other fields in struct kprint_block cannot be
> constant (they store internal state), you have to split it like:
>
> struct kprint_block {
> int loglevel;
> struct real_kprint_block real; /* internal state */
> }
>
> and pass &block.real() instead of &block to all successive internal functions.
> I haven't tried this, so let's hope gcc is actually smart enough...
It isn't, apparently. Or not with my test, anyway. Either way, it's
probably better not to make those assumptions about or rely too much
on the smartness of the compiler (we don't have *any* guarantees).
The best solution for now is probably to pass the log-level into each
line, as Dick Streefland suggested, though it would lead to a hairier
syntax, or just skip the whole interface for now, as Jan Engelhardt
suggested. Thanks.
Vegard
next prev parent reply other threads:[~2007-09-28 11:46 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-27 21:18 Vegard Nossum
2007-09-28 1:38 ` linux
2007-09-28 7:31 ` Geert Uytterhoeven
2007-09-28 7:44 ` Kyle Moffett
2007-09-28 11:49 ` Vegard Nossum
2007-09-28 11:46 ` Vegard Nossum [this message]
2007-09-28 8:22 ` Dick Streefland
2007-09-28 9:45 ` Jan Engelhardt
2007-09-28 11:59 ` Vegard Nossum
2007-09-28 12:11 ` Vegard Nossum
2007-09-28 13:30 ` Miguel Ojeda
2007-09-28 13:55 ` Vegard Nossum
2007-09-28 14:00 ` Miguel Ojeda
2007-09-28 16:30 ` Rob Landley
2007-09-28 16:41 ` 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=19f34abd0709280446l47584141m4f89fe4d2eb6926d@mail.gmail.com \
--to=vegard.nossum@gmail.com \
--cc=Emilian.Medve@freescale.com \
--cc=arnd@arndb.de \
--cc=dick.streefland@altium.nl \
--cc=geert@linux-m68k.org \
--cc=holzheu@linux.vnet.ibm.com \
--cc=jengelh@computergmbh.de \
--cc=jesse.barnes@intel.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@horizon.com \
--cc=mrmacman_g4@mac.com \
--cc=rob@landley.net \
--cc=shemminger@linux-foundation.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
all inboxes | Powered by JetHome®