summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/lttng/lttng-modules/0010-fix-mm-compaction-cleanup-the-compaction-trace-event.patch
blob: 892d3f0d236bba4dc519317bf08ec5d6b4f48ebf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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/10] 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

Upstream-Status: Backport

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.19.1