diff mbox

[ovs-dev,1/2] datapath: Provide this_cpu_{read, inc, dec} wrappers for v2.6.33

Message ID 1448604443-12224-2-git-send-email-simon.horman@netronome.com
State Changes Requested
Headers show

Commit Message

Simon Horman Nov. 27, 2015, 6:07 a.m. UTC
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.horman@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(-)

Comments

Pravin Shelar Jan. 28, 2016, 12:54 a.m. UTC | #1
On Thu, Nov 26, 2015 at 10:07 PM, Simon Horman
<simon.horman@netronome.com> wrote:
> 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.horman@netronome.com>
>
Sorry for late reply.

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

Since master is going to drop support for kernel older than 3.10. I
would apply such patches to branch 2.5 and older.

>
> 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
>
As mentioned in other review of compatibility patch, I think we should
not add every kernel that OVS support.

>  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
> +
We could redefine this_cpu_dec for OVS in combat header files.
diff mbox

Patch

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