Skip to contentSkip to conversation

percpu: fix generic definition of __this_cpu_add_and_return()

PATCH Applied Konstantin Khlebnikov 4 participants 6 messages Feb 19, 2012 – Feb 28, 2012 Per-CPU memory allocator

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 percpu: fix generic definition of __this_cpu_add_and_return()

This patch adds missed "__" into function prefix.
Otherwise on all archectures (except x86) it expands to irq/preemtion-safe
variant: _this_cpu_generic_add_return(), which do extra irq-save/irq-restore. Optimal generic implementation is __this_cpu_generic_add_return().

---
 include/linux/percpu.h |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/percpu.h +2 -1
index 32cd1f6..3b609eb 100644
@@ -718,7 +718,8 @@ do {									\
 # ifndef __this_cpu_add_return_8
 #  define __this_cpu_add_return_8(pcp, val)	__this_cpu_generic_add_return(pcp, val)
 # endif
-# define __this_cpu_add_return(pcp, val)	__pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
+# define __this_cpu_add_return(pcp, val)	\
+	__pcpu_size_call_return2(__this_cpu_add_return_, pcp, val)
 #endif
 
 #define __this_cpu_sub_return(pcp, val)	this_cpu_add_return(pcp, -(val))
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Konstantin Khlebnikov

This patch adds missed "__" into function prefix.
Otherwise on all archectures (except x86) it expands to irq/preemtion-safe
variant: _this_cpu_generic_add_return(), which do extra irq-save/irq-restore. Optimal generic implementation is __this_cpu_generic_add_return().

maintainer Applied
#2 lore raw
Quoted 8 lines · Christoph Lameter
Quoted 4 lines · Konstantin Khlebnikov

This patch adds missed "__" into function prefix.
Otherwise on all archectures (except x86) it expands to irq/preemtion-safe
variant: _this_cpu_generic_add_return(), which do extra irq-save/irq-restore. Optimal generic implementation is __this_cpu_generic_add_return().

Applied to 3.3-fixes. Thanks.

Signature · 1 line
tejun
#3 lore raw
In reply to Konstantin Khlebnikov
Quoted 15 lines · Konstantin Khlebnikov

This patch adds missed "__" into function prefix.
Otherwise on all archectures (except x86) it expands to irq/preemtion-safe
variant: _this_cpu_generic_add_return(), which do extra irq-save/irq-restore. Optimal generic implementation is __this_cpu_generic_add_return().

---
 include/linux/percpu.h |    3 ++-

 1 files changed, 2 insertions(+), 1 deletions(-)
include/linux/percpu.h +0 -0
index 32cd1f6..3b609eb 100644

include/linux/percpu.h do {                                                                        \ · line 725

Quoted 9 lines
include/linux/percpu.h +2 -1
@@ -718,7 +718,8 @@ do {                                                                        \
  # ifndef __this_cpu_add_return_8
  #  define __this_cpu_add_return_8(pcp, val)    __this_cpu_generic_add_return(pcp, val)
  # endif
-# define __this_cpu_add_return(pcp, val)       __pcpu_size_call_return2(this_cpu_add_return_, pcp, val)
+# define __this_cpu_add_return(pcp, val)       \
+       __pcpu_size_call_return2(__this_cpu_add_return_, pcp, val)
  #endif
 
  #define __this_cpu_sub_return(pcp, val)        this_cpu_add_return(pcp, -(val))

I think, the same fix should be applied to the lines following this patch:
#define __this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
#define __this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
#define __this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)

Shouldn't these other operations also only give the __ relaxed guarantees?

HTH

Torsten

#4 lore raw
Quoted 8 lines · Torsten Kaiser
Quoted 1 line

 #define __this_cpu_sub_return(pcp, val)        this_cpu_add_return(pcp, -(val))

I think, the same fix should be applied to the lines following this patch:
#define __this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
#define __this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
#define __this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)

Shouldn't these other operations also only give the __ relaxed guarantees?

Yes indeed that should also be fixed.

maintainer
#5 lore raw
Quoted 11 lines · Christoph Lameter
Quoted 8 lines · Torsten Kaiser
Quoted 1 line

 #define __this_cpu_sub_return(pcp, val)        this_cpu_add_return(pcp, -(val))

I think, the same fix should be applied to the lines following this patch:
#define __this_cpu_sub_return(pcp, val) this_cpu_add_return(pcp, -(val))
#define __this_cpu_inc_return(pcp) this_cpu_add_return(pcp, 1)
#define __this_cpu_dec_return(pcp) this_cpu_add_return(pcp, -1)

Shouldn't these other operations also only give the __ relaxed guarantees?

Yes indeed that should also be fixed.

Can someone please send a patch for this? :)

Thanks.

Signature · 1 line
tejun