Fix: discover Debian API
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Apr 2015 14:57:34 +0000 (10:57 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 27 Apr 2015 14:58:07 +0000 (10:58 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Makefile
Makefile.ABI.workarounds [new file with mode: 0644]
abi-debian-version.sh [new file with mode: 0755]
instrumentation/events/lttng-module/kmem.h
lib/Makefile
lttng-kernel-version.h
probes/Makefile

index 07d9d72e21a78f92847765b06a5894172af83f82..5277386915d87ce6bf7afefdb164e274b0879212 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -5,6 +5,8 @@
 ifneq ($(KERNELRELEASE),)
 ifneq ($(CONFIG_TRACEPOINTS),)
 
+KERNELDIR=${LTTNG_KERNELDIR}
+
 lttng_check_linux_version = $(shell pwd)/include/linux/version.h
 lttng_check_generated_linux_version = $(shell pwd)/include/generated/uapi/linux/version.h
 
@@ -19,6 +21,8 @@ $(error Duplicate version.h files found in $(lttng_check_linux_version) and $(lt
 endif
 endif
 
+include $(KBUILD_EXTMOD)/Makefile.ABI.workarounds
+
 obj-m += lttng-ring-buffer-client-discard.o
 obj-m += lttng-ring-buffer-client-overwrite.o
 obj-m += lttng-ring-buffer-metadata-client.o
@@ -69,14 +73,14 @@ else # KERNELRELEASE
        CFLAGS = $(EXTCFLAGS)
 
 default:
-       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
+       LTTNG_KERNELDIR=$(KERNELDIR) $(MAKE) -C $(KERNELDIR) M=$(PWD) modules
 
 modules_install:
-       $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
+       LTTNG_KERNELDIR=$(KERNELDIR) $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install
 
 clean:
-       $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
+       LTTNG_KERNELDIR=$(KERNELDIR) $(MAKE) -C $(KERNELDIR) M=$(PWD) clean
 
 %.i: %.c
-       $(MAKE) -C $(KERNELDIR) M=$(PWD) $@
+       LTTNG_KERNELDIR=$(KERNELDIR) $(MAKE) -C $(KERNELDIR) M=$(PWD) $@
 endif # KERNELRELEASE
diff --git a/Makefile.ABI.workarounds b/Makefile.ABI.workarounds
new file mode 100644 (file)
index 0000000..f00340c
--- /dev/null
@@ -0,0 +1,11 @@
+# Work-around for distro-specific public modules ABI breakages.
+# Some distributions break the public module instrumentation ABI
+# compared to upstream stable kernels without providing other mean than
+# the kernel EXTRAVERSION to figure it out. Translate this information
+# into a define visible from the C preprocessor.
+
+DEB_API_VERSION=$(shell $(KBUILD_EXTMOD)/abi-debian-version.sh $(KERNELDIR))
+
+ifneq ($(DEB_API_VERSION), 0)
+ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION)
+endif
diff --git a/abi-debian-version.sh b/abi-debian-version.sh
new file mode 100755 (executable)
index 0000000..a864a21
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+# First argument is the path to the kernel headers.
+KPATH=$1
+
+if [ ! -f ${KPATH}/include/generated/package.h ]; then
+       echo 0
+       exit 0
+fi
+
+# Debian snippet courtesy of Ben Hutchings
+
+# Assuming KPATH is the target kernel headers directory
+DEB_PACKAGE_VERSION=$(sed -rn 's/^#define LINUX_PACKAGE_ID " Debian (.*)"/\1/p' ${KPATH}/include/generated/package.h)
+# Ignore backports part
+DEB_PACKAGE_VERSION=$(echo ${DEB_PACKAGE_VERSION} | sed -r 's/~(bpo|deb).*//')
+# Get -ckt update number, if present
+KERNEL_CKT_UPDATE=$(echo ${DEB_PACKAGE_VERSION} | sed -rn 's/^[0-9]+\.[0-9]+\.[0-9]+-ckt([0-9]+).*/\1/p')
+test -n "${KERNEL_CKT_UPDATE}" || KERNEL_CKT_UPDATE=0
+# Get package revision
+DEB_PACKAGE_REVISION=$(echo ${DEB_PACKAGE_VERSION} | sed -r 's/.*-([^-]+)$/\1/')
+# Get non-sec update number
+DEB_PACKAGE_REVISION_BASE=$(echo ${DEB_PACKAGE_REVISION} | sed -r 's/^([0-9]+).*/\1/')
+# Get security update number, if present
+DEB_PACKAGE_REVISION_SECURITY=$(echo ${DEB_PACKAGE_REVISION} | sed -rn 's/.*\+(squeeze|deb[0-9])+u([0-9]+)$/\1/p')
+test -n "${DEB_PACKAGE_REVISION_SECURITY}" || DEB_PACKAGE_REVISION_SECURITY=0
+# Combine all update numbers into one
+DEB_API_VERSION=$((KERNEL_CKT_UPDATE * 10000 + DEB_PACKAGE_REVISION_BASE * 100 + DEB_PACKAGE_REVISION_SECURITY))
+
+echo ${DEB_API_VERSION}
index 710c9fa53af1038ce5f795509e74814727a0feee..7efca3e8358a3ba37bc86d900aa2b4a861532afe 100644 (file)
@@ -287,7 +287,8 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_PRINT(mm_page, mm_page_pcpu_drain,
 )
 
 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,19,2)      \
-       || LTTNG_KERNEL_RANGE(3,14,36, 3,15,0))
+       || LTTNG_KERNEL_RANGE(3,14,36, 3,15,0)          \
+       || LTTNG_DEBIAN_KERNEL_RANGE(3,16,7,9,0,0, 3,17,0,0,0,0))
 
 LTTNG_TRACEPOINT_EVENT(mm_page_alloc_extfrag,
 
index 5f092f553cee10587a147918edb59bfab7761ade..420c85a5e587a81fd67ccb8d5344287ce4bf01d3 100644 (file)
@@ -1,3 +1,7 @@
+KERNELDIR=${LTTNG_KERNELDIR}
+
+include $(KBUILD_EXTMOD)/Makefile.ABI.workarounds
+
 obj-m += lttng-lib-ring-buffer.o
 
 lttng-lib-ring-buffer-objs := \
index ec8cee0b30bc2a710f0629e14ceb89265ac0593d..59e19df55ff775a82eeaf747b1590555ab31c5be 100644 (file)
                LTTNG_UBUNTU_VERSION_CODE < \
                LTTNG_UBUNTU_KERNEL_VERSION(a_high, b_high, c_high, d_high))
 
