2005-10-26 04:28:29

by Jeff Garzik

[permalink] [raw]
Subject: [PATCH] kill massive wireless-related log spam


Please apply to 2.6.14-rc.

Although this message is having the intended effect of causing wireless
driver maintainers to upgrade their code, I never should have merged
this patch in its present form. Leading to tons of bug reports and
unhappy users.

Some wireless apps poll for statistics regularly, which leads to a
printk() every single time they ask for stats. That's a little bit
_too_ much of a reminder that the driver is using an old API.

Change this to printing out the message once, per kernel boot.

diff --git a/net/core/wireless.c b/net/core/wireless.c
index d17f158..271ddb3 100644
--- a/net/core/wireless.c
+++ b/net/core/wireless.c
@@ -455,10 +455,15 @@ static inline struct iw_statistics *get_

/* Old location, field to be removed in next WE */
if(dev->get_wireless_stats) {
- printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
- dev->name);
+ static int printed_message;
+
+ if (!printed_message++)
+ printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
+ dev->name);
+
return dev->get_wireless_stats(dev);
}
+
/* Not found */
return (struct iw_statistics *) NULL;
}


2005-10-26 15:03:27

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam

On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:

> Change this to printing out the message once, per kernel boot.

It doesn't do that. It prints it once every 2^32 calls. Also
the ++ causes unnecessary dirty cache lines in normal operation.

-Andi
>
> diff --git a/net/core/wireless.c b/net/core/wireless.c
> index d17f158..271ddb3 100644
> --- a/net/core/wireless.c
> +++ b/net/core/wireless.c
> @@ -455,10 +455,15 @@ static inline struct iw_statistics *get_
>
> /* Old location, field to be removed in next WE */
> if(dev->get_wireless_stats) {
> - printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
> - dev->name);
> + static int printed_message;
> +
> + if (!printed_message++)
> + printk(KERN_DEBUG "%s (WE) : Driver using old /proc/net/wireless support, please fix driver !\n",
> + dev->name);
> +
> return dev->get_wireless_stats(dev);
> }
> +

2005-10-26 15:23:16

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam

On 10/26/05, Andi Kleen <[email protected]> wrote:
> On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
>
> > Change this to printing out the message once, per kernel boot.
>
> It doesn't do that. It prints it once every 2^32 calls. Also

I noted that as well. How about just using something along the lines of

static unsigned char printed_message = 0;
if (!printed_message) {
printk(...);
printed_message++;
}


--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2005-10-26 15:43:05

by Jeff Garzik

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam

Andi Kleen wrote:
> On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
>
>
>>Change this to printing out the message once, per kernel boot.
>
>
> It doesn't do that. It prints it once every 2^32 calls. Also

...which is effectively one per kernel boot


> the ++ causes unnecessary dirty cache lines in normal operation.

Not a hot path operation by any stretch of the imagination, so that's fine.

Jeff


2005-10-26 21:24:05

by J.A. Magallon

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam


On 2005.10.26, at 17:23, Jesper Juhl wrote:

> On 10/26/05, Andi Kleen <[email protected]> wrote:
>
>> On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
>>
>>
>>> Change this to printing out the message once, per kernel boot.
>>>
>>
>> It doesn't do that. It prints it once every 2^32 calls. Also
>>
>
> I noted that as well. How about just using something along the
> lines of
>
> static unsigned char printed_message = 0;
> if (!printed_message) {
> printk(...);
> printed_message++;
> }

Sorry, but why not the old good

printed_message = 1

??
What kind of microoptimization is that ?

--
J.A. Magallon <jamagallon()able!es> \ Software is like sex:
wolverine \ It's better when it's free
MacOS X 10.4.2, Darwin Kernel Version 8.2.0


2005-10-26 21:44:04

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam

On 10/26/05, J.A. Magallon <[email protected]> wrote:
>
> On 2005.10.26, at 17:23, Jesper Juhl wrote:
>
> > On 10/26/05, Andi Kleen <[email protected]> wrote:
> >
> >> On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
> >>
> >>
> >>> Change this to printing out the message once, per kernel boot.
> >>>
> >>
> >> It doesn't do that. It prints it once every 2^32 calls. Also
> >>
> >
> > I noted that as well. How about just using something along the
> > lines of
> >
> > static unsigned char printed_message = 0;
> > if (!printed_message) {
> > printk(...);
> > printed_message++;
> > }
>
> Sorry, but why not the old good
>
> printed_message = 1
>
> ??
> What kind of microoptimization is that ?
>
Does it really matter? I needed to pick one of
printed_message=1; or printed_message++;
the end result is the same, so I just picked one at random.
But now that you mention it, I guess ++ would turn into "inc" which
should be faster than an assignment... but it *doesn't matter*... I
was not trying to optimize anything, just make the code work properly
- as in, only ever print the message once...


--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2005-10-27 17:39:21

by Horst H. von Brand

[permalink] [raw]
Subject: Re: [PATCH] kill massive wireless-related log spam

Jeff Garzik <[email protected]> wrote:
> Andi Kleen wrote:
> > On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
> >
> >>Change this to printing out the message once, per kernel boot.
> > It doesn't do that. It prints it once every 2^32 calls. Also
>
> ...which is effectively one per kernel boot
>
>
> > the ++ causes unnecessary dirty cache lines in normal operation.

> Not a hot path operation by any stretch of the imagination, so that's
fine.

Right. As the "++" is inside "if(!printed) { ... }" it clearly isn't ;-)
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513