diff mbox series

[ovs-dev] datapath: compat: Fix static key backport

Message ID 1544830135-2727-1-git-send-email-yihung.wei@gmail.com
State Accepted
Headers show
Series [ovs-dev] datapath: compat: Fix static key backport | expand

Commit Message

Yi-Hung Wei Dec. 14, 2018, 11:28 p.m. UTC
The original static key backport is based on the upstream
net-next commit 11276d5306b8
("locking/static_keys: Add a new static_key interface").

However, in Canonical's Trusty kernel, it introduced partial static
support which have different definition of some of the macros that
breaks the compatibility code.

For example, in net-next git tree commit 11276d5306b8
("locking/static_keys: Add a new static_key interface").
+ #define DEFINE_STATIC_KEY_TRUE(name)   \
+       struct static_key_true name = STATIC_KEY_TRUE_INIT

On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
("x86/KVM/VMX: Add module argument for L1TF mitigation")
+ #define DEFINE_STATIC_KEY_TRUE(name)   \
+       struct static_key name = STATIC_KEY_INIT_TRUE

This commit resolves the ovs kernel module compatibility issue on
Trusty kernel.

VMware-BZ: #2251101
Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
---
 acinclude.m4                                     |  4 +++-
 datapath/linux/compat/include/linux/static_key.h | 20 ++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

Comments

Gregory Rose Dec. 18, 2018, 12:22 a.m. UTC | #1
On 12/14/2018 3:28 PM, Yi-Hung Wei wrote:
> The original static key backport is based on the upstream
> net-next commit 11276d5306b8
> ("locking/static_keys: Add a new static_key interface").
>
> However, in Canonical's Trusty kernel, it introduced partial static
> support which have different definition of some of the macros that
> breaks the compatibility code.
>
> For example, in net-next git tree commit 11276d5306b8
> ("locking/static_keys: Add a new static_key interface").
> + #define DEFINE_STATIC_KEY_TRUE(name)   \
> +       struct static_key_true name = STATIC_KEY_TRUE_INIT
>
> On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
> ("x86/KVM/VMX: Add module argument for L1TF mitigation")
> + #define DEFINE_STATIC_KEY_TRUE(name)   \
> +       struct static_key name = STATIC_KEY_INIT_TRUE
>
> This commit resolves the ovs kernel module compatibility issue on
> Trusty kernel.
>
> VMware-BZ: #2251101
> Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>

Looks good to me. Compile tested on a variety of kernels which I imagine 
should be sufficient for this patch.

Passes Travis as well:
https://travis-ci.org/gvrose8192/ovs-experimental/builds/469277320

Tested-by: Greg Rose <gvrose8192@gmail.com>
Reviewed-by: Greg Rose <gvrose8192@gmail.com>

