Skip to contentSkip to conversation

percpu: remove address_space attribute if !SMP

PATCH In review Namhyung Kim 2 participants 7 messages Aug 6, 2010

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

PATCH 1/1 percpu: remove address_space attribute if !SMP

percpu data has no special meaning in case of !CONFIG_SMP. This removes lots of sparse warnings.

include/linux/compiler.h +5 -1
index a5a472b..8dfd41d 100644
@@ -15,7 +15,11 @@
 # define __acquire(x)	__context__(x,1)
 # define __release(x)	__context__(x,-1)
 # define __cond_lock(x,c)	((c) ? ({ __acquire(x); 1; }) : 0)
-# define __percpu	__attribute__((noderef, address_space(3)))
+# ifdef CONFIG_SMP
+#  define __percpu	__attribute__((noderef, address_space(3)))
+# else
+#  define __percpu
+# endif
 extern void __chk_user_ptr(const volatile void __user *);
 extern void __chk_io_ptr(const volatile void __iomem *);
 #else
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 4 lines · Namhyung Kim

percpu data has no special meaning in case of !CONFIG_SMP. This removes lots of sparse warnings.

But they should still be accessed through the accessors and if they are accessed through accessors, there shouldn't be sparse warnings regarding them. Maybe UP accessors are missing proper markups? Do those warnings only happen on UP config?

Signature · 1 line
tejun
#2 lore raw

2010-08-06 (금), 14:49 +0200, Tejun Heo:

Quoted 11 lines · Namhyung Kim
Quoted 4 lines

percpu data has no special meaning in case of !CONFIG_SMP. This removes lots of sparse warnings.

But they should still be accessed through the accessors and if they are accessed through accessors, there shouldn't be sparse warnings regarding them. Maybe UP accessors are missing proper markups? Do those warnings only happen on UP config?

They do nothing on UP.
quoting from include/asm-generic.h:

#else /* ! SMP */

#define per_cpu(var, cpu) (*((void)(cpu), &(var)))
#define __get_cpu_var(var) (var)
#define __raw_get_cpu_var(var) (var)
#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr)

#endif /* SMP */

Signature · 8 lines
Regards,
Namhyung Kim


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw

Hello,

Quoted 11 lines · Namhyung Kim
Quoted 5 lines

But they should still be accessed through the accessors and if they are accessed through accessors, there shouldn't be sparse warnings regarding them. Maybe UP accessors are missing proper markups? Do those warnings only happen on UP config?

They do nothing on UP.
quoting from include/asm-generic.h:

#else /* ! SMP */

Quoted 7 lines

#define per_cpu(var, cpu) (*((void)(cpu), &(var)))
#define __get_cpu_var(var) (var)
#define __raw_get_cpu_var(var) (var)
#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, 0)
#define __this_cpu_ptr(ptr) this_cpu_ptr(ptr)

#endif /* SMP */

Ah, I see. Then, the right thing to do is to add proper checking and markups to UP accessors matching the SMP ones.
ie. __verify_pcpu_ptr() verification followed by __kernel __force casting. Are you interested in doing it?

Thanks.

Signature · 1 line
tejun
#4 lore raw

2010-08-06 (금), 14:57 +0200, Tejun Heo:

Quoted 7 lines

Ah, I see. Then, the right thing to do is to add proper checking and markups to UP accessors matching the SMP ones.
ie. __verify_pcpu_ptr() verification followed by __kernel __force casting. Are you interested in doing it?

Thanks.

Sure. :-)
Although I'm not sure that it is really needed, if so I'll do that.

Signature · 8 lines
Regards,
Namhyung Kim


--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw

Hello,

Quoted 2 lines · Namhyung Kim

Sure. :-)
Although I'm not sure that it is really needed, if so I'll do that.

Well, the whole __percpu markup thing is to detect misuse of percpu pointers. I think it would definitely be better to have the sanity check for UP code too. It's not like it's gonna cost any runtime overhead and all the needed pieces are already there.

Thanks.

Signature · 1 line
tejun
#6 lore raw

2010-08-06 (금), 15:37 +0200, Tejun Heo:

Quoted 2 lines

Hello,

Hi,

Quoted 11 lines · Namhyung Kim
Quoted 2 lines

Sure. :-)
Although I'm not sure that it is really needed, if so I'll do that.

Well, the whole __percpu markup thing is to detect misuse of percpu pointers. I think it would definitely be better to have the sanity check for UP code too. It's not like it's gonna cost any runtime overhead and all the needed pieces are already there.

Thanks.

I see. Thanks for the comments.

Signature · 8 lines
Regards,
Namhyung Kim


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