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:45:22 +0000 (20:45 -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 cb46c17707c242af54027c21bd03ed1e5d682754..844b9068afe33100bae1895bdc5b2fcdc68b4964 100644 (file)
@@ -10,6 +10,12 @@ ifneq ($(DEB_API_VERSION), 0)
 ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION)
 endif
 
+RHEL_API_VERSION:=$(shell $(MAKEFILEDIR)/abi-rhel-version.sh $(CURDIR))
+
+ifneq ($(RHEL_API_VERSION), 0)
+  ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION)
+endif
+
 RT_PATCH_VERSION:=$(shell $(MAKEFILEDIR)/rt-patch-version.sh $(KERNELDIR))
 
 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 9edad7abc5e195793b84de5bc9e70da1152b2d06..d5bbe5bdf43cb44fe5d2a7cd77ba2aea420a09c3 100644 (file)
@@ -201,7 +201,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 cb730118e208b3bbd73cfc4c16fbb68542b74efc..b0e95e21b368cbdb14995dea13cf2ffaffbc1de9 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 c0088c633d16f3e9c5067577c0b02f8269a84437..b4f7191b658ad8155a4d944f7014a5fef4df4287 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 225940c90d67ce71ad718b879eb8ee1ed8266e7b..215662b783887d1d05cc7b5adb40cebce7d53ba6 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 561094b3ae924a6545cf795f0ba838040c1273fe..ad600ddce31fc8c1a1823d5a21a9c5d3bf029c61 100644 (file)
@@ -39,7 +39,7 @@
 #include "percpu-defs.h"
 #include "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.032009 seconds and 4 git commands to generate.