logo       

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

Subject: Re: [PATCH 1/4] Net device error logging, revised
Stephen Hemminger wrote:
> 
> > 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:
[more on #3 snipped]
> 
> 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.

Interesting idea.  I pondered this for a while.  But even if you postulate 
a varargs version of printk (which doesn't exist), it's not really
feasible to do this in a function.  There's no way for a function to
prepend args to a va_list.  That means you'd have to encode the text of
the prefix as part of the format string, and that would require you to
allocate room for prefix+format, which is still a lot of stack.  Also,
the fact that the interface name itself may contain "%d" or some such
makes it even messier.

Greg K-H thinks #2 is a reasonable solution (you're about to serialize on 
printk's
lock anyway), so I'll go with that.

Thanks.
Jim




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