summaryrefslogtreecommitdiffstats
path: root/include/net/dst_ops.h
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-02 09:58:49 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2010-11-02 09:58:49 -0400
commit9e3be1edbe5ca57df51140b523168237b3a01f4d (patch)
treea72c0ec1ce0fbcdcd12ecb6aad9bedcc94b94f9d /include/net/dst_ops.h
parent473f89fff76568a9f30c53b458e6323d48b0ab95 (diff)
parent29c798fecb9b846b363b0a02fa662ff42fc19426 (diff)
Merge branch 'for-2.6.37' into HEAD
WARN() fix from Joe moved. Conflicts: sound/soc/codecs/wm_hubs.c
Diffstat (limited to 'include/net/dst_ops.h')
-rw-r--r--include/net/dst_ops.h37
1 files changed, 36 insertions, 1 deletions
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h
index d1ff9b7e99b..1fa5306e3e2 100644
--- a/include/net/dst_ops.h
+++ b/include/net/dst_ops.h
@@ -1,6 +1,7 @@
#ifndef _NET_DST_OPS_H
#define _NET_DST_OPS_H
#include <linux/types.h>
+#include <linux/percpu_counter.h>
struct dst_entry;
struct kmem_cachep;
@@ -22,7 +23,41 @@ struct dst_ops {
void (*update_pmtu)(struct dst_entry *dst, u32 mtu);
int (*local_out)(struct sk_buff *skb);
- atomic_t entries;
struct kmem_cache *kmem_cachep;
+
+ struct percpu_counter pcpuc_entries ____cacheline_aligned_in_smp;
};
+
+static inline int dst_entries_get_fast(struct dst_ops *dst)
+{
+ return percpu_counter_read_positive(&dst->pcpuc_entries);
+}
+
+static inline int dst_entries_get_slow(struct dst_ops *dst)
+{
+ int res;
+
+ local_bh_disable();
+ res = percpu_counter_sum_positive(&dst->pcpuc_entries);
+ local_bh_enable();
+ return res;
+}
+
+static inline void dst_entries_add(struct dst_ops *dst, int val)
+{
+ local_bh_disable();
+ percpu_counter_add(&dst->pcpuc_entries, val);
+ local_bh_enable();
+}
+
+static inline int dst_entries_init(struct dst_ops *dst)
+{
+ return percpu_counter_init(&dst->pcpuc_entries, 0);
+}
+
+static inline void dst_entries_destroy(struct dst_ops *dst)
+{
+ percpu_counter_destroy(&dst->pcpuc_entries);
+}
+
#endif