]> git.pld-linux.org Git - packages/lttng-modules.git/commitdiff
- upstream fixes for kernel 5.18 compatibility, rel 2 auto/th/lttng-modules-2.13.3-2
authorJan Rękorajski <baggins@pld-linux.org>
Wed, 25 May 2022 14:44:41 +0000 (16:44 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Wed, 25 May 2022 14:44:41 +0000 (16:44 +0200)
14 files changed:
0001-Fix-compaction-migratepages-event-name.patch [new file with mode: 0644]
0002-Fix-tracepoint-event-allow-same-provider-and-event-n.patch [new file with mode: 0644]
0003-fix-sched-tracing-Don-t-re-read-p-state-when-emittin.patch [new file with mode: 0644]
0004-fix-block-remove-genhd.h-v5.18.patch [new file with mode: 0644]
0005-fix-scsi-block-Remove-REQ_OP_WRITE_SAME-support-v5.1.patch [new file with mode: 0644]
0006-fix-random-remove-unused-tracepoints-v5.18.patch [new file with mode: 0644]
0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch [new file with mode: 0644]
0008-fix-scsi-core-Remove-scsi-scsi_request.h-v5.18.patch [new file with mode: 0644]
0009-Rename-genhd-wrapper-to-blkdev.patch [new file with mode: 0644]
0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch [new file with mode: 0644]
0011-Fix-do-not-warn-on-unknown-counter-ioctl.patch [new file with mode: 0644]
0012-fix-KVM-x86-Unexport-kvm_x86_ops-v5.18.patch [new file with mode: 0644]
0013-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch [new file with mode: 0644]
lttng-modules.spec

diff --git a/0001-Fix-compaction-migratepages-event-name.patch b/0001-Fix-compaction-migratepages-event-name.patch
new file mode 100644 (file)
index 0000000..4ce26b9
--- /dev/null
@@ -0,0 +1,35 @@
+From c312bda00d2dc10ce5f6c1189acbefee5c6c8c6c Mon Sep 17 00:00:00 2001
+From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Date: Tue, 29 Mar 2022 16:34:07 -0400
+Subject: [PATCH 01/13] Fix: compaction migratepages event name
+
+The commit "fix: mm: compaction: fix the migration stats in trace_mm_compaction_migratepages() (v5.17)"
+
+Triggers this warning:
+
+    LTTng: event provider mismatch: The event name needs to start with provider name + _ + one or more letter, provider: compaction, event name: mm_compaction_migratepages
+
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Change-Id: I01c7485af765084dafb33bf33ae392e60bfbf1e7
+---
+ include/instrumentation/events/compaction.h | 4 +++-
+ 1 file changed, 3 insertions(+), 1 deletion(-)
+
+diff --git a/include/instrumentation/events/compaction.h b/include/instrumentation/events/compaction.h
+index 340e41f5..15964537 100644
+--- a/include/instrumentation/events/compaction.h
++++ b/include/instrumentation/events/compaction.h
+@@ -98,7 +98,9 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(compaction_isolate_template,
+ #endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0) */
+ #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0))
+-LTTNG_TRACEPOINT_EVENT(mm_compaction_migratepages,
++LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages,
++
++      compaction_migratepages,
+       TP_PROTO(unsigned long nr_all,
+               unsigned int nr_succeeded),
+-- 
+2.36.1
+
diff --git a/0002-Fix-tracepoint-event-allow-same-provider-and-event-n.patch b/0002-Fix-tracepoint-event-allow-same-provider-and-event-n.patch
new file mode 100644 (file)
index 0000000..623d489
--- /dev/null
@@ -0,0 +1,46 @@
+From a7eb2e3d0a4beb1ee80b132927641dd05ef2d542 Mon Sep 17 00:00:00 2001
+From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Date: Mon, 4 Apr 2022 15:49:32 -0400
+Subject: [PATCH 02/13] Fix: tracepoint event: allow same provider and event
+ name
+
+Using the same name for the provider (TRACE_SYSTEM) and event name
+causes a compilation error because the same identifiers are emitted
+twice.
+
+Fix this by prefixing the provider identifier with
+"__provider_event_desc___".
+
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Change-Id: I8cdf8f859e35b8bd5c19737860d12f1ed546dfc2
+---
+ include/lttng/tracepoint-event-impl.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/include/lttng/tracepoint-event-impl.h b/include/lttng/tracepoint-event-impl.h
+index 38b1dc43..dcb22247 100644
+--- a/include/lttng/tracepoint-event-impl.h
++++ b/include/lttng/tracepoint-event-impl.h
+@@ -1255,7 +1255,7 @@ static const struct lttng_kernel_event_desc __event_desc___##_map = {    \
+ #define TP_ID1(_token, _system)       _token##_system
+ #define TP_ID(_token, _system)        TP_ID1(_token, _system)
+-static const struct lttng_kernel_event_desc * const TP_ID(__event_desc___, TRACE_SYSTEM)[] = {
++static const struct lttng_kernel_event_desc * const TP_ID(__provider_event_desc___, TRACE_SYSTEM)[] = {
+ #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)
+ };
+@@ -1274,8 +1274,8 @@ static const struct lttng_kernel_event_desc * const TP_ID(__event_desc___, TRACE
+ /* non-const because list head will be modified when registered. */
+ static __used struct lttng_kernel_probe_desc TP_ID(__probe_desc___, TRACE_SYSTEM) = {
+       .provider_name = __stringify(TRACE_SYSTEM),
+-      .event_desc = TP_ID(__event_desc___, TRACE_SYSTEM),
+-      .nr_events = ARRAY_SIZE(TP_ID(__event_desc___, TRACE_SYSTEM)),
++      .event_desc = TP_ID(__provider_event_desc___, TRACE_SYSTEM),
++      .nr_events = ARRAY_SIZE(TP_ID(__provider_event_desc___, TRACE_SYSTEM)),
+       .head = { NULL, NULL },
+       .lazy_init_head = { NULL, NULL },
+       .lazy = 0,
+-- 
+2.36.1
+
diff --git a/0003-fix-sched-tracing-Don-t-re-read-p-state-when-emittin.patch b/0003-fix-sched-tracing-Don-t-re-read-p-state-when-emittin.patch
new file mode 100644 (file)
index 0000000..1c2a90d
--- /dev/null
@@ -0,0 +1,181 @@
+From 8e52fd71e693619f7a58de2692e59f0c826e9988 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 13:52:57 -0400
+Subject: [PATCH 03/13] fix: sched/tracing: Don't re-read p->state when
+ emitting sched_switch event (v5.18)
+
+See upstream commit :
+
+  commit fa2c3254d7cfff5f7a916ab928a562d1165f17bb
+  Author: Valentin Schneider <valentin.schneider@arm.com>
+  Date:   Thu Jan 20 16:25:19 2022 +0000
+
+    sched/tracing: Don't re-read p->state when emitting sched_switch event
+
+    As of commit
+
+      c6e7bd7afaeb ("sched/core: Optimize ttwu() spinning on p->on_cpu")
+
+    the following sequence becomes possible:
+
+                          p->__state = TASK_INTERRUPTIBLE;
+                          __schedule()
+                            deactivate_task(p);
+      ttwu()
+        READ !p->on_rq
+        p->__state=TASK_WAKING
+                            trace_sched_switch()
+                              __trace_sched_switch_state()
+                                task_state_index()
+                                  return 0;
+
+    TASK_WAKING isn't in TASK_REPORT, so the task appears as TASK_RUNNING in
+    the trace event.
+
+    Prevent this by pushing the value read from __schedule() down the trace
+    event.
+
+Change-Id: I46743cd006be4b4d573cae2d77df7d6d16744d04
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/instrumentation/events/sched.h | 88 +++++++++++++++++++++++---
+ 1 file changed, 78 insertions(+), 10 deletions(-)
+
+diff --git a/include/instrumentation/events/sched.h b/include/instrumentation/events/sched.h
+index 91953a6f..339bec94 100644
+--- a/include/instrumentation/events/sched.h
++++ b/include/instrumentation/events/sched.h
+@@ -20,7 +20,37 @@
+ #ifndef _TRACE_SCHED_DEF_
+ #define _TRACE_SCHED_DEF_
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++
++static inline long __trace_sched_switch_state(bool preempt,
++              unsigned int prev_state,
++              struct task_struct *p)
++{
++        unsigned int state;
++
++#ifdef CONFIG_SCHED_DEBUG
++        BUG_ON(p != current);
++#endif /* CONFIG_SCHED_DEBUG */
++
++        /*
++         * Preemption ignores task state, therefore preempted tasks are always
++         * RUNNING (we will not have dequeued if state != RUNNING).
++         */
++        if (preempt)
++                return TASK_REPORT_MAX;
++
++        /*
++         * task_state_index() uses fls() and returns a value from 0-8 range.
++         * Decrement it by 1 (except TASK_RUNNING state i.e 0) before using
++         * it for left shift operation to get the correct task->state
++         * mapping.
++         */
++      state = __task_state_index(prev_state, p->exit_state);
++
++        return state ? (1 << (state - 1)) : state;
++}
++
++#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,15,0))
+ static inline long __trace_sched_switch_state(bool preempt, struct task_struct *p)
+ {
+@@ -321,43 +351,81 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new,
+ /*
+  * Tracepoint for task switches, performed by the scheduler:
+  */
++
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
+ LTTNG_TRACEPOINT_EVENT(sched_switch,
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
+       TP_PROTO(bool preempt,
+-               struct task_struct *prev,
+-               struct task_struct *next),
++              unsigned int prev_state,
++              struct task_struct *prev,
++              struct task_struct *next),
+-      TP_ARGS(preempt, prev, next),
++      TP_ARGS(preempt, prev_state, prev, next),
++
++      TP_FIELDS(
++              ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
++              ctf_integer(pid_t, prev_tid, prev->pid)
++              ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
++#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
++              ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(preempt, prev_state, prev))
+ #else
+-      TP_PROTO(struct task_struct *prev,
++              ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev_state, prev))
++#endif
++              ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
++              ctf_integer(pid_t, next_tid, next->pid)
++              ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
++      )
++)
++
++#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
++
++LTTNG_TRACEPOINT_EVENT(sched_switch,
++
++      TP_PROTO(bool preempt,
++               struct task_struct *prev,
+                struct task_struct *next),
+-      TP_ARGS(prev, next),
+-#endif /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0)) */
++      TP_ARGS(preempt, prev, next),
+       TP_FIELDS(
+               ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, prev_tid, prev->pid)
+               ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,4,0))
+ #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+               ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(preempt, prev))
+ #else
+               ctf_integer(long, prev_state, __trace_sched_switch_state(preempt, prev))
+ #endif
++              ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
++              ctf_integer(pid_t, next_tid, next->pid)
++              ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
++      )
++)
++
+ #else
++
++LTTNG_TRACEPOINT_EVENT(sched_switch,
++
++      TP_PROTO(struct task_struct *prev,
++               struct task_struct *next),
++
++      TP_ARGS(prev, next),
++
++      TP_FIELDS(
++              ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
++              ctf_integer(pid_t, prev_tid, prev->pid)
++              ctf_integer(int, prev_prio, prev->prio - MAX_RT_PRIO)
+ #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+               ctf_enum(task_state, long, prev_state, __trace_sched_switch_state(prev))
+ #else
+               ctf_integer(long, prev_state, __trace_sched_switch_state(prev))
+-#endif
+ #endif
+               ctf_array_text(char, next_comm, next->comm, TASK_COMM_LEN)
+               ctf_integer(pid_t, next_tid, next->pid)
+               ctf_integer(int, next_prio, next->prio - MAX_RT_PRIO)
+       )
+ )
++#endif
+ /*
+  * Tracepoint for a task being migrated:
+-- 
+2.36.1
+
diff --git a/0004-fix-block-remove-genhd.h-v5.18.patch b/0004-fix-block-remove-genhd.h-v5.18.patch
new file mode 100644 (file)
index 0000000..d0a5818
--- /dev/null
@@ -0,0 +1,43 @@
+From 868e0b6db59159197c2cec3550fa4ad5e6572bc5 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 13:54:59 -0400
+Subject: [PATCH 04/13] fix: block: remove genhd.h (v5.18)
+
+See upstream commit :
+
+  commit 322cbb50de711814c42fb088f6d31901502c711a
+  Author: Christoph Hellwig <hch@lst.de>
+  Date:   Mon Jan 24 10:39:13 2022 +0100
+
+    block: remove genhd.h
+
+    There is no good reason to keep genhd.h separate from the main blkdev.h
+    header that includes it.  So fold the contents of genhd.h into blkdev.h
+    and remove genhd.h entirely.
+
+Change-Id: I7cf2aaa3a4c133320b95f2edde49f790f9515dbd
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/wrapper/genhd.h | 4 ++++
+ 1 file changed, 4 insertions(+)
+
+diff --git a/include/wrapper/genhd.h b/include/wrapper/genhd.h
+index 3c6dbcbe..4a59b68e 100644
+--- a/include/wrapper/genhd.h
++++ b/include/wrapper/genhd.h
+@@ -12,7 +12,11 @@
+ #ifndef _LTTNG_WRAPPER_GENHD_H
+ #define _LTTNG_WRAPPER_GENHD_H
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++#include <linux/blkdev.h>
++#else
+ #include <linux/genhd.h>
++#endif
+ #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0))
+ #define LTTNG_GENHD_FL_HIDDEN GENHD_FL_HIDDEN
+-- 
+2.36.1
+
diff --git a/0005-fix-scsi-block-Remove-REQ_OP_WRITE_SAME-support-v5.1.patch b/0005-fix-scsi-block-Remove-REQ_OP_WRITE_SAME-support-v5.1.patch
new file mode 100644 (file)
index 0000000..4e9688b
--- /dev/null
@@ -0,0 +1,77 @@
+From 2bc7cb7193124d20aa4e1b5dbad0410bfb97a470 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 14:12:13 -0400
+Subject: [PATCH 05/13] fix: scsi: block: Remove REQ_OP_WRITE_SAME support
+ (v5.18)
+
+See upstream commit :
+
+  commit 73bd66d9c834220579c881a3eb020fd8917075d8
+  Author: Christoph Hellwig <hch@lst.de>
+  Date:   Wed Feb 9 09:28:28 2022 +0100
+
+    scsi: block: Remove REQ_OP_WRITE_SAME support
+
+    No more users of REQ_OP_WRITE_SAME or drivers implementing it are left,
+    so remove the infrastructure.
+
+Change-Id: Ifbff71f79f8b590436fc7cb79f82d90c6e033d84
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/instrumentation/events/block.h | 32 ++++++++++++++++++++++++++
+ 1 file changed, 32 insertions(+)
+
+diff --git a/include/instrumentation/events/block.h b/include/instrumentation/events/block.h
+index 3e1104d7..050a59a2 100644
+--- a/include/instrumentation/events/block.h
++++ b/include/instrumentation/events/block.h
+@@ -66,6 +66,37 @@ LTTNG_TRACEPOINT_ENUM(block_rq_type,
+ #define lttng_bio_op(bio)     bio_op(bio)
+ #define lttng_bio_rw(bio)     ((bio)->bi_opf)
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++#ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
++#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)                             \
++              ctf_enum(block_rq_type, type, rwbs,                                           \
++                      ( (op) == REQ_OP_WRITE ? RWBS_FLAG_WRITE : \
++                      ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD :        \
++                      ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
++                      ( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH :            \
++                      ( (op) == REQ_OP_READ ? RWBS_FLAG_READ :              \
++                      ( 0 ))))))                                            \
++                      | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)          \
++                      | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)              \
++                      | ((rw) & REQ_META ? RWBS_FLAG_META : 0)              \
++                      | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
++                      | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
++#else
++#define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)                             \
++              ctf_integer(type, rwbs,                                       \
++                      ( (op) == REQ_OP_WRITE ? RWBS_FLAG_WRITE : \
++                      ( (op) == REQ_OP_DISCARD ? RWBS_FLAG_DISCARD :        \
++                      ( (op) == REQ_OP_SECURE_ERASE ? (RWBS_FLAG_DISCARD | RWBS_FLAG_SECURE) : \
++                      ( (op) == REQ_OP_FLUSH ? RWBS_FLAG_FLUSH :            \
++                      ( (op) == REQ_OP_READ ? RWBS_FLAG_READ :              \
++                      ( 0 ))))))                                            \
++                      | ((rw) & REQ_RAHEAD ? RWBS_FLAG_RAHEAD : 0)          \
++                      | ((rw) & REQ_SYNC ? RWBS_FLAG_SYNC : 0)              \
++                      | ((rw) & REQ_META ? RWBS_FLAG_META : 0)              \
++                      | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
++                      | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
++#endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */
++#else
+ #ifdef CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM
+ #define blk_rwbs_ctf_integer(type, rwbs, op, rw, bytes)                             \
+               ctf_enum(block_rq_type, type, rwbs,                                           \
+@@ -95,6 +126,7 @@ LTTNG_TRACEPOINT_ENUM(block_rq_type,
+                       | ((rw) & REQ_PREFLUSH ? RWBS_FLAG_PREFLUSH : 0)      \
+                       | ((rw) & REQ_FUA ? RWBS_FLAG_FUA : 0))
+ #endif /* CONFIG_LTTNG_EXPERIMENTAL_BITWISE_ENUM */
++#endif
+ #elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3,1,0))
+-- 
+2.36.1
+
diff --git a/0006-fix-random-remove-unused-tracepoints-v5.18.patch b/0006-fix-random-remove-unused-tracepoints-v5.18.patch
new file mode 100644 (file)
index 0000000..11a0b1a
--- /dev/null
@@ -0,0 +1,45 @@
+From 369d82bb1746447514c877088d7c5fd0f39140f8 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 14:33:42 -0400
+Subject: [PATCH 06/13] fix: random: remove unused tracepoints (v5.18)
+
+See upstream commit :
+
+  commit 14c174633f349cb41ea90c2c0aaddac157012f74
+  Author: Jason A. Donenfeld <Jason@zx2c4.com>
+  Date:   Thu Feb 10 16:40:44 2022 +0100
+
+    random: remove unused tracepoints
+
+    These explicit tracepoints aren't really used and show sign of aging.
+    It's work to keep these up to date, and before I attempted to keep them
+    up to date, they weren't up to date, which indicates that they're not
+    really used. These days there are better ways of introspecting anyway.
+
+Change-Id: I3b8c3e2732e7efdd76ce63204ac53a48784d0df6
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ src/probes/Kbuild | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+diff --git a/src/probes/Kbuild b/src/probes/Kbuild
+index e26b4359..8d6ff0f2 100644
+--- a/src/probes/Kbuild
++++ b/src/probes/Kbuild
+@@ -187,8 +187,11 @@ ifneq ($(CONFIG_FRAME_WARN),0)
+   CFLAGS_lttng-probe-printk.o += -Wframe-larger-than=2200
+ endif
++# Introduced in v3.6, remove in v5.18
+ obj-$(CONFIG_LTTNG) +=  $(shell \
+-    if [ $(VERSION) -ge 4 \
++    if [ \( ! \( $(VERSION) -ge 6 -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -ge 18 \) \) \) \
++      -a \
++      $(VERSION) -ge 4 \
+       -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 6 \) \
+       -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -ge 2 \) \
+       -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 4 -a $(SUBLEVEL) -ge 9 \) \
+-- 
+2.36.1
+
diff --git a/0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch b/0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch
new file mode 100644 (file)
index 0000000..2eca7d1
--- /dev/null
@@ -0,0 +1,70 @@
+From 3c46ddc134621dba65030263aa321dd6bdae3ba3 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 15:02:10 -0400
+Subject: [PATCH 07/13] fix: kprobes: Use rethook for kretprobe if possible
+ (v5.18)
+
+See upstream commit :
+
+  commit 73f9b911faa74ac5107879de05c9489c419f41bb
+  Author: Masami Hiramatsu <mhiramat@kernel.org>
+  Date:   Sat Mar 26 11:27:05 2022 +0900
+
+    kprobes: Use rethook for kretprobe if possible
+
+    Use rethook for kretprobe function return hooking if the arch sets
+    CONFIG_HAVE_RETHOOK=y. In this case, CONFIG_KRETPROBE_ON_RETHOOK is
+    set to 'y' automatically, and the kretprobe internal data fields
+    switches to use rethook. If not, it continues to use kretprobe
+    specific function return hooks.
+
+Change-Id: I2b7670dc04e4769c1e3c372582ad2f555f6d7a66
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/wrapper/kprobes.h     | 17 +++++++++++++++++
+ src/probes/lttng-kretprobes.c |  2 +-
+ 2 files changed, 18 insertions(+), 1 deletion(-)
+
+diff --git a/include/wrapper/kprobes.h b/include/wrapper/kprobes.h
+index b546d615..51d32b7c 100644
+--- a/include/wrapper/kprobes.h
++++ b/include/wrapper/kprobes.h
+@@ -29,4 +29,21 @@ struct kretprobe *lttng_get_kretprobe(struct kretprobe_instance *ri)
+ #endif /* LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0) */
++
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++static inline
++unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri)
++{
++      return get_kretprobe_retaddr(ri);
++}
++
++#else
++
++static inline
++unsigned long lttng_get_kretprobe_retaddr(struct kretprobe_instance *ri)
++{
++      return (unsigned long) ri->ret_addr;
++}
++#endif
++
+ #endif /* _LTTNG_WRAPPER_KPROBES_H */
+diff --git a/src/probes/lttng-kretprobes.c b/src/probes/lttng-kretprobes.c
+index 5cb2e953..565df739 100644
+--- a/src/probes/lttng-kretprobes.c
++++ b/src/probes/lttng-kretprobes.c
+@@ -81,7 +81,7 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi,
+               int ret;
+               payload.ip = (unsigned long) lttng_get_kretprobe(krpi)->kp.addr;
+-              payload.parent_ip = (unsigned long) krpi->ret_addr;
++              payload.parent_ip = lttng_get_kretprobe_retaddr(krpi);
+               lib_ring_buffer_ctx_init(&ctx, event_recorder, sizeof(payload),
+                                        lttng_alignof(payload), &lttng_probe_ctx);
+-- 
+2.36.1
+
diff --git a/0008-fix-scsi-core-Remove-scsi-scsi_request.h-v5.18.patch b/0008-fix-scsi-core-Remove-scsi-scsi_request.h-v5.18.patch
new file mode 100644 (file)
index 0000000..e1816ac
--- /dev/null
@@ -0,0 +1,42 @@
+From e8d2f286b5b208ac8870d0a9c167b170e96169b3 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 15:08:48 -0400
+Subject: [PATCH 08/13] fix: scsi: core: Remove <scsi/scsi_request.h> (v5.18)
+
+See upstream commit :
+
+  commit 26440303310591e29121964ede0048583cb3126d
+  Author: Christoph Hellwig <hch@lst.de>
+  Date:   Thu Feb 24 18:55:52 2022 +0100
+
+    scsi: core: Remove <scsi/scsi_request.h>
+
+    This header is empty now except for an include of <linux/blk-mq.h>, so
+    remove it.
+
+Change-Id: Ic8ee3352f1e8bddfcd44c31be9b788db82f183aa
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/instrumentation/events/block.h | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/include/instrumentation/events/block.h b/include/instrumentation/events/block.h
+index 050a59a2..882e6e08 100644
+--- a/include/instrumentation/events/block.h
++++ b/include/instrumentation/events/block.h
+@@ -11,9 +11,9 @@
+ #include <linux/trace_seq.h>
+ #include <lttng/kernel-version.h>
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0))
++#if LTTNG_KERNEL_RANGE(4,11,0, 5,18,0)
+ #include <scsi/scsi_request.h>
+-#endif /* (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,11,0)) */
++#endif /* LTTNG_KERNEL_RANGE(4,11,0, 5,18,0) */
+ #ifndef _TRACE_BLOCK_DEF_
+ #define _TRACE_BLOCK_DEF_
+-- 
+2.36.1
+
diff --git a/0009-Rename-genhd-wrapper-to-blkdev.patch b/0009-Rename-genhd-wrapper-to-blkdev.patch
new file mode 100644 (file)
index 0000000..72abfe3
--- /dev/null
@@ -0,0 +1,74 @@
+From 82fbf9d383ff9069808fb0f5f75c660098dbae52 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Tue, 5 Apr 2022 14:57:41 -0400
+Subject: [PATCH 09/13] Rename genhd wrapper to blkdev
+
+The genhd.h header was folded into blkdev.h in v5.18, rename our wrapper
+to follow upstream.
+
+Change-Id: I4ec94fb94d11712dd20f0680aea1de77fbfa9d17
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/wrapper/{genhd.h => blkdev.h} | 10 +++++-----
+ src/lttng-statedump-impl.c            |  2 +-
+ 2 files changed, 6 insertions(+), 6 deletions(-)
+ rename include/wrapper/{genhd.h => blkdev.h} (93%)
+
+diff --git a/include/wrapper/genhd.h b/include/wrapper/blkdev.h
+similarity index 93%
+rename from include/wrapper/genhd.h
+rename to include/wrapper/blkdev.h
+index 4a59b68e..0d5ad90f 100644
+--- a/include/wrapper/genhd.h
++++ b/include/wrapper/blkdev.h
+@@ -1,6 +1,6 @@
+ /* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
+  *
+- * wrapper/genhd.h
++ * wrapper/blkdev.h
+  *
+  * wrapper around block layer functions and data structures. Using
+  * KALLSYMS to get its address when available, else we need to have a
+@@ -9,8 +9,8 @@
+  * Copyright (C) 2011-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+  */
+-#ifndef _LTTNG_WRAPPER_GENHD_H
+-#define _LTTNG_WRAPPER_GENHD_H
++#ifndef _LTTNG_WRAPPER_BLKDEV_H
++#define _LTTNG_WRAPPER_BLKDEV_H
+ #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
+ #include <linux/blkdev.h>
+@@ -45,7 +45,7 @@ struct class *wrapper_get_block_class(void)
+ /*
+  * Canary function to check for 'block_class' at compile time.
+  *
+- * From 'include/linux/genhd.h':
++ * From 'include/linux/blkdev.h':
+  *
+  *   extern struct class block_class;
+  */
+@@ -104,4 +104,4 @@ struct device_type *wrapper_get_disk_type(void)
+ #endif
+-#endif /* _LTTNG_WRAPPER_GENHD_H */
++#endif /* _LTTNG_WRAPPER_BLKDEV_H */
+diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c
+index 4d7b2921..0e753090 100644
+--- a/src/lttng-statedump-impl.c
++++ b/src/lttng-statedump-impl.c
+@@ -41,7 +41,7 @@
+ #include <wrapper/namespace.h>
+ #include <wrapper/irq.h>
+ #include <wrapper/tracepoint.h>
+-#include <wrapper/genhd.h>
++#include <wrapper/blkdev.h>
+ #include <wrapper/file.h>
+ #include <wrapper/fdtable.h>
+ #include <wrapper/sched.h>
+-- 
+2.36.1
+
diff --git a/0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch b/0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch
new file mode 100644 (file)
index 0000000..a1515c8
--- /dev/null
@@ -0,0 +1,104 @@
+From f9208dc00756dfa0a2f191799722030bdf3f793d Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 15:14:01 -0400
+Subject: [PATCH 10/13] fix: mm: compaction: cleanup the compaction trace
+ events (v5.18)
+
+See upstream commit :
+
+  commit abd4349ff9b8d242376b67711254221f64f447c7
+  Author: Baolin Wang <baolin.wang@linux.alibaba.com>
+  Date:   Tue Mar 22 14:45:56 2022 -0700
+
+    mm: compaction: cleanup the compaction trace events
+
+    As Steven suggested [1], we should access the pointers from the trace
+    event to avoid dereferencing them to the tracepoint function when the
+    tracepoint is disabled.
+
+    [1] https://lkml.org/lkml/2021/11/3/409
+
+Change-Id: I6c08250df8596e8dbc76780ae5d95c899c12e6fe
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/instrumentation/events/compaction.h | 17 ++++++++++++++++-
+ src/probes/Kbuild                           | 17 ++++++++++++++++-
+ src/probes/lttng-probe-compaction.c         |  5 +++++
+ 3 files changed, 37 insertions(+), 2 deletions(-)
+
+diff --git a/include/instrumentation/events/compaction.h b/include/instrumentation/events/compaction.h
+index 15964537..ecae39a8 100644
+--- a/include/instrumentation/events/compaction.h
++++ b/include/instrumentation/events/compaction.h
+@@ -97,7 +97,22 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(compaction_isolate_template,
+ #endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0) */
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0))
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages,
++
++      compaction_migratepages,
++
++      TP_PROTO(struct compact_control *cc,
++              unsigned int nr_succeeded),
++
++      TP_ARGS(cc, nr_succeeded),
++
++      TP_FIELDS(
++              ctf_integer(unsigned long, nr_migrated, nr_succeeded)
++              ctf_integer(unsigned long, nr_failed, cc->nr_migratepages - nr_succeeded)
++      )
++)
++#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0))
+ LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages,
+       compaction_migratepages,
+diff --git a/src/probes/Kbuild b/src/probes/Kbuild
+index 8d6ff0f2..54784477 100644
+--- a/src/probes/Kbuild
++++ b/src/probes/Kbuild
+@@ -167,7 +167,22 @@ ifneq ($(CONFIG_BTRFS_FS),)
+   endif # $(wildcard $(btrfs_dep))
+ endif # CONFIG_BTRFS_FS
+-obj-$(CONFIG_LTTNG) += lttng-probe-compaction.o
++# A dependency on internal header 'mm/internal.h' was introduced in v5.18
++compaction_dep = $(srctree)/mm/internal.h
++compaction_dep_wildcard = $(wildcard $(compaction_dep))
++compaction_dep_check = $(shell \
++if [ \( $(VERSION) -ge 6 \
++   -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -ge 18 \) \) -a \
++   -z "$(compaction_dep_wildcard)" ] ; then \
++  echo "warn" ; \
++else \
++  echo "ok" ; \
++fi ;)
++ifeq ($(compaction_dep_check),ok)
++  obj-$(CONFIG_LTTNG) += lttng-probe-compaction.o
++else
++  $(warning Files $(compaction_dep) not found. Probe "compaction" is disabled. Use full kernel source tree to enable it.)
++endif # $(wildcard $(compaction_dep))
+ ifneq ($(CONFIG_EXT4_FS),)
+   ext4_dep = $(srctree)/fs/ext4/*.h
+diff --git a/src/probes/lttng-probe-compaction.c b/src/probes/lttng-probe-compaction.c
+index f8ddf384..ffaf45f0 100644
+--- a/src/probes/lttng-probe-compaction.c
++++ b/src/probes/lttng-probe-compaction.c
+@@ -10,6 +10,11 @@
+ #include <linux/module.h>
+ #include <lttng/tracer.h>
++#include <lttng/kernel-version.h>
++
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++#include "../mm/internal.h"
++#endif
+ /*
+  * Create the tracepoint static inlines from the kernel to validate that our
+-- 
+2.36.1
+
diff --git a/0011-Fix-do-not-warn-on-unknown-counter-ioctl.patch b/0011-Fix-do-not-warn-on-unknown-counter-ioctl.patch
new file mode 100644 (file)
index 0000000..9d05a15
--- /dev/null
@@ -0,0 +1,29 @@
+From 43e623f93ffb9386165c2149705ee716ef88e3a5 Mon Sep 17 00:00:00 2001
+From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Date: Fri, 8 Apr 2022 14:33:20 -0400
+Subject: [PATCH 11/13] Fix: do not warn on unknown counter ioctl
+
+It is perfectly valid for a newer lttng-tools to try to use an unknown
+ioctl and handle -ENOSYS.
+
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+Change-Id: Ia9f6472ca1196f983eee1327805b0ad69d028a98
+---
+ src/lttng-abi.c | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/src/lttng-abi.c b/src/lttng-abi.c
+index fa7eca6f..c3e67690 100644
+--- a/src/lttng-abi.c
++++ b/src/lttng-abi.c
+@@ -730,7 +730,6 @@ long lttng_counter_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+               return lttng_kernel_counter_clear(counter, indexes);
+       }
+       default:
+-              WARN_ON_ONCE(1);
+               return -ENOSYS;
+       }
+ }
+-- 
+2.36.1
+
diff --git a/0012-fix-KVM-x86-Unexport-kvm_x86_ops-v5.18.patch b/0012-fix-KVM-x86-Unexport-kvm_x86_ops-v5.18.patch
new file mode 100644 (file)
index 0000000..8312044
--- /dev/null
@@ -0,0 +1,190 @@
+From 45240b53fb037012a86613150fd5dc7e151fb7d1 Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Mon, 4 Apr 2022 16:28:26 -0400
+Subject: [PATCH 12/13] fix: KVM: x86: Unexport kvm_x86_ops (v5.18)
+
+See upstream commit :
+
+  commit dfc4e6ca041135217c07ebcd102b6694cea22856
+  Author: Sean Christopherson <seanjc@google.com>
+  Date:   Fri Jan 28 00:51:56 2022 +0000
+
+    KVM: x86: Unexport kvm_x86_ops
+
+    Drop the export of kvm_x86_ops now it is no longer referenced by SVM or
+    VMX.  Disallowing access to kvm_x86_ops is very desirable as it prevents
+    vendor code from incorrectly modifying hooks after they have been set by
+    kvm_arch_hardware_setup(), and more importantly after each function's
+    associated static_call key has been updated.
+
+    No functional change intended.
+
+Change-Id: Icee959a984570f95ab9b71354225b5aeecea7da0
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ .../events/arch/x86/kvm/trace.h               | 47 +++++++++++-
+ include/wrapper/kvm-x86.h                     | 72 +++++++++++++++++++
+ 2 files changed, 117 insertions(+), 2 deletions(-)
+ create mode 100644 include/wrapper/kvm-x86.h
+
+diff --git a/include/instrumentation/events/arch/x86/kvm/trace.h b/include/instrumentation/events/arch/x86/kvm/trace.h
+index 42e5b94d..0d6c4e33 100644
+--- a/include/instrumentation/events/arch/x86/kvm/trace.h
++++ b/include/instrumentation/events/arch/x86/kvm/trace.h
+@@ -9,6 +9,7 @@
+ #include <asm/clocksource.h>
+ #endif
+ #include <lttng/kernel-version.h>
++#include <wrapper/kvm-x86.h>
+ #include <../arch/x86/kvm/lapic.h>
+ #include <../arch/x86/kvm/kvm_cache_regs.h>
+@@ -115,7 +116,40 @@ LTTNG_TRACEPOINT_EVENT_MAP(kvm_apic, kvm_x86_apic,
+ /*
+  * Tracepoint for kvm guest exit:
+  */
+-#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,16,0))
++#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
++LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
++      TP_PROTO(struct kvm_vcpu *vcpu, u32 isa),
++      TP_ARGS(vcpu, isa),
++
++      TP_locvar(
++              u32 exit_reason;
++              u64 info1, info2;
++              u32 intr_info, error_code;
++      ),
++
++      TP_code_pre(
++              lttng_kvm_x86_get_exit_info(vcpu,
++                              &tp_locvar->exit_reason,
++                              &tp_locvar->info1,
++                              &tp_locvar->info2,
++                              &tp_locvar->intr_info,
++                              &tp_locvar->error_code);
++      ),
++
++      TP_FIELDS(
++              ctf_integer(unsigned int, exit_reason, tp_locvar->exit_reason)
++              ctf_integer(unsigned long, guest_rip, kvm_rip_read(vcpu))
++              ctf_integer(u32, isa, isa)
++              ctf_integer(u64, info1, tp_locvar->info1)
++              ctf_integer(u64, info2, tp_locvar->info2)
++              ctf_integer(u32, intr_info, tp_locvar->intr_info)
++              ctf_integer(u32, error_code, tp_locvar->error_code)
++              ctf_integer(unsigned int, vcpu_id, vcpu->vcpu_id)
++      ),
++
++      TP_code_post()
++)
++#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,16,0))
+ LTTNG_TRACEPOINT_EVENT_CODE_MAP(kvm_exit, kvm_x86_exit,
+       TP_PROTO(struct kvm_vcpu *vcpu, u32 isa),
+       TP_ARGS(vcpu, isa),
+@@ -535,7 +569,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn,
+                               vcpu->arch.emulate_ctxt.fetch.data)
+               ctf_array(__u8, insn, vcpu->arch.emulate_ctxt.fetch.data, 15)
+               ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt.mode))
+-#else
++#elif (LTTNG_LINUX_VERSION_CODE < LTTNG_KERNEL_VERSION(5,18,0))
+               ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt->_eip -
+                               (vcpu->arch.emulate_ctxt->fetch.ptr -
+                                       vcpu->arch.emulate_ctxt->fetch.data))
+@@ -544,6 +578,15 @@ LTTNG_TRACEPOINT_EVENT_MAP(kvm_emulate_insn, kvm_x86_emulate_insn,
+                               vcpu->arch.emulate_ctxt->fetch.data)
+               ctf_array(__u8, insn, vcpu->arch.emulate_ctxt->fetch.data, 15)
+               ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt->mode))
++#else
++              ctf_integer(__u64, rip, vcpu->arch.emulate_ctxt->_eip -
++                              (vcpu->arch.emulate_ctxt->fetch.ptr -
++                                      vcpu->arch.emulate_ctxt->fetch.data))
++              ctf_integer(__u32, csbase, lttng_kvm_x86_get_segment_base(vcpu, VCPU_SREG_CS))
++              ctf_integer(__u8, len, vcpu->arch.emulate_ctxt->fetch.ptr -
++                              vcpu->arch.emulate_ctxt->fetch.data)
++              ctf_array(__u8, insn, vcpu->arch.emulate_ctxt->fetch.data, 15)
++              ctf_integer(__u8, flags, kei_decode_mode(vcpu->arch.emulate_ctxt->mode))
+ #endif
+               ctf_integer(__u8, failed, failed)
+       )
+diff --git a/include/wrapper/kvm-x86.h b/include/wrapper/kvm-x86.h
+new file mode 100644
+index 00000000..2007aebd
+--- /dev/null
++++ b/include/wrapper/kvm-x86.h
+@@ -0,0 +1,72 @@
++/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
++ *
++ * wrapper/kvm-x86.h
++ *
++ * Copyright (C) 2022 Michael Jeanson <mjeanson@efficios.com>
++ */
++
++#ifndef _LTTNG_WRAPPER_KVM_X86_H
++#define _LTTNG_WRAPPER_KVM_X86_H
++
++#include <linux/kvm_host.h>
++#include <lttng/kernel-version.h>
++
++#if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0)
++
++#ifdef CONFIG_KALLSYMS_ALL
++#include <linux/kallsyms.h>
++#include <wrapper/kallsyms.h>
++
++static struct kvm_x86_ops *kvm_x86_ops_sym;
++
++static inline
++void lttng_kvm_x86_get_exit_info(
++              struct kvm_vcpu *vcpu, u32 *reason,
++              u64 *info1, u64 *info2,
++              u32 *exit_int_info, u32 *exit_int_info_err_code)
++{
++      if (!kvm_x86_ops_sym)
++              kvm_x86_ops_sym =
++                      (void *) kallsyms_lookup_dataptr("kvm_x86_ops");
++
++      if (kvm_x86_ops_sym) {
++              kvm_x86_ops_sym->get_exit_info(vcpu, reason, info1, info2,
++                              exit_int_info, exit_int_info_err_code);
++      } else {
++              printk_once(KERN_WARNING "LTTng: kvm_x86_ops symbol lookup failed.\n");
++      }
++}
++
++static inline
++u64 lttng_kvm_x86_get_segment_base(struct kvm_vcpu *vcpu, int seg)
++{
++      if (!kvm_x86_ops_sym)
++              kvm_x86_ops_sym =
++                      (void *) kallsyms_lookup_dataptr("kvm_x86_ops");
++
++      if (kvm_x86_ops_sym) {
++              return kvm_x86_ops_sym->get_segment_base(vcpu, seg);
++      } else {
++              printk_once(KERN_WARNING "LTTng: kvm_x86_ops symbol lookup failed.\n");
++              return 0;
++      }
++}
++
++/*
++ * Canary function to check for 'kvm_x86_ops' at compile time.
++ *
++ * From 'arch/x86/include/asm/kvm_host.h':
++ *
++ *   extern struct kvm_x86_ops kvm_x86_ops;;
++ */
++static inline
++unsigned int __canary__kvm_x86_ops(void)
++{
++      return kvm_x86_ops.vm_size;
++}
++
++#endif /* CONFIG_KALLSYMS_ALL */
++
++#endif
++
++#endif /* _LTTNG_WRAPPER_KVM_X86_H */
+-- 
+2.36.1
+
diff --git a/0013-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch b/0013-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch
new file mode 100644 (file)
index 0000000..b91cff7
--- /dev/null
@@ -0,0 +1,56 @@
+From 9c5b8de32b5745f3ff31079c02da64595e101bee Mon Sep 17 00:00:00 2001
+From: Michael Jeanson <mjeanson@efficios.com>
+Date: Tue, 17 May 2022 11:46:29 -0400
+Subject: [PATCH 13/13] fix: sched/tracing: Append prev_state to tp args
+ instead (v5.18)
+
+See upstream commit :
+
+  commit 9c2136be0878c88c53dea26943ce40bb03ad8d8d
+  Author: Delyan Kratunov <delyank@fb.com>
+  Date:   Wed May 11 18:28:36 2022 +0000
+
+    sched/tracing: Append prev_state to tp args instead
+
+    Commit fa2c3254d7cf (sched/tracing: Don't re-read p->state when emitting
+    sched_switch event, 2022-01-20) added a new prev_state argument to the
+    sched_switch tracepoint, before the prev task_struct pointer.
+
+    This reordering of arguments broke BPF programs that use the raw
+    tracepoint (e.g. tp_btf programs). The type of the second argument has
+    changed and existing programs that assume a task_struct* argument
+    (e.g. for bpf_task_storage access) will now fail to verify.
+
+    If we instead append the new argument to the end, all existing programs
+    would continue to work and can conditionally extract the prev_state
+    argument on supported kernel versions.
+
+Change-Id: Ife2ec88a8bea2743562590cbd357068d7773863f
+Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
+Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+---
+ include/instrumentation/events/sched.h | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/include/instrumentation/events/sched.h b/include/instrumentation/events/sched.h
+index 339bec94..c1c3df15 100644
+--- a/include/instrumentation/events/sched.h
++++ b/include/instrumentation/events/sched.h
+@@ -356,11 +356,11 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(sched_wakeup_template, sched_wakeup_new,
+ LTTNG_TRACEPOINT_EVENT(sched_switch,
+       TP_PROTO(bool preempt,
+-              unsigned int prev_state,
+               struct task_struct *prev,
+-              struct task_struct *next),
++              struct task_struct *next,
++              unsigned int prev_state),
+-      TP_ARGS(preempt, prev_state, prev, next),
++      TP_ARGS(preempt, prev, next, prev_state),
+       TP_FIELDS(
+               ctf_array_text(char, prev_comm, prev->comm, TASK_COMM_LEN)
+-- 
+2.36.1
+
index 992e18893a09fde53976f25485dce273e5be55fe..dfb56921c05ca891df4c7dd825490708e5ee0f98 100644 (file)
@@ -6,7 +6,7 @@
 # nothing to be placed to debuginfo package
 %define                _enable_debug_packages  0
 
-%define                rel     1
+%define                rel     2
 %define                pname   lttng-modules
 Summary:       LTTng 2.x kernel modules
 Summary(pl.UTF-8):     Moduły jądra LTTng 2.x
@@ -18,6 +18,19 @@ Group:               Base/Kernel
 Source0:       https://lttng.org/files/lttng-modules/%{pname}-%{version}.tar.bz2
 # Source0-md5: 7f25ed040ca46c3c643e9a44dd258d3b
 Patch0:                build.patch
+Patch1:                0001-Fix-compaction-migratepages-event-name.patch
+Patch2:                0002-Fix-tracepoint-event-allow-same-provider-and-event-n.patch
+Patch3:                0003-fix-sched-tracing-Don-t-re-read-p-state-when-emittin.patch
+Patch4:                0004-fix-block-remove-genhd.h-v5.18.patch
+Patch5:                0005-fix-scsi-block-Remove-REQ_OP_WRITE_SAME-support-v5.1.patch
+Patch6:                0006-fix-random-remove-unused-tracepoints-v5.18.patch
+Patch7:                0007-fix-kprobes-Use-rethook-for-kretprobe-if-possible-v5.patch
+Patch8:                0008-fix-scsi-core-Remove-scsi-scsi_request.h-v5.18.patch
+Patch9:                0009-Rename-genhd-wrapper-to-blkdev.patch
+Patch10:       0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch
+Patch11:       0011-Fix-do-not-warn-on-unknown-counter-ioctl.patch
+Patch12:       0012-fix-KVM-x86-Unexport-kvm_x86_ops-v5.18.patch
+Patch13:       0013-fix-sched-tracing-Append-prev_state-to-tp-args-inste.patch
 URL:           https://lttng.org/
 %{expand:%buildrequires_kernel kernel%%{_alt_kernel}-module-build >= 3:3.0}
 %{?with_kernelsrc:%{expand:%buildrequires_kernel kernel%%{_alt_kernel}-source >= 3:3.0}}
@@ -94,6 +107,19 @@ p=`pwd`\
 %setup -qc -n %{name}-%{version}
 cd %{pname}-%{version}
 %patch0 -p1
+%patch1 -p1
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
+%patch6 -p1
+%patch7 -p1
+%patch8 -p1
+%patch9 -p1
+%patch10 -p1
+%patch11 -p1
+%patch12 -p1
+%patch13 -p1
 
 %build
 cd  %{pname}-%{version}
This page took 0.161165 seconds and 4 git commands to generate.