netdev
[Top] [All Lists]

Re: [PATCH 1/4] Net device error logging, revised

To: Jim Keniston <jkenisto@xxxxxxxxxx>
Subject: Re: [PATCH 1/4] Net device error logging, revised
From: Stephen Hemminger <shemminger@xxxxxxxx>
Date: Tue, 26 Aug 2003 18:06:26 -0700
Cc: Greg KH <greg@xxxxxxxxx>, LKML <linux-kernel@xxxxxxxxxxxxxxx>, netdev <netdev@xxxxxxxxxxx>, Jeff Garzik <jgarzik@xxxxxxxxx>, "Feldman, Scott" <scott.feldman@xxxxxxxxx>, Larry Kessler <kessler@xxxxxxxxxx>, Randy Dunlap <rddunlap@xxxxxxxx>, Alan Cox <alan@xxxxxxxxxxxxxxxxxxx>, Andrew Morton <akpm@xxxxxxxx>
In-reply-to: <3F4BEE68.A6C862C2@xxxxxxxxxx>
Organization: Open Source Development Lab
References: <3F4A8027.6FE3F594@xxxxxxxxxx> <20030826183221.GB3167@xxxxxxxxx> <3F4BEE68.A6C862C2@xxxxxxxxxx>
Sender: netdev-bounce@xxxxxxxxxxx
 
> The following options come to mind:
> 1. Keep the msg buffer, but make it smaller.  Around 120 bytes would probably 
> be
> big enough for the vast majority of messages.  (printk() uses a 1024-byte 
> buffer,
> but it's static -- see #2.)
> 
> 2. Use a big, static buffer, protected by a spinlock.  printk() does this.
> 
> 3. Do the whole thing in a macro, as in previous proposals.  The size of the 
> macro
> expansion could be reduced somewhat by doing the encode-prefix step in a 
> function --
> something like:
> 
> #define netdev_printk(sevlevel, netdev, msglevel, format, arg...)     \
> do {                                                                  \
> if (NETIF_MSG_##msglevel == NETIF_MSG_ALL || ((netdev)->msg_enable & 
> NETIF_MSG_##msglevel)) { \
>       char pfx[40];                                                   \
>       printk(sevlevel "%s: " format , make_netdev_msg_prefix(pfx, netdev) , 
> ## arg);  \
> }} while (0)
> 
> This would make your code bigger, but not that much bigger for the common 
> case where
> the msglevel is omitted (and the 'if(...)' is optimized out).

Is there some way to tack copy and prepend what you want onto the format
string, and add additional arguments to the call to printk?  That way you
wouldn't need space for the potentially large resulting string, but only
enough room for the expanded format string.

<Prev in Thread] Current Thread [Next in Thread>