[ovs-dev] [PATCH] datapath: Improve robustness of this_cpu_ptr definition in compat layer

Andy Zhou azhou at nicira.com
Wed Sep 10 22:58:18 UTC 2014


Current autoconfig detection logic for HAVE_PER_CPU_PTR is not robust.
Depends on linux kernel version, the definition can be in either
linux/percpu.h or asm/percpu.h

Turns out it is simpler and safer to handle missing percpu.h
definitions in linux/percpu.h rather than asm/percpu.h. With this
change, there is no need for the autoconfig detection logic above.

Signed-off-by: Andy Zhou <azhou at nicira.com>
---
 acinclude.m4                                 |  2 --
 datapath/linux/Modules.mk                    |  1 -
 datapath/linux/compat/include/asm/percpu.h   | 10 ----------
 datapath/linux/compat/include/linux/percpu.h |  4 ++++
 4 files changed, 4 insertions(+), 13 deletions(-)
 delete mode 100644 datapath/linux/compat/include/asm/percpu.h

diff --git a/acinclude.m4 b/acinclude.m4
index b0794d2..ae0f8d8 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -359,8 +359,6 @@ AC_DEFUN([OVS_CHECK_LINUX_COMPAT], [
   OVS_GREP_IFELSE([$KSRC/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD],
                   [OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])])
 
-  OVS_GREP_IFELSE([$KSRC/include/linux/percpu.h], [this_cpu_ptr])
-
   OVS_GREP_IFELSE([$KSRC/include/linux/u64_stats_sync.h], [u64_stats_fetch_begin_irq])
 
   OVS_GREP_IFELSE([$KSRC/include/linux/openvswitch.h], [openvswitch_handle_frame_hook],
diff --git a/datapath/linux/Modules.mk b/datapath/linux/Modules.mk
index 00922ed..f7c64e2 100644
--- a/datapath/linux/Modules.mk
+++ b/datapath/linux/Modules.mk
@@ -18,7 +18,6 @@ openvswitch_sources += \
 openvswitch_headers += \
 	linux/compat/gso.h \
 	linux/compat/include/asm/hash.h \
-	linux/compat/include/asm/percpu.h \
 	linux/compat/include/linux/percpu.h \
 	linux/compat/include/linux/bug.h \
 	linux/compat/include/linux/compiler.h \
diff --git a/datapath/linux/compat/include/asm/percpu.h b/datapath/linux/compat/include/asm/percpu.h
deleted file mode 100644
index 65bce08..0000000
--- a/datapath/linux/compat/include/asm/percpu.h
+++ /dev/null
@@ -1,10 +0,0 @@
-#ifndef __ASM_PERCPU_WRAPPER_H
-#define __ASM_PERCPU_WRAPPER_H 1
-
-#include_next <asm/percpu.h>
-
-#if !defined this_cpu_ptr && !defined HAVE_THIS_CPU_PTR
-#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, smp_processor_id())
-#endif
-
-#endif
diff --git a/datapath/linux/compat/include/linux/percpu.h b/datapath/linux/compat/include/linux/percpu.h
index 9bd6801..e0941f7 100644
--- a/datapath/linux/compat/include/linux/percpu.h
+++ b/datapath/linux/compat/include/linux/percpu.h
@@ -3,6 +3,10 @@
 
 #include_next <linux/percpu.h>
 
+#if !defined this_cpu_ptr
+#define this_cpu_ptr(ptr) per_cpu_ptr(ptr, smp_processor_id())
+#endif
+
 #if !defined this_cpu_read
 #define this_cpu_read(ptr) percpu_read(ptr)
 #endif
-- 
1.9.1




More information about the dev mailing list