Repository : ssh://git@open-mesh.org/batman-adv
On branch : master
commit f8b19e13d8d8b233384d723ee2b2b54d011fb90c Author: Shan Wei davidshan@tencent.com Date: Tue Nov 13 09:53:26 2012 +0800
batman-adv: use per_cpu_add helper
this_cpu_add is an atomic operation. and be more faster than per_cpu_ptr operation.
Signed-off-by: Shan Wei davidshan@tencent.com Reviewed-by: Christoph Lameter cl@linux.com Signed-off-by: Sven Eckelmann sven@narfation.org Signed-off-by: Marek Lindner lindner_marek@yahoo.de
f8b19e13d8d8b233384d723ee2b2b54d011fb90c compat.h | 9 +++++++++ main.h | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/compat.h b/compat.h index be685aa..8780b43 100644 --- a/compat.h +++ b/compat.h @@ -62,6 +62,15 @@
#define skb_iif iif
+#define this_cpu_add(x, c) batadv_this_cpu_add(&(x), c) + +static inline void batadv_this_cpu_add(uint64_t *count_ptr, size_t count) +{ + int cpu = get_cpu(); + *per_cpu_ptr(count_ptr, cpu) += count; + put_cpu(); +} + #endif /* < KERNEL_VERSION(2, 6, 33) */
diff --git a/main.h b/main.h index ec9c5ad..7b5fc99 100644 --- a/main.h +++ b/main.h @@ -279,9 +279,7 @@ static inline bool batadv_has_timed_out(unsigned long timestamp, static inline void batadv_add_counter(struct batadv_priv *bat_priv, size_t idx, size_t count) { - int cpu = get_cpu(); - per_cpu_ptr(bat_priv->bat_counters, cpu)[idx] += count; - put_cpu(); + this_cpu_add(bat_priv->bat_counters[idx], count); }
#define batadv_inc_counter(b, i) batadv_add_counter(b, i, 1)