Fix: Add granularity to RHEL kernel version checks
authorMichael Jeanson <mjeanson@efficios.com>
Tue, 29 Mar 2016 23:32:19 +0000 (19:32 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 30 Mar 2016 00:43:46 +0000 (20:43 -0400)
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@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile.ABI.workarounds
abi-rhel-version.sh [new file with mode: 0755]
instrumentation/events/lttng-module/block.h
instrumentation/events/lttng-module/kvm.h
instrumentation/events/lttng-module/scsi.h
instrumentation/events/lttng-module/writeback.h
lttng-kernel-version.h
wrapper/trace-clock.h

index d30aeaf2939d1922e076e7d7a9a616301f499966..470bdef71b4a89182969afb473bb618aeb2e406d 100644 (file)
@@ -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 (executable)
index 0000000..30f3c17
--- /dev/null
@@ -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}
index b8d939034f6dd918dc1b876c75f7490cd52fac86..75cb11b40b1018975925971fce2db3b42c60f8c6 100644 (file)
@@ -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
index 725a60167a10bc6f1f46f60c778b3f09b3ed3ab3..a8b3e9a04ded477db0339a25323bab609c1c842f 100644 (file)
@@ -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,
index dd5f084f72c64073d4a1b319325f524b8d725d68..e57e460194c7be576115fd5db879ecdab601726b 100644 (file)
@@ -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,                                   \
index cfa903eb45ff12b4870a3dec966d32618968ab0b..a215f55badf5a024315dc868a1a5bc51fef11bd4 100644 (file)
@@ -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;
index ac61739b9812eed4771abfb56b254da2e42d5113..d9a5f13cfb27e1f4c5f8ce038842546fa94cf0ca 100644 (file)
@@ -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))
 
                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))
index efb49f4c2ed57dde712b74d3855e4e2e903f700c..1d14cb9bd1b4457950f2aa74a933fdb6a50394ee 100644 (file)
@@ -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
This page took 0.030241 seconds and 4 git commands to generate.