[lttng-dev] [PATCH lttng-modules] Fix: Add granularity to RHEL kernel version checks

Mathieu Desnoyers mathieu.desnoyers at efficios.com
Wed Mar 30 00:46:19 UTC 2016


merged into master, stable-2.8 and stable-2.7, thanks!

Mathieu

----- On Mar 29, 2016, at 7:32 PM, Michael Jeanson mjeanson at efficios.com wrote:

> Our RHEL kernel version macros were based on the major and minor version
> of the distribution version like "7.2" instead of the full kernel version
> like "327.4.4". This prevented us from adding compatibility changes with
> sufficient granularity.
> 
> Signed-off-by: Michael Jeanson <mjeanson at efficios.com>
> ---
> Makefile.ABI.workarounds                        |  6 ++++++
> abi-rhel-version.sh                             | 21 +++++++++++++++++++++
> instrumentation/events/lttng-module/block.h     |  2 +-
> instrumentation/events/lttng-module/kvm.h       |  4 ++--
> instrumentation/events/lttng-module/scsi.h      |  2 +-
> instrumentation/events/lttng-module/writeback.h |  3 ++-
> lttng-kernel-version.h                          | 24 ++++++++++++++++--------
> wrapper/trace-clock.h                           |  2 +-
> 8 files changed, 50 insertions(+), 14 deletions(-)
> create mode 100755 abi-rhel-version.sh
> 
> diff --git a/Makefile.ABI.workarounds b/Makefile.ABI.workarounds
> index d30aeaf..470bdef 100644
> --- a/Makefile.ABI.workarounds
> +++ b/Makefile.ABI.workarounds
> @@ -10,6 +10,12 @@ ifneq ($(DEB_API_VERSION), 0)
>   ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION)
> endif
> 
> +RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/abi-rhel-version.sh
> $(CURDIR))
> +
> +ifneq ($(RHEL_API_VERSION), 0)
> +  ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION)
> +endif
> +
> RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/rt-patch-version.sh
> $(CURDIR))
> 
> ifneq ($(RT_PATCH_VERSION), 0)
> diff --git a/abi-rhel-version.sh b/abi-rhel-version.sh
> new file mode 100755
> index 0000000..30f3c17
> --- /dev/null
> +++ b/abi-rhel-version.sh
> @@ -0,0 +1,21 @@
> +#!/bin/sh
> +
> +# First argument is the path to the kernel headers.
> +KPATH=$1
> +
> +if [ ! -f ${KPATH}/include/generated/uapi/linux/version.h ]; then
> +	echo 0
> +	exit 0
> +fi
> +
> +# Assuming KPATH is the target kernel headers directory
> +RHEL_RELEASE=$(sed -rn 's/^#define RHEL_RELEASE "(.*)"/\1/p'
> ${KPATH}/include/generated/uapi/linux/version.h)
> +
> +RHEL_RELEASE_MAJOR=$(echo ${RHEL_RELEASE} | sed -r
> 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\1/')
> +RHEL_RELEASE_MINOR=$(echo ${RHEL_RELEASE} | sed -r
> 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\2/')
> +RHEL_RELEASE_PATCH=$(echo ${RHEL_RELEASE} | sed -r
> 's/^([0-9]+)\.([0-9]+)\.([0-9]+)/\3/')
> +
> +# Combine all update numbers into one
> +RHEL_API_VERSION=$((RHEL_RELEASE_MAJOR * 10000 + RHEL_RELEASE_MINOR * 100 +
> RHEL_RELEASE_PATCH))
> +
> +echo ${RHEL_API_VERSION}
> diff --git a/instrumentation/events/lttng-module/block.h
> b/instrumentation/events/lttng-module/block.h
> index b8d9390..75cb11b 100644
> --- a/instrumentation/events/lttng-module/block.h
> +++ b/instrumentation/events/lttng-module/block.h
> @@ -203,7 +203,7 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(block_rq_with_error,
> block_rq_requeue,
> 	|| LTTNG_KERNEL_RANGE(3,4,91, 3,5,0)		\
> 	|| LTTNG_KERNEL_RANGE(3,2,58, 3,3,0)		\
> 	|| LTTNG_UBUNTU_KERNEL_RANGE(3,13,11,28, 3,14,0,0)	\
> -	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,7,1, 3,11,0,0,0))
> +	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0))
> 
> /**
>  * block_rq_complete - block IO operation completed by device driver
> diff --git a/instrumentation/events/lttng-module/kvm.h
> b/instrumentation/events/lttng-module/kvm.h
> index 725a601..a8b3e9a 100644
> --- a/instrumentation/events/lttng-module/kvm.h
> +++ b/instrumentation/events/lttng-module/kvm.h
> @@ -112,7 +112,7 @@ LTTNG_TRACEPOINT_EVENT(kvm_fpu,
> )
> 
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0) \
> -	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,7,2, 3,11,0,0,0))
> +	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,327,0,0, 3,11,0,0,0,0))
> 
> LTTNG_TRACEPOINT_EVENT(kvm_age_page,
> 	TP_PROTO(ulong gfn, int level, struct kvm_memory_slot *slot, int ref),
> @@ -199,7 +199,7 @@
> LTTNG_TRACEPOINT_EVENT_INSTANCE(kvm_async_pf_nopresent_ready,
> kvm_async_pf_ready
> )
> 
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,13,0) \
> -	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,7,1, 3,11,0,0,0))
> +	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,229,0,0, 3,11,0,0,0,0))
> 
> LTTNG_TRACEPOINT_EVENT(
> 	kvm_async_pf_completed,
> diff --git a/instrumentation/events/lttng-module/scsi.h
> b/instrumentation/events/lttng-module/scsi.h
> index dd5f084..e57e460 100644
> --- a/instrumentation/events/lttng-module/scsi.h
> +++ b/instrumentation/events/lttng-module/scsi.h
> @@ -16,7 +16,7 @@
> #define scsi_opcode_name(opcode)	{ opcode, #opcode }
> 
> #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,0) \
> -	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,7,2, 3,11,0,0,0))
> +	|| LTTNG_RHEL_KERNEL_RANGE(3,10,0,327,0,0, 3,11,0,0,0,0))
> 
> #define show_opcode_name(val)					\
> 	__print_symbolic(val,					\
> diff --git a/instrumentation/events/lttng-module/writeback.h
> b/instrumentation/events/lttng-module/writeback.h
> index cfa903e..a215f55 100644
> --- a/instrumentation/events/lttng-module/writeback.h
> +++ b/instrumentation/events/lttng-module/writeback.h
> @@ -13,7 +13,8 @@
> #ifndef _TRACE_WRITEBACK_DEF_
> #define _TRACE_WRITEBACK_DEF_
> 
> -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0))
> +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,0,0) && \
> +	LTTNG_RHEL_VERSION_CODE < LTTNG_RHEL_KERNEL_VERSION(3,10,0,327,10,1))
> static inline struct backing_dev_info *inode_to_bdi(struct inode *inode)
> {
> 	struct super_block *sb = inode->i_sb;
> diff --git a/lttng-kernel-version.h b/lttng-kernel-version.h
> index ac61739..d9a5f13 100644
> --- a/lttng-kernel-version.h
> +++ b/lttng-kernel-version.h
> @@ -39,6 +39,8 @@
> 	(LINUX_VERSION_CODE >= KERNEL_VERSION(a_low, b_low, c_low) && \
> 	 LINUX_VERSION_CODE < KERNEL_VERSION(a_high, b_high, c_high))
> 
> +/* Ubuntu */
> +
> #define LTTNG_UBUNTU_KERNEL_VERSION(a, b, c, d) \
> 	(((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
> 
> @@ -56,6 +58,8 @@
> 		LTTNG_UBUNTU_VERSION_CODE < \
> 		LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
> 
> +/* Debian */
> +
> #define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
> 	(((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) +
> 	(f))
> 
> @@ -73,22 +77,26 @@
> 		LTTNG_DEBIAN_VERSION_CODE < \
> 		LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
> 
> -#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e) \
> -	(((a) * (1ULL << 32)) + ((b) << 24) + ((c) << 16) + ((d) << 8) + (e))
> +#define LTTNG_RHEL_KERNEL_VERSION(a, b, c, d, e, f) \
> +	(((((a) << 16) + ((b) << 8) + (c)) * 10000000ULL) + ((d) * 10000) + ((e) *
> 100) + (f))
> +
> +/* RHEL */
> 
> -#ifdef RHEL_RELEASE_CODE
> +#ifdef RHEL_API_VERSION
> #define LTTNG_RHEL_VERSION_CODE \
> -	((LINUX_VERSION_CODE * (1ULL << 16)) + RHEL_RELEASE_CODE)
> +	((LINUX_VERSION_CODE * 10000000ULL) + RHEL_API_VERSION)
> #else
> #define LTTNG_RHEL_VERSION_CODE		0
> #endif
> 
> -#define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, \
> -		a_high, b_high, c_high, d_high, e_high) \
> +#define LTTNG_RHEL_KERNEL_RANGE(a_low, b_low, c_low, d_low, e_low, f_low, \
> +		a_high, b_high, c_high, d_high, e_high, f_high) \
> 	(LTTNG_RHEL_VERSION_CODE >= \
> -		LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low) && \
> +		LTTNG_RHEL_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
> 		LTTNG_RHEL_VERSION_CODE < \
> -		LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high))
> +		LTTNG_RHEL_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
> +
> +/* RT patch */
> 
> #define LTTNG_RT_KERNEL_VERSION(a, b, c, d) \
> 	(((a) << 24) + ((b) << 16) + ((c) << 8) + (d))
> diff --git a/wrapper/trace-clock.h b/wrapper/trace-clock.h
> index efb49f4..1d14cb9 100644
> --- a/wrapper/trace-clock.h
> +++ b/wrapper/trace-clock.h
> @@ -40,7 +40,7 @@
> #include <wrapper/percpu-defs.h>
> #include <wrapper/random.h>
> 
> -#if ((LTTNG_KERNEL_RANGE(3,10,0, 3,10,14) &&
> !LTTNG_RHEL_KERNEL_RANGE(3,10,0,7,0, 3,10,14,0,0)) \
> +#if ((LTTNG_KERNEL_RANGE(3,10,0, 3,10,14) &&
> !LTTNG_RHEL_KERNEL_RANGE(3,10,0,123,0,0, 3,10,14,0,0,0)) \
> 	|| LTTNG_KERNEL_RANGE(3,11,0, 3,11,3))
> #error "Linux kernels 3.10 and 3.11 introduce a deadlock in the timekeeping
> subsystem. Fixed by commit 7bd36014460f793c19e7d6c94dab67b0afcfcb7f
> \"timekeeping: Fix HRTICK related deadlock from ntp lock changes\" in Linux."
> #endif
> --
> 2.7.4

-- 
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com


More information about the lttng-dev mailing list