From 00e01dd48c6eb88dafc8e8bb318baa5ad0b536d7 Mon Sep 17 00:00:00 2001 From: Andy Zhou Date: Wed, 10 Sep 2014 15:36:06 -0700 Subject: [PATCH] datapath: Improve robustness of this_cpu_ptr definition in compat layer 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 Acked-by: Pravin B Shelar --- 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 e903273e2..e3a694be2 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -366,8 +366,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 00922ed6b..f7c64e266 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 65bce0847..000000000 --- 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 - -#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 9bd680190..e0941f73d 100644 --- a/datapath/linux/compat/include/linux/percpu.h +++ b/datapath/linux/compat/include/linux/percpu.h @@ -3,6 +3,10 @@ #include_next +#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 -- 2.20.1