Skip to contentSkip to conversation

kernel/time/tick-sched.c: fix warning of printk's argument format

PATCH In review Wu Zhangjin 5 participants 7 messages Oct 8, 2009 – Oct 9, 2009 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernel/time/tick-sched.c: fix warning of printk's argument format

This patch will fix the following warning:

kernel/time/tick-sched.c: In function 'tick_nohz_stop_sched_tick':
kernel/time/tick-sched.c:261: warning: format '%02x' expects type 'unsigned int', but argument 2 has type 'long unsigned int'

---
 kernel/time/tick-sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/tick-sched.c +1 -1
index e0f59a2..26370b0 100644
@@ -257,7 +257,7 @@ void tick_nohz_stop_sched_tick(int inidle)
 		static int ratelimit;
 
 		if (ratelimit < 10) {
-			printk(KERN_ERR "NOHZ: local_softirq_pending %02x\n",
+			printk(KERN_ERR "NOHZ: local_softirq_pending %02lx\n",
 			       local_softirq_pending());
 			ratelimit++;
 		}
Signature · 1 line
1.6.2.1
#1 lore raw
Quoted 2 lines · Wu Zhangjin

This patch will fix the following warning:

No it won't. It will add a lot of new warnings.

The thing is, almost all architectures (including x86) have

	unsigned int __softirq_pending;

but then in <asm-generic/hardirq.h> we have

	unsigned long __softirq_pending;

for some unfathomable reason. Quite frankly, I think Arnd just screwed up the "generic" version, and the fix is almost certainly to just make the generic version match all the main architectures.

I don't have any architectures using the generic header file, though, so I'm not going to do that change blindly. People who do should look at it (alpha, powerpc and mips look like the only ones that might be 64-bit, but I didn't check very carefully - just grepped for it)

Added Cc's for some people that have worked on, or used, that generic header file. Is there any possible reason why it is "unsigned long" in that one?

Linus

---

Quoted 24 lines

kernel/time/tick-sched.c: In function 'tick_nohz_stop_sched_tick':
kernel/time/tick-sched.c:261: warning: format '%02x' expects type 'unsigned int', but argument 2 has type 'long unsigned int'

---
 kernel/time/tick-sched.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/time/tick-sched.c +1 -1
index e0f59a2..26370b0 100644
@@ -257,7 +257,7 @@ void tick_nohz_stop_sched_tick(int inidle)
 		static int ratelimit;
 
 		if (ratelimit < 10) {
-			printk(KERN_ERR "NOHZ: local_softirq_pending %02x\n",
+			printk(KERN_ERR "NOHZ: local_softirq_pending %02lx\n",
 			       local_softirq_pending());
 			ratelimit++;
 		}
Signature · 1 line
1.6.2.1
#2 lore raw
Quoted 19 lines · Linus Torvalds
Quoted 2 lines · Wu Zhangjin

This patch will fix the following warning:

No it won't. It will add a lot of new warnings.

The thing is, almost all architectures (including x86) have

	unsigned int __softirq_pending;

but then in <asm-generic/hardirq.h> we have

	unsigned long __softirq_pending;

for some unfathomable reason. Quite frankly, I think Arnd just screwed up the "generic" version, and the fix is almost certainly to just make the generic version match all the main architectures.

Quoted 9 lines

I don't have any architectures using the generic header file, though, so I'm not going to do that change blindly. People who do should look at it (alpha, powerpc and mips look like the only ones that might be 64-bit, but I didn't check very carefully - just grepped for it)

Added Cc's for some people that have worked on, or used, that generic header file. Is there any possible reason why it is "unsigned long" in that one?

I'm really using a MIPS machine! there is only a "unsigned long" definition in include/asm-generic/hardirq.h.

Regards,
Wu Zhangjin

#3 lore raw
Quoted 25 lines · Wu Zhangjin
Quoted 24 lines · Linus Torvalds
Quoted 2 lines · Wu Zhangjin

This patch will fix the following warning:

No it won't. It will add a lot of new warnings.

The thing is, almost all architectures (including x86) have

      unsigned int __softirq_pending;

but then in <asm-generic/hardirq.h> we have

      unsigned long __softirq_pending;

for some unfathomable reason. Quite frankly, I think Arnd just screwed up the "generic" version, and the fix is almost certainly to just make the generic version match all the main architectures.

I don't have any architectures using the generic header file, though, so I'm not going to do that change blindly. People who do should look at it (alpha, powerpc and mips look like the only ones that might be 64-bit, but I didn't check very carefully - just grepped for it)

Quoted 8 lines
Quoted 4 lines

Added Cc's for some people that have worked on, or used, that generic header file. Is there any possible reason why it is "unsigned long" in that one?

I'm really using a MIPS machine! there is only a "unsigned long" definition in include/asm-generic/hardirq.h.

So this is introduced by 24ffce18a4b6b5e9769200582c09df7ff044259f.
MIPS: Convert to asm-generic/hardirq.h

Cced Ralf.

Thanks,
Yong

Quoted 9 lines

Regards,
       Wu Zhangjin

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

#4 lore raw
In reply to Linus Torvalds
Quoted 16 lines · Linus Torvalds
Quoted 1 line

This patch will fix the following warning:

No it won't. It will add a lot of new warnings.

The thing is, almost all architectures (including x86) have

	unsigned int __softirq_pending;

but then in <asm-generic/hardirq.h> we have

	unsigned long __softirq_pending;

for some unfathomable reason. Quite frankly, I think Arnd just screwed up the "generic" version, and the fix is almost certainly to just make the generic version match all the main architectures.

Quoted 8 lines

I don't have any architectures using the generic header file, though, so I'm not going to do that change blindly. People who do should look at it (alpha, powerpc and mips look like the only ones that might be 64-bit, but I didn't check very carefully - just grepped for it)

Added Cc's for some people that have worked on, or used, that generic header file. Is there any possible reason why it is "unsigned long" in that one?

I think for no other reason than many other bitfields in kernel being unsigned long or arrays of unsigned long. Except of course that __softirq_pending is never being used with the <asm/bitops.h> operations that operate on unsigned longs.

Patch in followup email.

Ralf

#5 lore raw

PATCH 1/1 IRQ: Change __softirq_pending to unsigned int in asm-generic/hardirq.h.

Since the beginnings in aafe4dbed0bf6cbdb2e9f03e1d42f8a540d8541d include/asm-generic/hardirq.h defined __softirq_pending as unsigned long which is different from other architectures for no apparent good reason and was causing the following warning:

kernel/time/tick-sched.c: In function 'tick_nohz_stop_sched_tick':
kernel/time/tick-sched.c:261: warning: format '%02x' expects type 'unsigned int', but argument 2 has type 'long unsigned int'

Reported and initial patch by Wu Zhangjin <[email protected]>.

---
Tested on a big endian 64-bit MIPS SMP system.

 include/asm-generic/hardirq.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-generic/hardirq.h +1 -1
index 23bb4da..62f5908 100644
@@ -6,7 +6,7 @@
 #include <linux/irq.h>
 
 typedef struct {
-	unsigned long __softirq_pending;
+	unsigned int __softirq_pending;
 } ____cacheline_aligned irq_cpustat_t;
 
 #include <linux/irq_cpustat.h>	/* Standard mappings for irq_cpustat_t above */

A message that is not in the archive (sent off-list or not yet received): [email protected]

Acked-by
#7 lore raw
Quoted 19 lines · Arnd Bergmann
Quoted 4 lines · Linus Torvalds

for some unfathomable reason. Quite frankly, I think Arnd just screwed up the "generic" version, and the fix is almost certainly to just make the generic version match all the main architectures.

Quoted 8 lines

I don't have any architectures using the generic header file, though, so I'm not going to do that change blindly. People who do should look at it (alpha, powerpc and mips look like the only ones that might be 64-bit, but I didn't check very carefully - just grepped for it)

Added Cc's for some people that have worked on, or used, that generic header file. Is there any possible reason why it is "unsigned long" in that one?

It was intentional to make it unsigned long in the asm-generic version, based on the observation that some of the 64-bit architectures (alpha and parisc) were using unsigned long in their arch specific files. The original parisc file contained

Quoted 8 lines

typedef struct {
unsigned long __softirq_pending; /* set_bit is used on this */
} ____cacheline_aligned irq_cpustat_t;

which would imply that unsigned int wouldn't work for it, and looked like a good idea. It turns out that the comment is outdated, set_bit hasn't been used on __softirq_pending on any architecture for a long time as far as I can tell, and 32 bits is obviously enough for it.

Yes, I just tested it on the parisc architecture. It seems we don't even touch this variable in our code.

Quoted 4 lines

The patch that Ralf just sent looks good therefore, but I'd suggest either reverting two of Christophs patches that changed parisc and alpha just to be on the safe side, or getting explicit Acks for Ralfs patch from the maintainers of those two architectures.

Don't revert for parisc, as either "unsigned long" or "unsigned int" is OK. So, Ralf's patch (switching __softirq_pending back to "unsigned int") get's my Ack:

Helge