[PATCH] kill massive wireless-related log spam

Subsystems: networking [general], the rest

STALE7600d

6 messages, 4 authors, 2005-10-26 · open the first message on its own page

[PATCH] kill massive wireless-related log spam

From: Jeff Garzik <hidden>
Date: 2005-10-26 04:28:29

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;
 }

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

From: Andi Kleen <hidden>
Date: 2005-10-26 15:03:27

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
quoted hunk
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);
 	}
+

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

From: Jesper Juhl <hidden>
Date: 2005-10-26 15:23:16

On 10/26/05, Andi Kleen [off-list ref] wrote:
On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:
quoted
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 [off-list ref]
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

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

From: Jeff Garzik <hidden>
Date: 2005-10-26 15:43:05

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

quoted
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

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

From: J.A. Magallon <hidden>
Date: 2005-10-26 21:24:05

On 2005.10.26, at 17:23, Jesper Juhl wrote:
On 10/26/05, Andi Kleen [off-list ref] wrote:
quoted
On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:

quoted
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

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

From: Jesper Juhl <hidden>
Date: 2005-10-26 21:44:04

On 10/26/05, J.A. Magallon [off-list ref] wrote:
On 2005.10.26, at 17:23, Jesper Juhl wrote:
quoted
On 10/26/05, Andi Kleen [off-list ref] wrote:
quoted
On Wednesday 26 October 2005 06:28, Jeff Garzik wrote:

quoted
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 [off-list ref]
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help