+#define LTTNG_DEBIAN_KERNEL_VERSION(a, b, c, d, e, f) \
+       (((((a) << 16) + ((b) << 8) + (c)) * 1000000ULL) + ((d) * 10000) + ((e) * 100) + (f))
+
+#define LTTNG_DEBIAN_VERSION_CODE \
+       ((LINUX_VERSION_CODE * 1000000ULL) + DEBIAN_API_VERSION)
+
+#define LTTNG_DEBIAN_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) \
+       (defined(DEBIAN_API_VERSION) && \
+               LTTNG_DEBIAN_VERSION_CODE >= \
+               LTTNG_DEBIAN_KERNEL_VERSION(a_low, b_low, c_low, d_low, e_low, f_low) && \
+               LTTNG_DEBIAN_VERSION_CODE < \
+               LTTNG_DEBIAN_KERNEL_VERSION(a_high, b_high, c_high, d_high, e_high, f_high))
+
 #endif /* _LTTNG_KERNEL_VERSION_H */
index a228f8a4fb8862c2a36e1c9452a97cf3b96b010a..4d38199e37c1208ac79b23addd49fce2c54755a1 100644 (file)
@@ -5,6 +5,10 @@
 ifneq ($(KERNELRELEASE),)
 ifneq ($(CONFIG_TRACEPOINTS),)
 
+KERNELDIR=${LTTNG_KERNELDIR}
+
+include $(KBUILD_EXTMOD)/Makefile.ABI.workarounds
+
 ccflags-y += -I$(PWD)/probes
 obj-m += lttng-types.o
 
This page took 0.028955 seconds and 4 git commands to generate.