> ---
>   acinclude.m4                                     |  4 +++-
>   datapath/linux/compat/include/linux/static_key.h | 20 ++++++++++++++------
>   2 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/acinclude.m4 b/acinclude.m4
> index ed83df43df54..63da2d38e14e 100644
> --- a/acinclude.m4
> +++ b/acinclude.m4
> @@ -470,8 +470,10 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
>     OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
>     OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [PTR_ERR_OR_ZERO])
>   
> -  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [DEFINE_STATIC_KEY_FALSE],
> +  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [static_branch_unlikely(],
>                     [OVS_DEFINE([HAVE_UPSTREAM_STATIC_KEY])])
> +  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [DEFINE_STATIC_KEY_FALSE],
> +                  [OVS_DEFINE([HAVE_DEFINE_STATIC_KEY])])
>   
>     OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
>     OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
> diff --git a/datapath/linux/compat/include/linux/static_key.h b/datapath/linux/compat/include/linux/static_key.h
> index ea59e3e285a1..01c6a93f07fe 100644
> --- a/datapath/linux/compat/include/linux/static_key.h
> +++ b/datapath/linux/compat/include/linux/static_key.h
> @@ -23,16 +23,16 @@ struct static_key_false {
>   #define rpl_STATIC_KEY_INIT_TRUE	{ .enabled = ATOMIC_INIT(1) }
>   #define rpl_STATIC_KEY_INIT_FALSE	{ .enabled = ATOMIC_INIT(0) }
>   
> -#define STATIC_KEY_TRUE_INIT	\
> +#define rpl_STATIC_KEY_TRUE_INIT	\
>   	(struct static_key_true) { .key = rpl_STATIC_KEY_INIT_TRUE,  }
> -#define STATIC_KEY_FALSE_INIT	\
> +#define rpl_STATIC_KEY_FALSE_INIT	\
>   	(struct static_key_false){ .key = rpl_STATIC_KEY_INIT_FALSE, }
>   
> -#define DEFINE_STATIC_KEY_TRUE(name)	\
> -	struct static_key_true name = STATIC_KEY_TRUE_INIT
> +#define rpl_DEFINE_STATIC_KEY_TRUE(name)	\
> +	struct static_key_true name = rpl_STATIC_KEY_TRUE_INIT
>   
> -#define DEFINE_STATIC_KEY_FALSE(name)	\
> -	struct static_key_false name = STATIC_KEY_FALSE_INIT
> +#define rpl_DEFINE_STATIC_KEY_FALSE(name)	\
> +	struct static_key_false name = rpl_STATIC_KEY_FALSE_INIT
>   
>   static inline int rpl_static_key_count(struct static_key *key)
>   {
> @@ -59,6 +59,14 @@ static inline void rpl_static_key_disable(struct static_key *key)
>   		static_key_slow_dec(key);
>   }
>   
> +#ifdef	HAVE_DEFINE_STATIC_KEY
> +#undef	DEFINE_STATIC_KEY_TRUE
> +#undef	DEFINE_STATIC_KEY_FALSE
> +#endif
> +
> +#define DEFINE_STATIC_KEY_TRUE		rpl_DEFINE_STATIC_KEY_TRUE
> +#define DEFINE_STATIC_KEY_FALSE		rpl_DEFINE_STATIC_KEY_FALSE
> +
>   #define static_branch_likely(x)		likely(static_key_enabled(&(x)->key))
>   #define static_branch_unlikely(x)	unlikely(static_key_enabled(&(x)->key))
>
Ben Pfaff Dec. 18, 2018, 8:16 p.m. UTC | #2
On Fri, Dec 14, 2018 at 03:28:55PM -0800, Yi-Hung Wei wrote:
> The original static key backport is based on the upstream
> net-next commit 11276d5306b8
> ("locking/static_keys: Add a new static_key interface").
> 
> However, in Canonical's Trusty kernel, it introduced partial static
> support which have different definition of some of the macros that
> breaks the compatibility code.
> 
> For example, in net-next git tree commit 11276d5306b8
> ("locking/static_keys: Add a new static_key interface").
> + #define DEFINE_STATIC_KEY_TRUE(name)   \
> +       struct static_key_true name = STATIC_KEY_TRUE_INIT
> 
> On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
> ("x86/KVM/VMX: Add module argument for L1TF mitigation")
> + #define DEFINE_STATIC_KEY_TRUE(name)   \
> +       struct static_key name = STATIC_KEY_INIT_TRUE
> 
> This commit resolves the ovs kernel module compatibility issue on
> Trusty kernel.
> 
> VMware-BZ: #2251101
> Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
> Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>

Applied to master, thanks!
Yi-Hung Wei Dec. 18, 2018, 8:19 p.m. UTC | #3
On Tue, Dec 18, 2018 at 12:16 PM Ben Pfaff <blp@ovn.org> wrote:
>
> On Fri, Dec 14, 2018 at 03:28:55PM -0800, Yi-Hung Wei wrote:
> > The original static key backport is based on the upstream
> > net-next commit 11276d5306b8
> > ("locking/static_keys: Add a new static_key interface").
> >
> > However, in Canonical's Trusty kernel, it introduced partial static
> > support which have different definition of some of the macros that
> > breaks the compatibility code.
> >
> > For example, in net-next git tree commit 11276d5306b8
> > ("locking/static_keys: Add a new static_key interface").
> > + #define DEFINE_STATIC_KEY_TRUE(name)   \
> > +       struct static_key_true name = STATIC_KEY_TRUE_INIT
> >
> > On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
> > ("x86/KVM/VMX: Add module argument for L1TF mitigation")
> > + #define DEFINE_STATIC_KEY_TRUE(name)   \
> > +       struct static_key name = STATIC_KEY_INIT_TRUE
> >
> > This commit resolves the ovs kernel module compatibility issue on
> > Trusty kernel.
> >
> > VMware-BZ: #2251101
> > Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
> > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
>
> Applied to master, thanks!

Hi Ben,

Can you help to bring it back to branch 2.10?  It can be cleanly apply.

Thanks,

-Yi-Hung
Ben Pfaff Dec. 18, 2018, 8:24 p.m. UTC | #4
On Tue, Dec 18, 2018 at 12:19:59PM -0800, Yi-Hung Wei wrote:
> On Tue, Dec 18, 2018 at 12:16 PM Ben Pfaff <blp@ovn.org> wrote:
> >
> > On Fri, Dec 14, 2018 at 03:28:55PM -0800, Yi-Hung Wei wrote:
> > > The original static key backport is based on the upstream
> > > net-next commit 11276d5306b8
> > > ("locking/static_keys: Add a new static_key interface").
> > >
> > > However, in Canonical's Trusty kernel, it introduced partial static
> > > support which have different definition of some of the macros that
> > > breaks the compatibility code.
> > >
> > > For example, in net-next git tree commit 11276d5306b8
> > > ("locking/static_keys: Add a new static_key interface").
> > > + #define DEFINE_STATIC_KEY_TRUE(name)   \
> > > +       struct static_key_true name = STATIC_KEY_TRUE_INIT
> > >
> > > On the other hand, in Canonical's Trusty git tree commit 13f5d5d1cccb6
> > > ("x86/KVM/VMX: Add module argument for L1TF mitigation")
> > > + #define DEFINE_STATIC_KEY_TRUE(name)   \
> > > +       struct static_key name = STATIC_KEY_INIT_TRUE
> > >
> > > This commit resolves the ovs kernel module compatibility issue on
> > > Trusty kernel.
> > >
> > > VMware-BZ: #2251101
> > > Fixes: 6660a9597a49 ("datapath: compat: Introduce static key support")
> > > Signed-off-by: Yi-Hung Wei <yihung.wei@gmail.com>
> >
> > Applied to master, thanks!
> 
> Hi Ben,
> 
> Can you help to bring it back to branch 2.10?  It can be cleanly apply.

Done.
diff mbox series

Patch

diff --git a/acinclude.m4 b/acinclude.m4
index ed83df43df54..63da2d38e14e 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -470,8 +470,10 @@  AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [IS_ERR_OR_NULL])
   OVS_GREP_IFELSE([$KSRC/include/linux/err.h], [PTR_ERR_OR_ZERO])
 
