My understanding is that prior to linux kernel commit
dd17c8f72993 ("percpu: remove per_cpu__ prefix.") per_cpu_var(),
which was included in v2.6.34, was used to wrap per cpu variables

In order to allow Open vSwitch to compile against  v2.6.33
and earlier use per_cpu_var() and in order to allow compilation
with latter kernels provide a per_cpu_var() which performs
an identity map.

In the case of v2.6.32 the kernel does not supply this_cpu_{read,inc,dec}
and the compat code for RHEL6 in datapath/linux/compat/include/linux/percpu.h
is used.

Fixes: 60759b2b9d0c ("datapath: Remove recirc stack depth limit check")
Signed-off-by: Simon Horman <simon.hor...@netronome.com>

---
* Also applicable to branch-2.4, please consider backporting to that branch.

v2
* Add kernel version to test to .travis.yml
---
 .travis.yml        |  1 +
 datapath/actions.c | 16 +++++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index ea1d7e7ebea4..141359b76c1e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,6 +32,7 @@ env:
   - KERNEL=3.10.92
   - KERNEL=3.4.110
   - KERNEL=3.2.72
+  - KERNEL=2.6.33.20
   - KERNEL=2.6.32.68
 
 script: ./.travis/build.sh $OPTS
diff --git a/datapath/actions.c b/datapath/actions.c
index c529bbb9b6ee..e8ca114beec2 100644
--- a/datapath/actions.c
+++ b/datapath/actions.c
@@ -982,12 +982,22 @@ static void process_deferred_actions(struct datapath *dp)
        action_fifo_init(fifo);
 }
 
+#if LINUX_VERSION_CODE == KERNEL_VERSION(2,6,33)
+#define ovs_this_cpu_read(ptr) this_cpu_read(per_cpu_var(ptr))
+#define ovs_this_cpu_inc(ptr) this_cpu_inc(per_cpu_var(ptr))
+#define ovs_this_cpu_dec(ptr) this_cpu_dec(per_cpu_var(ptr))
+#else
+#define ovs_this_cpu_read(ptr) this_cpu_read(ptr)
+#define ovs_this_cpu_inc(ptr) this_cpu_inc(ptr)
+#define ovs_this_cpu_dec(ptr) this_cpu_dec(ptr)
+#endif
+
 /* Execute a list of actions against 'skb'. */
 int ovs_execute_actions(struct datapath *dp, struct sk_buff *skb,
                        const struct sw_flow_actions *acts,
                        struct sw_flow_key *key)
 {
-       int level = this_cpu_read(exec_actions_level);
+       int level = ovs_this_cpu_read(exec_actions_level);
        int err;
 
        if (unlikely(level >= EXEC_ACTIONS_LEVEL_LIMIT)) {
@@ -999,14 +1009,14 @@ int ovs_execute_actions(struct datapath *dp, struct 
sk_buff *skb,
                return -ELOOP;
        }
 
-       this_cpu_inc(exec_actions_level);
+       ovs_this_cpu_inc(exec_actions_level);
        err = do_execute_actions(dp, skb, key,
                                 acts->actions, acts->actions_len);
 
        if (!level)
                process_deferred_actions(dp);
 
-       this_cpu_dec(exec_actions_level);
+       ovs_this_cpu_dec(exec_actions_level);
 
        /* This return status currently does not reflect the errors
         * encounted during deferred actions execution. Probably needs to
-- 
2.1.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to