]>
Commit | Line | Data |
---|---|---|
5041df65 JR |
1 | From f9208dc00756dfa0a2f191799722030bdf3f793d Mon Sep 17 00:00:00 2001 |
2 | From: Michael Jeanson <mjeanson@efficios.com> | |
3 | Date: Mon, 4 Apr 2022 15:14:01 -0400 | |
4 | Subject: [PATCH 10/13] fix: mm: compaction: cleanup the compaction trace | |
5 | events (v5.18) | |
6 | ||
7 | See upstream commit : | |
8 | ||
9 | commit abd4349ff9b8d242376b67711254221f64f447c7 | |
10 | Author: Baolin Wang <baolin.wang@linux.alibaba.com> | |
11 | Date: Tue Mar 22 14:45:56 2022 -0700 | |
12 | ||
13 | mm: compaction: cleanup the compaction trace events | |
14 | ||
15 | As Steven suggested [1], we should access the pointers from the trace | |
16 | event to avoid dereferencing them to the tracepoint function when the | |
17 | tracepoint is disabled. | |
18 | ||
19 | [1] https://lkml.org/lkml/2021/11/3/409 | |
20 | ||
21 | Change-Id: I6c08250df8596e8dbc76780ae5d95c899c12e6fe | |
22 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | |
23 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | |
24 | --- | |
25 | include/instrumentation/events/compaction.h | 17 ++++++++++++++++- | |
26 | src/probes/Kbuild | 17 ++++++++++++++++- | |
27 | src/probes/lttng-probe-compaction.c | 5 +++++ | |
28 | 3 files changed, 37 insertions(+), 2 deletions(-) | |
29 | ||
30 | diff --git a/include/instrumentation/events/compaction.h b/include/instrumentation/events/compaction.h | |
31 | index 15964537..ecae39a8 100644 | |
32 | --- a/include/instrumentation/events/compaction.h | |
33 | +++ b/include/instrumentation/events/compaction.h | |
34 | @@ -97,7 +97,22 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(compaction_isolate_template, | |
35 | ||
36 | #endif /* #else #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,0,0) */ | |
37 | ||
38 | -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0)) | |
39 | +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0)) | |
40 | +LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages, | |
41 | + | |
42 | + compaction_migratepages, | |
43 | + | |
44 | + TP_PROTO(struct compact_control *cc, | |
45 | + unsigned int nr_succeeded), | |
46 | + | |
47 | + TP_ARGS(cc, nr_succeeded), | |
48 | + | |
49 | + TP_FIELDS( | |
50 | + ctf_integer(unsigned long, nr_migrated, nr_succeeded) | |
51 | + ctf_integer(unsigned long, nr_failed, cc->nr_migratepages - nr_succeeded) | |
52 | + ) | |
53 | +) | |
54 | +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0)) | |
55 | LTTNG_TRACEPOINT_EVENT_MAP(mm_compaction_migratepages, | |
56 | ||
57 | compaction_migratepages, | |
58 | diff --git a/src/probes/Kbuild b/src/probes/Kbuild | |
59 | index 8d6ff0f2..54784477 100644 | |
60 | --- a/src/probes/Kbuild | |
61 | +++ b/src/probes/Kbuild | |
62 | @@ -167,7 +167,22 @@ ifneq ($(CONFIG_BTRFS_FS),) | |
63 | endif # $(wildcard $(btrfs_dep)) | |
64 | endif # CONFIG_BTRFS_FS | |
65 | ||
66 | -obj-$(CONFIG_LTTNG) += lttng-probe-compaction.o | |
67 | +# A dependency on internal header 'mm/internal.h' was introduced in v5.18 | |
68 | +compaction_dep = $(srctree)/mm/internal.h | |
69 | +compaction_dep_wildcard = $(wildcard $(compaction_dep)) | |
70 | +compaction_dep_check = $(shell \ | |
71 | +if [ \( $(VERSION) -ge 6 \ | |
72 | + -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -ge 18 \) \) -a \ | |
73 | + -z "$(compaction_dep_wildcard)" ] ; then \ | |
74 | + echo "warn" ; \ | |
75 | +else \ | |
76 | + echo "ok" ; \ | |
77 | +fi ;) | |
78 | +ifeq ($(compaction_dep_check),ok) | |
79 | + obj-$(CONFIG_LTTNG) += lttng-probe-compaction.o | |
80 | +else | |
81 | + $(warning Files $(compaction_dep) not found. Probe "compaction" is disabled. Use full kernel source tree to enable it.) | |
82 | +endif # $(wildcard $(compaction_dep)) | |
83 | ||
84 | ifneq ($(CONFIG_EXT4_FS),) | |
85 | ext4_dep = $(srctree)/fs/ext4/*.h | |
86 | diff --git a/src/probes/lttng-probe-compaction.c b/src/probes/lttng-probe-compaction.c | |
87 | index f8ddf384..ffaf45f0 100644 | |
88 | --- a/src/probes/lttng-probe-compaction.c | |
89 | +++ b/src/probes/lttng-probe-compaction.c | |
90 | @@ -10,6 +10,11 @@ | |
91 | ||
92 | #include <linux/module.h> | |
93 | #include <lttng/tracer.h> | |
94 | +#include <lttng/kernel-version.h> | |
95 | + | |
96 | +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0)) | |
97 | +#include "../mm/internal.h" | |
98 | +#endif | |
99 | ||
100 | /* | |
101 | * Create the tracepoint static inlines from the kernel to validate that our | |
102 | -- | |
103 | 2.36.1 | |
104 |