-  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [DEFINE_STATIC_KEY_FALSE],
+  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [static_branch_unlikely(],
                   [OVS_DEFINE([HAVE_UPSTREAM_STATIC_KEY])])
+  OVS_GREP_IFELSE([$KSRC/include/linux/jump_label.h], [DEFINE_STATIC_KEY_FALSE],
+                  [OVS_DEFINE([HAVE_DEFINE_STATIC_KEY])])
 
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [eth_hw_addr_random])
   OVS_GREP_IFELSE([$KSRC/include/linux/etherdevice.h], [ether_addr_copy])
diff --git a/datapath/linux/compat/include/linux/static_key.h b/datapath/linux/compat/include/linux/static_key.h
index ea59e3e285a1..01c6a93f07fe 100644
--- a/datapath/linux/compat/include/linux/static_key.h
+++ b/datapath/linux/compat/include/linux/static_key.h
@@ -23,16 +23,16 @@  struct static_key_false {
 #define rpl_STATIC_KEY_INIT_TRUE	{ .enabled = ATOMIC_INIT(1) }
 #define rpl_STATIC_KEY_INIT_FALSE	{ .enabled = ATOMIC_INIT(0) }
 
-#define STATIC_KEY_TRUE_INIT	\
+#define rpl_STATIC_KEY_TRUE_INIT	\
 	(struct static_key_true) { .key = rpl_STATIC_KEY_INIT_TRUE,  }
-#define STATIC_KEY_FALSE_INIT	\
+#define rpl_STATIC_KEY_FALSE_INIT	\
 	(struct static_key_false){ .key = rpl_STATIC_KEY_INIT_FALSE, }
 
-#define DEFINE_STATIC_KEY_TRUE(name)	\
-	struct static_key_true name = STATIC_KEY_TRUE_INIT
+#define rpl_DEFINE_STATIC_KEY_TRUE(name)	\
+	struct static_key_true name = rpl_STATIC_KEY_TRUE_INIT
 
-#define DEFINE_STATIC_KEY_FALSE(name)	\
-	struct static_key_false name = STATIC_KEY_FALSE_INIT
+#define rpl_DEFINE_STATIC_KEY_FALSE(name)	\
+	struct static_key_false name = rpl_STATIC_KEY_FALSE_INIT
 
 static inline int rpl_static_key_count(struct static_key *key)
 {
@@ -59,6 +59,14 @@  static inline void rpl_static_key_disable(struct static_key *key)
 		static_key_slow_dec(key);
 }
 
+#ifdef	HAVE_DEFINE_STATIC_KEY
+#undef	DEFINE_STATIC_KEY_TRUE
+#undef	DEFINE_STATIC_KEY_FALSE
+#endif
+
+#define DEFINE_STATIC_KEY_TRUE		rpl_DEFINE_STATIC_KEY_TRUE
+#define DEFINE_STATIC_KEY_FALSE		rpl_DEFINE_STATIC_KEY_FALSE
+
 #define static_branch_likely(x)		likely(static_key_enabled(&(x)->key))
 #define static_branch_unlikely(x)	unlikely(static_key_enabled(&(x)->key))