diff options
| author | Alexander Kanavin <alex.kanavin@gmail.com> | 2020-10-28 22:05:44 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-10-30 13:22:49 +0000 |
| commit | 9624092cd61bdde9bcef3361cff898282e50dcae (patch) | |
| tree | d962e774876b63c3acd3c5c7898d2cd15351e942 /meta/recipes-kernel/lttng | |
| parent | 6d3c1edca59528ea8d0ed212729e6b689657eddb (diff) | |
| download | poky-9624092cd61bdde9bcef3361cff898282e50dcae.tar.gz | |
lttng-modules: update 2.12.2 -> 2.12.3
Drop a pile of backports.
(From OE-Core rev: fba843f79ac6ad2636385de2bd63e90e08c04fcd)
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/lttng')
11 files changed, 1 insertions, 1829 deletions
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0001-Kconfig-fix-dependency-issue-when-building-in-tree-w.patch b/meta/recipes-kernel/lttng/lttng-modules/0001-Kconfig-fix-dependency-issue-when-building-in-tree-w.patch deleted file mode 100644 index ae8bec45de..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0001-Kconfig-fix-dependency-issue-when-building-in-tree-w.patch +++ /dev/null | |||
| @@ -1,54 +0,0 @@ | |||
| 1 | From ff4d1d7e85be94ef43709cd698f0ec9a12f247d1 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 3 | Date: Thu, 13 Aug 2020 16:24:39 +0300 | ||
| 4 | Subject: [PATCH 01/10] Kconfig: fix dependency issue when building in-tree | ||
| 5 | without CONFIG_FTRACE | ||
| 6 | |||
| 7 | When building in-tree, one could disable CONFIG_FTRACE from kernel | ||
| 8 | config which will leave CONFIG_TRACEPOINTS selected by LTTNG modules, | ||
| 9 | but generate a lot of linker errors like below because it leaves out | ||
| 10 | other stuff, e.g.: | ||
| 11 | |||
| 12 | trace.c:(.text+0xd86b): undefined reference to `trace_event_buffer_reserve' | ||
| 13 | ld: trace.c:(.text+0xd8de): undefined reference to `trace_event_buffer_commit' | ||
| 14 | ld: trace.c:(.text+0xd926): undefined reference to `event_triggers_call' | ||
| 15 | ld: trace.c:(.text+0xd942): undefined reference to `trace_event_ignore_this_pid' | ||
| 16 | ld: net/mac80211/trace.o: in function `trace_event_raw_event_drv_tdls_cancel_channel_switch': | ||
| 17 | |||
| 18 | It appears to be caused by the fact that TRACE_EVENT macros in the Linux | ||
| 19 | kernel depend on the Ftrace ring buffer as soon as CONFIG_TRACEPOINTS is | ||
| 20 | enabled. | ||
| 21 | |||
| 22 | Steps to reproduce: | ||
| 23 | |||
| 24 | - Get a clone of an upstream stable kernel and use scripts/built-in.sh on it | ||
| 25 | |||
| 26 | - Configure a standard x86-64 build, enable built-in LTTNG but disable | ||
| 27 | CONFIG_FTRACE from Kernel Hacking-->Tracers using menuconfig | ||
| 28 | |||
| 29 | - Build will fail at linking stage | ||
| 30 | |||
| 31 | Upstream-Status: Backport | ||
| 32 | |||
| 33 | Signed-off-by: Beniamin Sandu <beniaminsandu@gmail.com> | ||
| 34 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 35 | --- | ||
| 36 | Kconfig | 2 +- | ||
| 37 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
| 38 | |||
| 39 | diff --git a/Kconfig b/Kconfig | ||
| 40 | index acdab73..10eccff 100644 | ||
| 41 | --- a/Kconfig | ||
| 42 | +++ b/Kconfig | ||
| 43 | @@ -2,7 +2,7 @@ | ||
| 44 | |||
| 45 | config LTTNG | ||
| 46 | tristate "LTTng support" | ||
| 47 | - select TRACEPOINTS | ||
| 48 | + select TRACING | ||
| 49 | help | ||
| 50 | LTTng is an open source tracing framework for Linux. | ||
| 51 | |||
| 52 | -- | ||
| 53 | 2.19.1 | ||
| 54 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0002-fix-Move-mmutrace.h-into-the-mmu-sub-directory-v5.9.patch b/meta/recipes-kernel/lttng/lttng-modules/0002-fix-Move-mmutrace.h-into-the-mmu-sub-directory-v5.9.patch deleted file mode 100644 index fab673b854..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0002-fix-Move-mmutrace.h-into-the-mmu-sub-directory-v5.9.patch +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | From e10ab43dd0e425df5bc0ac763447664ed075ba05 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 10 Aug 2020 11:22:05 -0400 | ||
| 4 | Subject: [PATCH 02/10] fix: Move mmutrace.h into the mmu/ sub-directory (v5.9) | ||
| 5 | |||
| 6 | commit 33e3042dac6bcc33b80835f7d7b502b1d74c457c | ||
| 7 | Author: Sean Christopherson <sean.j.christopherson@intel.com> | ||
| 8 | Date: Mon Jun 22 13:20:29 2020 -0700 | ||
| 9 | |||
| 10 | KVM: x86/mmu: Move mmu_audit.c and mmutrace.h into the mmu/ sub-directory | ||
| 11 | |||
| 12 | Move mmu_audit.c and mmutrace.h under mmu/ where they belong. | ||
| 13 | |||
| 14 | Upstream-Status: Backport | ||
| 15 | |||
| 16 | Change-Id: I582525ccca34e1e3bd62870364108a7d3e9df2e4 | ||
| 17 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 18 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 19 | --- | ||
| 20 | probes/lttng-probe-kvm-x86-mmu.c | 4 ++++ | ||
| 21 | 1 file changed, 4 insertions(+) | ||
| 22 | |||
| 23 | diff --git a/probes/lttng-probe-kvm-x86-mmu.c b/probes/lttng-probe-kvm-x86-mmu.c | ||
| 24 | index 37384a2..5a7ef1e 100644 | ||
| 25 | --- a/probes/lttng-probe-kvm-x86-mmu.c | ||
| 26 | +++ b/probes/lttng-probe-kvm-x86-mmu.c | ||
| 27 | @@ -24,7 +24,11 @@ | ||
| 28 | */ | ||
| 29 | #include <wrapper/tracepoint.h> | ||
| 30 | |||
| 31 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 32 | +#include <../../arch/x86/kvm/mmu/mmutrace.h> | ||
| 33 | +#else | ||
| 34 | #include <../../arch/x86/kvm/mmutrace.h> | ||
| 35 | +#endif | ||
| 36 | |||
| 37 | #undef TRACE_INCLUDE_PATH | ||
| 38 | #undef TRACE_INCLUDE_FILE | ||
| 39 | -- | ||
| 40 | 2.19.1 | ||
| 41 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-KVM-x86-mmu-Make-kvm_mmu_page-definition-and-acc.patch b/meta/recipes-kernel/lttng/lttng-modules/0003-fix-KVM-x86-mmu-Make-kvm_mmu_page-definition-and-acc.patch deleted file mode 100644 index 524631cc72..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0003-fix-KVM-x86-mmu-Make-kvm_mmu_page-definition-and-acc.patch +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | From f16315cc45c4c6b880de541bb092ca18a13952b7 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 10 Aug 2020 11:36:03 -0400 | ||
| 4 | Subject: [PATCH 03/10] fix: KVM: x86/mmu: Make kvm_mmu_page definition and | ||
| 5 | accessor internal-only (v5.9) | ||
| 6 | |||
| 7 | commit 985ab2780164698ec6e7d73fad523d50449261dd | ||
| 8 | Author: Sean Christopherson <sean.j.christopherson@intel.com> | ||
| 9 | Date: Mon Jun 22 13:20:32 2020 -0700 | ||
| 10 | |||
| 11 | KVM: x86/mmu: Make kvm_mmu_page definition and accessor internal-only | ||
| 12 | |||
| 13 | Make 'struct kvm_mmu_page' MMU-only, nothing outside of the MMU should | ||
| 14 | be poking into the gory details of shadow pages. | ||
| 15 | |||
| 16 | Upstream-Status: Backport | ||
| 17 | |||
| 18 | Change-Id: Ia5c1b9c49c2b00dad1d5b17c50c3dc730dafda20 | ||
| 19 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 20 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 21 | --- | ||
| 22 | probes/lttng-probe-kvm-x86-mmu.c | 1 + | ||
| 23 | 1 file changed, 1 insertion(+) | ||
| 24 | |||
| 25 | diff --git a/probes/lttng-probe-kvm-x86-mmu.c b/probes/lttng-probe-kvm-x86-mmu.c | ||
| 26 | index 5a7ef1e..8f98186 100644 | ||
| 27 | --- a/probes/lttng-probe-kvm-x86-mmu.c | ||
| 28 | +++ b/probes/lttng-probe-kvm-x86-mmu.c | ||
| 29 | @@ -25,6 +25,7 @@ | ||
| 30 | #include <wrapper/tracepoint.h> | ||
| 31 | |||
| 32 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 33 | +#include <../../arch/x86/kvm/mmu/mmu_internal.h> | ||
| 34 | #include <../../arch/x86/kvm/mmu/mmutrace.h> | ||
| 35 | #else | ||
| 36 | #include <../../arch/x86/kvm/mmutrace.h> | ||
| 37 | -- | ||
| 38 | 2.19.1 | ||
| 39 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0004-fix-ext4-limit-the-length-of-per-inode-prealloc-list.patch b/meta/recipes-kernel/lttng/lttng-modules/0004-fix-ext4-limit-the-length-of-per-inode-prealloc-list.patch deleted file mode 100644 index e29c07252c..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0004-fix-ext4-limit-the-length-of-per-inode-prealloc-list.patch +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 1 | From 8fe742807e65af29dac3fea568ff93cbc5dd9a56 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 24 Aug 2020 15:26:04 -0400 | ||
| 4 | Subject: [PATCH 04/10] fix: ext4: limit the length of per-inode prealloc list | ||
| 5 | (v5.9) | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | See upstream commit: | ||
| 11 | |||
| 12 | commit 27bc446e2def38db3244a6eb4bb1d6312936610a | ||
| 13 | Author: brookxu <brookxu.cn@gmail.com> | ||
| 14 | Date: Mon Aug 17 15:36:15 2020 +0800 | ||
| 15 | |||
| 16 | ext4: limit the length of per-inode prealloc list | ||
| 17 | |||
| 18 | In the scenario of writing sparse files, the per-inode prealloc list may | ||
| 19 | be very long, resulting in high overhead for ext4_mb_use_preallocated(). | ||
| 20 | To circumvent this problem, we limit the maximum length of per-inode | ||
| 21 | prealloc list to 512 and allow users to modify it. | ||
| 22 | |||
| 23 | After patching, we observed that the sys ratio of cpu has dropped, and | ||
| 24 | the system throughput has increased significantly. We created a process | ||
| 25 | to write the sparse file, and the running time of the process on the | ||
| 26 | fixed kernel was significantly reduced, as follows: | ||
| 27 | |||
| 28 | Running time on unfixed kernel: | ||
| 29 | [root@TENCENT64 ~]# time taskset 0x01 ./sparse /data1/sparce.dat | ||
| 30 | real 0m2.051s | ||
| 31 | user 0m0.008s | ||
| 32 | sys 0m2.026s | ||
| 33 | |||
| 34 | Running time on fixed kernel: | ||
| 35 | [root@TENCENT64 ~]# time taskset 0x01 ./sparse /data1/sparce.dat | ||
| 36 | real 0m0.471s | ||
| 37 | user 0m0.004s | ||
| 38 | sys 0m0.395s | ||
| 39 | |||
| 40 | Upstream-Status: Backport | ||
| 41 | |||
| 42 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 43 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 44 | Change-Id: I5169cb24853d4da32e2862a6626f1f058689b053 | ||
| 45 | --- | ||
| 46 | instrumentation/events/lttng-module/ext4.h | 15 +++++++++++++++ | ||
| 47 | 1 file changed, 15 insertions(+) | ||
| 48 | |||
| 49 | diff --git a/instrumentation/events/lttng-module/ext4.h b/instrumentation/events/lttng-module/ext4.h | ||
| 50 | index 5f7ab28..72ad4c9 100644 | ||
| 51 | --- a/instrumentation/events/lttng-module/ext4.h | ||
| 52 | +++ b/instrumentation/events/lttng-module/ext4.h | ||
| 53 | @@ -460,6 +460,20 @@ LTTNG_TRACEPOINT_EVENT(ext4_mb_release_group_pa, | ||
| 54 | ) | ||
| 55 | #endif | ||
| 56 | |||
| 57 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 58 | +LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations, | ||
| 59 | + TP_PROTO(struct inode *inode, unsigned int len, unsigned int needed), | ||
| 60 | + | ||
| 61 | + TP_ARGS(inode, len, needed), | ||
| 62 | + | ||
| 63 | + TP_FIELDS( | ||
| 64 | + ctf_integer(dev_t, dev, inode->i_sb->s_dev) | ||
| 65 | + ctf_integer(ino_t, ino, inode->i_ino) | ||
| 66 | + ctf_integer(unsigned int, len, len) | ||
| 67 | + ctf_integer(unsigned int, needed, needed) | ||
| 68 | + ) | ||
| 69 | +) | ||
| 70 | +#else | ||
| 71 | LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations, | ||
| 72 | TP_PROTO(struct inode *inode), | ||
| 73 | |||
| 74 | @@ -470,6 +484,7 @@ LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations, | ||
| 75 | ctf_integer(ino_t, ino, inode->i_ino) | ||
| 76 | ) | ||
| 77 | ) | ||
| 78 | +#endif | ||
| 79 | |||
| 80 | LTTNG_TRACEPOINT_EVENT(ext4_mb_discard_preallocations, | ||
| 81 | TP_PROTO(struct super_block *sb, int needed), | ||
| 82 | -- | ||
| 83 | 2.19.1 | ||
| 84 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0005-fix-ext4-indicate-via-a-block-bitmap-read-is-prefetc.patch b/meta/recipes-kernel/lttng/lttng-modules/0005-fix-ext4-indicate-via-a-block-bitmap-read-is-prefetc.patch deleted file mode 100644 index f76e9698c8..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0005-fix-ext4-indicate-via-a-block-bitmap-read-is-prefetc.patch +++ /dev/null | |||
| @@ -1,63 +0,0 @@ | |||
| 1 | From 52563d02a9234215b62c5f519aa1b5d8589ccd0a Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 24 Aug 2020 15:37:50 -0400 | ||
| 4 | Subject: [PATCH 05/10] =?UTF-8?q?fix:=20ext4:=20indicate=20via=20a=20block?= | ||
| 5 | =?UTF-8?q?=20bitmap=20read=20is=20prefetched=E2=80=A6=20(v5.9)?= | ||
| 6 | MIME-Version: 1.0 | ||
| 7 | Content-Type: text/plain; charset=UTF-8 | ||
| 8 | Content-Transfer-Encoding: 8bit | ||
| 9 | |||
| 10 | See upstream commit: | ||
| 11 | |||
| 12 | commit ab74c7b23f3770935016e3eb3ecdf1e42b73efaa | ||
| 13 | Author: Theodore Ts'o <tytso@mit.edu> | ||
| 14 | Date: Wed Jul 15 11:48:55 2020 -0400 | ||
| 15 | |||
| 16 | ext4: indicate via a block bitmap read is prefetched via a tracepoint | ||
| 17 | |||
| 18 | Modify the ext4_read_block_bitmap_load tracepoint so that it tells us | ||
| 19 | whether a block bitmap is being prefetched. | ||
| 20 | |||
| 21 | Upstream-Status: Backport | ||
| 22 | |||
| 23 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 24 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 25 | Change-Id: I0e5e2c5b8004223d0928235c092449ee16a940e1 | ||
| 26 | --- | ||
| 27 | instrumentation/events/lttng-module/ext4.h | 14 ++++++++++++++ | ||
| 28 | 1 file changed, 14 insertions(+) | ||
| 29 | |||
| 30 | diff --git a/instrumentation/events/lttng-module/ext4.h b/instrumentation/events/lttng-module/ext4.h | ||
| 31 | index 72ad4c9..4476abb 100644 | ||
| 32 | --- a/instrumentation/events/lttng-module/ext4.h | ||
| 33 | +++ b/instrumentation/events/lttng-module/ext4.h | ||
| 34 | @@ -893,12 +893,26 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(ext4__bitmap_load, ext4_mb_buddy_bitmap_load, | ||
| 35 | TP_ARGS(sb, group) | ||
| 36 | ) | ||
| 37 | |||
| 38 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 39 | +LTTNG_TRACEPOINT_EVENT(ext4_read_block_bitmap_load, | ||
| 40 | + TP_PROTO(struct super_block *sb, unsigned long group, bool prefetch), | ||
| 41 | + | ||
| 42 | + TP_ARGS(sb, group, prefetch), | ||
| 43 | + | ||
| 44 | + TP_FIELDS( | ||
| 45 | + ctf_integer(dev_t, dev, sb->s_dev) | ||
| 46 | + ctf_integer(__u32, group, group) | ||
| 47 | + ctf_integer(bool, prefetch, prefetch) | ||
| 48 | + ) | ||
| 49 | +) | ||
| 50 | +#else | ||
| 51 | LTTNG_TRACEPOINT_EVENT_INSTANCE(ext4__bitmap_load, ext4_read_block_bitmap_load, | ||
| 52 | |||
| 53 | TP_PROTO(struct super_block *sb, unsigned long group), | ||
| 54 | |||
| 55 | TP_ARGS(sb, group) | ||
| 56 | ) | ||
| 57 | +#endif | ||
| 58 | |||
| 59 | LTTNG_TRACEPOINT_EVENT_INSTANCE(ext4__bitmap_load, ext4_load_inode_bitmap, | ||
| 60 | |||
| 61 | -- | ||
| 62 | 2.19.1 | ||
| 63 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0006-fix-removal-of-smp_-read_barrier_depends-v5.9.patch b/meta/recipes-kernel/lttng/lttng-modules/0006-fix-removal-of-smp_-read_barrier_depends-v5.9.patch deleted file mode 100644 index 0970dd30aa..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0006-fix-removal-of-smp_-read_barrier_depends-v5.9.patch +++ /dev/null | |||
| @@ -1,391 +0,0 @@ | |||
| 1 | From 57ccbfa6a8a79c7b84394c2097efaf7935607aa5 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Tue, 25 Aug 2020 10:56:29 -0400 | ||
| 4 | Subject: [PATCH 06/10] fix: removal of [smp_]read_barrier_depends (v5.9) | ||
| 5 | |||
| 6 | See upstream commits: | ||
| 7 | |||
| 8 | commit 76ebbe78f7390aee075a7f3768af197ded1bdfbb | ||
| 9 | Author: Will Deacon <will@kernel.org> | ||
| 10 | Date: Tue Oct 24 11:22:47 2017 +0100 | ||
| 11 | |||
| 12 | locking/barriers: Add implicit smp_read_barrier_depends() to READ_ONCE() | ||
| 13 | |||
| 14 | In preparation for the removal of lockless_dereference(), which is the | ||
| 15 | same as READ_ONCE() on all architectures other than Alpha, add an | ||
| 16 | implicit smp_read_barrier_depends() to READ_ONCE() so that it can be | ||
| 17 | used to head dependency chains on all architectures. | ||
| 18 | |||
| 19 | commit 76ebbe78f7390aee075a7f3768af197ded1bdfbb | ||
| 20 | Author: Will Deacon <will.deacon@arm.com> | ||
| 21 | Date: Tue Oct 24 11:22:47 2017 +0100 | ||
| 22 | |||
| 23 | locking/barriers: Add implicit smp_read_barrier_depends() to READ_ONCE() | ||
| 24 | |||
| 25 | In preparation for the removal of lockless_dereference(), which is the | ||
| 26 | same as READ_ONCE() on all architectures other than Alpha, add an | ||
| 27 | implicit smp_read_barrier_depends() to READ_ONCE() so that it can be | ||
| 28 | used to head dependency chains on all architectures. | ||
| 29 | |||
| 30 | Upstream-Status: Backport | ||
| 31 | |||
| 32 | Change-Id: Ife8880bd9378dca2972da8838f40fc35ccdfaaac | ||
| 33 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 34 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 35 | --- | ||
| 36 | instrumentation/events/lttng-module/i2c.h | 4 ++-- | ||
| 37 | lib/ringbuffer/backend.h | 2 +- | ||
| 38 | lib/ringbuffer/backend_internal.h | 2 +- | ||
| 39 | lib/ringbuffer/frontend.h | 4 ++-- | ||
| 40 | lib/ringbuffer/ring_buffer_frontend.c | 4 ++-- | ||
| 41 | lib/ringbuffer/ring_buffer_iterator.c | 2 +- | ||
| 42 | lttng-events.c | 8 ++++---- | ||
| 43 | probes/lttng-kprobes.c | 6 +++--- | ||
| 44 | probes/lttng-kretprobes.c | 6 +++--- | ||
| 45 | probes/lttng-tracepoint-event-impl.h | 12 ++++++------ | ||
| 46 | probes/lttng-uprobes.c | 6 +++--- | ||
| 47 | wrapper/compiler.h | 18 ++++++++++++++++++ | ||
| 48 | wrapper/trace-clock.h | 15 +++++---------- | ||
| 49 | 13 files changed, 51 insertions(+), 38 deletions(-) | ||
| 50 | |||
| 51 | diff --git a/instrumentation/events/lttng-module/i2c.h b/instrumentation/events/lttng-module/i2c.h | ||
| 52 | index dcbabf6..131d134 100644 | ||
| 53 | --- a/instrumentation/events/lttng-module/i2c.h | ||
| 54 | +++ b/instrumentation/events/lttng-module/i2c.h | ||
| 55 | @@ -23,7 +23,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(i2c_write, | ||
| 56 | |||
| 57 | TP_code_pre( | ||
| 58 | tp_locvar->extract_sensitive_payload = | ||
| 59 | - READ_ONCE(extract_sensitive_payload); | ||
| 60 | + LTTNG_READ_ONCE(extract_sensitive_payload); | ||
| 61 | ), | ||
| 62 | |||
| 63 | TP_FIELDS( | ||
| 64 | @@ -78,7 +78,7 @@ LTTNG_TRACEPOINT_EVENT_CODE(i2c_reply, | ||
| 65 | |||
| 66 | TP_code_pre( | ||
| 67 | tp_locvar->extract_sensitive_payload = | ||
| 68 | - READ_ONCE(extract_sensitive_payload); | ||
| 69 | + LTTNG_READ_ONCE(extract_sensitive_payload); | ||
| 70 | ), | ||
| 71 | |||
| 72 | TP_FIELDS( | ||
| 73 | diff --git a/lib/ringbuffer/backend.h b/lib/ringbuffer/backend.h | ||
| 74 | index da937f2..43e1d47 100644 | ||
| 75 | --- a/lib/ringbuffer/backend.h | ||
| 76 | +++ b/lib/ringbuffer/backend.h | ||
| 77 | @@ -156,7 +156,7 @@ size_t lib_ring_buffer_do_strcpy(const struct lib_ring_buffer_config *config, | ||
| 78 | * Only read source character once, in case it is | ||
| 79 | * modified concurrently. | ||
| 80 | */ | ||
| 81 | - c = READ_ONCE(src[count]); | ||
| 82 | + c = LTTNG_READ_ONCE(src[count]); | ||
| 83 | if (!c) | ||
| 84 | break; | ||
| 85 | lib_ring_buffer_do_copy(config, &dest[count], &c, 1); | ||
| 86 | diff --git a/lib/ringbuffer/backend_internal.h b/lib/ringbuffer/backend_internal.h | ||
| 87 | index 2d6a345..1226fd8 100644 | ||
| 88 | --- a/lib/ringbuffer/backend_internal.h | ||
| 89 | +++ b/lib/ringbuffer/backend_internal.h | ||
| 90 | @@ -367,7 +367,7 @@ void lib_ring_buffer_clear_noref(const struct lib_ring_buffer_config *config, | ||
| 91 | * Performing a volatile access to read the sb_pages, because we want to | ||
| 92 | * read a coherent version of the pointer and the associated noref flag. | ||
| 93 | */ | ||
| 94 | - id = READ_ONCE(bufb->buf_wsb[idx].id); | ||
| 95 | + id = LTTNG_READ_ONCE(bufb->buf_wsb[idx].id); | ||
| 96 | for (;;) { | ||
| 97 | /* This check is called on the fast path for each record. */ | ||
| 98 | if (likely(!subbuffer_id_is_noref(config, id))) { | ||
| 99 | diff --git a/lib/ringbuffer/frontend.h b/lib/ringbuffer/frontend.h | ||
| 100 | index 6f516d9..41382fe 100644 | ||
| 101 | --- a/lib/ringbuffer/frontend.h | ||
| 102 | +++ b/lib/ringbuffer/frontend.h | ||
| 103 | @@ -79,7 +79,7 @@ void *channel_destroy(struct channel *chan); | ||
| 104 | #define for_each_channel_cpu(cpu, chan) \ | ||
| 105 | for ((cpu) = -1; \ | ||
| 106 | ({ (cpu) = cpumask_next(cpu, (chan)->backend.cpumask); \ | ||
| 107 | - smp_read_barrier_depends(); (cpu) < nr_cpu_ids; });) | ||
| 108 | + smp_rmb(); (cpu) < nr_cpu_ids; });) | ||
| 109 | |||
| 110 | extern struct lib_ring_buffer *channel_get_ring_buffer( | ||
| 111 | const struct lib_ring_buffer_config *config, | ||
| 112 | @@ -155,7 +155,7 @@ static inline | ||
| 113 | int lib_ring_buffer_is_finalized(const struct lib_ring_buffer_config *config, | ||
| 114 | struct lib_ring_buffer *buf) | ||
| 115 | { | ||
| 116 | - int finalized = READ_ONCE(buf->finalized); | ||
| 117 | + int finalized = LTTNG_READ_ONCE(buf->finalized); | ||
| 118 | /* | ||
| 119 | * Read finalized before counters. | ||
| 120 | */ | ||
| 121 | diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c | ||
| 122 | index 3cab365..4980d20 100644 | ||
| 123 | --- a/lib/ringbuffer/ring_buffer_frontend.c | ||
| 124 | +++ b/lib/ringbuffer/ring_buffer_frontend.c | ||
| 125 | @@ -1074,7 +1074,7 @@ int lib_ring_buffer_snapshot(struct lib_ring_buffer *buf, | ||
| 126 | int finalized; | ||
| 127 | |||
| 128 | retry: | ||
| 129 | - finalized = READ_ONCE(buf->finalized); | ||
| 130 | + finalized = LTTNG_READ_ONCE(buf->finalized); | ||
| 131 | /* | ||
| 132 | * Read finalized before counters. | ||
| 133 | */ | ||
| 134 | @@ -1245,7 +1245,7 @@ int lib_ring_buffer_get_subbuf(struct lib_ring_buffer *buf, | ||
| 135 | return -EBUSY; | ||
| 136 | } | ||
| 137 | retry: | ||
| 138 | - finalized = READ_ONCE(buf->finalized); | ||
| 139 | + finalized = LTTNG_READ_ONCE(buf->finalized); | ||
| 140 | /* | ||
| 141 | * Read finalized before counters. | ||
| 142 | */ | ||
| 143 | diff --git a/lib/ringbuffer/ring_buffer_iterator.c b/lib/ringbuffer/ring_buffer_iterator.c | ||
| 144 | index d25db72..7b4f20a 100644 | ||
| 145 | --- a/lib/ringbuffer/ring_buffer_iterator.c | ||
| 146 | +++ b/lib/ringbuffer/ring_buffer_iterator.c | ||
| 147 | @@ -46,7 +46,7 @@ restart: | ||
| 148 | switch (iter->state) { | ||
| 149 | case ITER_GET_SUBBUF: | ||
| 150 | ret = lib_ring_buffer_get_next_subbuf(buf); | ||
| 151 | - if (ret && !READ_ONCE(buf->finalized) | ||
| 152 | + if (ret && !LTTNG_READ_ONCE(buf->finalized) | ||
| 153 | && config->alloc == RING_BUFFER_ALLOC_GLOBAL) { | ||
| 154 | /* | ||
| 155 | * Use "pull" scheme for global buffers. The reader | ||
| 156 | diff --git a/lttng-events.c b/lttng-events.c | ||
| 157 | index be7e389..d719294 100644 | ||
| 158 | --- a/lttng-events.c | ||
| 159 | +++ b/lttng-events.c | ||
| 160 | @@ -1719,7 +1719,7 @@ int lttng_metadata_printf(struct lttng_session *session, | ||
| 161 | size_t len; | ||
| 162 | va_list ap; | ||
| 163 | |||
| 164 | - WARN_ON_ONCE(!READ_ONCE(session->active)); | ||
| 165 | + WARN_ON_ONCE(!LTTNG_READ_ONCE(session->active)); | ||
| 166 | |||
| 167 | va_start(ap, fmt); | ||
| 168 | str = kvasprintf(GFP_KERNEL, fmt, ap); | ||
| 169 | @@ -2305,7 +2305,7 @@ int _lttng_event_metadata_statedump(struct lttng_session *session, | ||
| 170 | { | ||
| 171 | int ret = 0; | ||
| 172 | |||
| 173 | - if (event->metadata_dumped || !READ_ONCE(session->active)) | ||
| 174 | + if (event->metadata_dumped || !LTTNG_READ_ONCE(session->active)) | ||
| 175 | return 0; | ||
| 176 | if (chan->channel_type == METADATA_CHANNEL) | ||
| 177 | return 0; | ||
| 178 | @@ -2377,7 +2377,7 @@ int _lttng_channel_metadata_statedump(struct lttng_session *session, | ||
| 179 | { | ||
| 180 | int ret = 0; | ||
| 181 | |||
| 182 | - if (chan->metadata_dumped || !READ_ONCE(session->active)) | ||
| 183 | + if (chan->metadata_dumped || !LTTNG_READ_ONCE(session->active)) | ||
| 184 | return 0; | ||
| 185 | |||
| 186 | if (chan->channel_type == METADATA_CHANNEL) | ||
| 187 | @@ -2604,7 +2604,7 @@ int _lttng_session_metadata_statedump(struct lttng_session *session) | ||
| 188 | struct lttng_event *event; | ||
| 189 | int ret = 0; | ||
| 190 | |||
| 191 | - if (!READ_ONCE(session->active)) | ||
| 192 | + if (!LTTNG_READ_ONCE(session->active)) | ||
| 193 | return 0; | ||
| 194 | |||
| 195 | lttng_metadata_begin(session); | ||
| 196 | diff --git a/probes/lttng-kprobes.c b/probes/lttng-kprobes.c | ||
| 197 | index a44eaa1..38fb72e 100644 | ||
| 198 | --- a/probes/lttng-kprobes.c | ||
| 199 | +++ b/probes/lttng-kprobes.c | ||
| 200 | @@ -31,11 +31,11 @@ int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs) | ||
| 201 | int ret; | ||
| 202 | unsigned long data = (unsigned long) p->addr; | ||
| 203 | |||
| 204 | - if (unlikely(!READ_ONCE(chan->session->active))) | ||
| 205 | + if (unlikely(!LTTNG_READ_ONCE(chan->session->active))) | ||
| 206 | return 0; | ||
| 207 | - if (unlikely(!READ_ONCE(chan->enabled))) | ||
| 208 | + if (unlikely(!LTTNG_READ_ONCE(chan->enabled))) | ||
| 209 | return 0; | ||
| 210 | - if (unlikely(!READ_ONCE(event->enabled))) | ||
| 211 | + if (unlikely(!LTTNG_READ_ONCE(event->enabled))) | ||
| 212 | return 0; | ||
| 213 | |||
| 214 | lib_ring_buffer_ctx_init(&ctx, chan->chan, <tng_probe_ctx, sizeof(data), | ||
| 215 | diff --git a/probes/lttng-kretprobes.c b/probes/lttng-kretprobes.c | ||
| 216 | index ab98ff2..a6bcd21 100644 | ||
| 217 | --- a/probes/lttng-kretprobes.c | ||
| 218 | +++ b/probes/lttng-kretprobes.c | ||
| 219 | @@ -51,11 +51,11 @@ int _lttng_kretprobes_handler(struct kretprobe_instance *krpi, | ||
| 220 | unsigned long parent_ip; | ||
| 221 | } payload; | ||
| 222 | |||
| 223 | - if (unlikely(!READ_ONCE(chan->session->active))) | ||
| 224 | + if (unlikely(!LTTNG_READ_ONCE(chan->session->active))) | ||
| 225 | return 0; | ||
| 226 | - if (unlikely(!READ_ONCE(chan->enabled))) | ||
| 227 | + if (unlikely(!LTTNG_READ_ONCE(chan->enabled))) | ||
| 228 | return 0; | ||
| 229 | - if (unlikely(!READ_ONCE(event->enabled))) | ||
| 230 | + if (unlikely(!LTTNG_READ_ONCE(event->enabled))) | ||
| 231 | return 0; | ||
| 232 | |||
| 233 | payload.ip = (unsigned long) krpi->rp->kp.addr; | ||
| 234 | diff --git a/probes/lttng-tracepoint-event-impl.h b/probes/lttng-tracepoint-event-impl.h | ||
| 235 | index 77b8638..72a669e 100644 | ||
| 236 | --- a/probes/lttng-tracepoint-event-impl.h | ||
| 237 | +++ b/probes/lttng-tracepoint-event-impl.h | ||
| 238 | @@ -1132,11 +1132,11 @@ static void __event_probe__##_name(void *__data, _proto) \ | ||
| 239 | \ | ||
| 240 | if (!_TP_SESSION_CHECK(session, __session)) \ | ||
| 241 | return; \ | ||
| 242 | - if (unlikely(!READ_ONCE(__session->active))) \ | ||
| 243 | + if (unlikely(!LTTNG_READ_ONCE(__session->active))) \ | ||
| 244 | return; \ | ||
| 245 | - if (unlikely(!READ_ONCE(__chan->enabled))) \ | ||
| 246 | + if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \ | ||
| 247 | return; \ | ||
| 248 | - if (unlikely(!READ_ONCE(__event->enabled))) \ | ||
| 249 | + if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \ | ||
| 250 | return; \ | ||
| 251 | __lf = lttng_rcu_dereference(__session->pid_tracker.p); \ | ||
| 252 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \ | ||
| 253 | @@ -1225,11 +1225,11 @@ static void __event_probe__##_name(void *__data) \ | ||
| 254 | \ | ||
| 255 | if (!_TP_SESSION_CHECK(session, __session)) \ | ||
| 256 | return; \ | ||
| 257 | - if (unlikely(!READ_ONCE(__session->active))) \ | ||
| 258 | + if (unlikely(!LTTNG_READ_ONCE(__session->active))) \ | ||
| 259 | return; \ | ||
| 260 | - if (unlikely(!READ_ONCE(__chan->enabled))) \ | ||
| 261 | + if (unlikely(!LTTNG_READ_ONCE(__chan->enabled))) \ | ||
| 262 | return; \ | ||
| 263 | - if (unlikely(!READ_ONCE(__event->enabled))) \ | ||
| 264 | + if (unlikely(!LTTNG_READ_ONCE(__event->enabled))) \ | ||
| 265 | return; \ | ||
| 266 | __lf = lttng_rcu_dereference(__session->pid_tracker.p); \ | ||
| 267 | if (__lf && likely(!lttng_id_tracker_lookup(__lf, current->tgid))) \ | ||
| 268 | diff --git a/probes/lttng-uprobes.c b/probes/lttng-uprobes.c | ||
| 269 | index bc10128..bda1d9b 100644 | ||
| 270 | --- a/probes/lttng-uprobes.c | ||
| 271 | +++ b/probes/lttng-uprobes.c | ||
| 272 | @@ -40,11 +40,11 @@ int lttng_uprobes_handler_pre(struct uprobe_consumer *uc, struct pt_regs *regs) | ||
| 273 | unsigned long ip; | ||
| 274 | } payload; | ||
| 275 | |||
| 276 | - if (unlikely(!READ_ONCE(chan->session->active))) | ||
| 277 | + if (unlikely(!LTTNG_READ_ONCE(chan->session->active))) | ||
| 278 | return 0; | ||
| 279 | - if (unlikely(!READ_ONCE(chan->enabled))) | ||
| 280 | + if (unlikely(!LTTNG_READ_ONCE(chan->enabled))) | ||
| 281 | return 0; | ||
| 282 | - if (unlikely(!READ_ONCE(event->enabled))) | ||
| 283 | + if (unlikely(!LTTNG_READ_ONCE(event->enabled))) | ||
| 284 | return 0; | ||
| 285 | |||
| 286 | lib_ring_buffer_ctx_init(&ctx, chan->chan, <tng_probe_ctx, | ||
| 287 | diff --git a/wrapper/compiler.h b/wrapper/compiler.h | ||
| 288 | index 1496f33..b9f8c51 100644 | ||
| 289 | --- a/wrapper/compiler.h | ||
| 290 | +++ b/wrapper/compiler.h | ||
| 291 | @@ -9,6 +9,7 @@ | ||
| 292 | #define _LTTNG_WRAPPER_COMPILER_H | ||
| 293 | |||
| 294 | #include <linux/compiler.h> | ||
| 295 | +#include <linux/version.h> | ||
| 296 | |||
| 297 | /* | ||
| 298 | * Don't allow compiling with buggy compiler. | ||
| 299 | @@ -39,4 +40,21 @@ | ||
| 300 | # define WRITE_ONCE(x, val) ({ ACCESS_ONCE(x) = val; }) | ||
| 301 | #endif | ||
| 302 | |||
| 303 | +/* | ||
| 304 | + * In v4.15 a smp read barrier was added to READ_ONCE to replace | ||
| 305 | + * lockless_dereference(), replicate this behavior on prior kernels | ||
| 306 | + * and remove calls to smp_read_barrier_depends which was dropped | ||
| 307 | + * in v5.9. | ||
| 308 | + */ | ||
| 309 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,15,0)) | ||
| 310 | +#define LTTNG_READ_ONCE(x) READ_ONCE(x) | ||
| 311 | +#else | ||
| 312 | +#define LTTNG_READ_ONCE(x) \ | ||
| 313 | +({ \ | ||
| 314 | + typeof(x) __val = READ_ONCE(x); \ | ||
| 315 | + smp_read_barrier_depends(); \ | ||
| 316 | + __val; \ | ||
| 317 | +}) | ||
| 318 | +#endif | ||
| 319 | + | ||
| 320 | #endif /* _LTTNG_WRAPPER_COMPILER_H */ | ||
| 321 | diff --git a/wrapper/trace-clock.h b/wrapper/trace-clock.h | ||
| 322 | index 9f4e366..187fc82 100644 | ||
| 323 | --- a/wrapper/trace-clock.h | ||
| 324 | +++ b/wrapper/trace-clock.h | ||
| 325 | @@ -160,33 +160,30 @@ static inline void put_trace_clock(void) | ||
| 326 | |||
| 327 | static inline u64 trace_clock_read64(void) | ||
| 328 | { | ||
| 329 | - struct lttng_trace_clock *ltc = READ_ONCE(lttng_trace_clock); | ||
| 330 | + struct lttng_trace_clock *ltc = LTTNG_READ_ONCE(lttng_trace_clock); | ||
| 331 | |||
| 332 | if (likely(!ltc)) { | ||
| 333 | return trace_clock_read64_monotonic(); | ||
| 334 | } else { | ||
| 335 | - read_barrier_depends(); /* load ltc before content */ | ||
| 336 | return ltc->read64(); | ||
| 337 | } | ||
| 338 | } | ||
| 339 | |||
| 340 | static inline u64 trace_clock_freq(void) | ||
| 341 | { | ||
| 342 | - struct lttng_trace_clock *ltc = READ_ONCE(lttng_trace_clock); | ||
| 343 | + struct lttng_trace_clock *ltc = LTTNG_READ_ONCE(lttng_trace_clock); | ||
| 344 | |||
| 345 | if (!ltc) { | ||
| 346 | return trace_clock_freq_monotonic(); | ||
| 347 | } else { | ||
| 348 | - read_barrier_depends(); /* load ltc before content */ | ||
| 349 | return ltc->freq(); | ||
| 350 | } | ||
| 351 | } | ||
| 352 | |||
| 353 | static inline int trace_clock_uuid(char *uuid) | ||
| 354 | { | ||
| 355 | - struct lttng_trace_clock *ltc = READ_ONCE(lttng_trace_clock); | ||
| 356 | + struct lttng_trace_clock *ltc = LTTNG_READ_ONCE(lttng_trace_clock); | ||
| 357 | |||
| 358 | - read_barrier_depends(); /* load ltc before content */ | ||
| 359 | /* Use default UUID cb when NULL */ | ||
| 360 | if (!ltc || !ltc->uuid) { | ||
| 361 | return trace_clock_uuid_monotonic(uuid); | ||
| 362 | @@ -197,24 +194,22 @@ static inline int trace_clock_uuid(char *uuid) | ||
| 363 | |||
| 364 | static inline const char *trace_clock_name(void) | ||
| 365 | { | ||
| 366 | - struct lttng_trace_clock *ltc = READ_ONCE(lttng_trace_clock); | ||
| 367 | + struct lttng_trace_clock *ltc = LTTNG_READ_ONCE(lttng_trace_clock); | ||
| 368 | |||
| 369 | if (!ltc) { | ||
| 370 | return trace_clock_name_monotonic(); | ||
| 371 | } else { | ||
| 372 | - read_barrier_depends(); /* load ltc before content */ | ||
| 373 | return ltc->name(); | ||
| 374 | } | ||
| 375 | } | ||
| 376 | |||
| 377 | static inline const char *trace_clock_description(void) | ||
| 378 | { | ||
| 379 | - struct lttng_trace_clock *ltc = READ_ONCE(lttng_trace_clock); | ||
| 380 | + struct lttng_trace_clock *ltc = LTTNG_READ_ONCE(lttng_trace_clock); | ||
| 381 | |||
| 382 | if (!ltc) { | ||
| 383 | return trace_clock_description_monotonic(); | ||
| 384 | } else { | ||
| 385 | - read_barrier_depends(); /* load ltc before content */ | ||
| 386 | return ltc->description(); | ||
| 387 | } | ||
| 388 | } | ||
| 389 | -- | ||
| 390 | 2.19.1 | ||
| 391 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0007-fix-writeback-Drop-I_DIRTY_TIME_EXPIRE-v5.9.patch b/meta/recipes-kernel/lttng/lttng-modules/0007-fix-writeback-Drop-I_DIRTY_TIME_EXPIRE-v5.9.patch deleted file mode 100644 index 2843c9cb62..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0007-fix-writeback-Drop-I_DIRTY_TIME_EXPIRE-v5.9.patch +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | From eae02feb58064eee5ce15a9f6bdffd107c47da05 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 31 Aug 2020 11:41:38 -0400 | ||
| 4 | Subject: [PATCH 07/10] fix: writeback: Drop I_DIRTY_TIME_EXPIRE (v5.9) | ||
| 5 | |||
| 6 | See upstream commit: | ||
| 7 | |||
| 8 | commit 5fcd57505c002efc5823a7355e21f48dd02d5a51 | ||
| 9 | Author: Jan Kara <jack@suse.cz> | ||
| 10 | Date: Fri May 29 16:24:43 2020 +0200 | ||
| 11 | |||
| 12 | writeback: Drop I_DIRTY_TIME_EXPIRE | ||
| 13 | |||
| 14 | The only use of I_DIRTY_TIME_EXPIRE is to detect in | ||
| 15 | __writeback_single_inode() that inode got there because flush worker | ||
| 16 | decided it's time to writeback the dirty inode time stamps (either | ||
| 17 | because we are syncing or because of age). However we can detect this | ||
| 18 | directly in __writeback_single_inode() and there's no need for the | ||
| 19 | strange propagation with I_DIRTY_TIME_EXPIRE flag. | ||
| 20 | |||
| 21 | Upstream-Status: Backport | ||
| 22 | |||
| 23 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 24 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 25 | Change-Id: I92e37c2ff3ec36d431e8f9de5c8e37c5a2da55ea | ||
| 26 | --- | ||
| 27 | instrumentation/events/lttng-module/writeback.h | 16 +++++++++++++++- | ||
| 28 | 1 file changed, 15 insertions(+), 1 deletion(-) | ||
| 29 | |||
| 30 | diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h | ||
| 31 | index affb4eb..ece67ad 100644 | ||
| 32 | --- a/instrumentation/events/lttng-module/writeback.h | ||
| 33 | +++ b/instrumentation/events/lttng-module/writeback.h | ||
| 34 | @@ -46,7 +46,21 @@ static inline struct backing_dev_info *lttng_inode_to_bdi(struct inode *inode) | ||
| 35 | |||
| 36 | #endif | ||
| 37 | |||
| 38 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) | ||
| 39 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 40 | +#define show_inode_state(state) \ | ||
| 41 | + __print_flags(state, "|", \ | ||
| 42 | + {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ | ||
| 43 | + {I_DIRTY_DATASYNC, "I_DIRTY_DATASYNC"}, \ | ||
| 44 | + {I_DIRTY_PAGES, "I_DIRTY_PAGES"}, \ | ||
| 45 | + {I_NEW, "I_NEW"}, \ | ||
| 46 | + {I_WILL_FREE, "I_WILL_FREE"}, \ | ||
| 47 | + {I_FREEING, "I_FREEING"}, \ | ||
| 48 | + {I_CLEAR, "I_CLEAR"}, \ | ||
| 49 | + {I_SYNC, "I_SYNC"}, \ | ||
| 50 | + {I_DIRTY_TIME, "I_DIRTY_TIME"}, \ | ||
| 51 | + {I_REFERENCED, "I_REFERENCED"} \ | ||
| 52 | + ) | ||
| 53 | +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,0,0)) | ||
| 54 | #define show_inode_state(state) \ | ||
| 55 | __print_flags(state, "|", \ | ||
| 56 | {I_DIRTY_SYNC, "I_DIRTY_SYNC"}, \ | ||
| 57 | -- | ||
| 58 | 2.19.1 | ||
| 59 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0008-fix-writeback-Fix-sync-livelock-due-to-b_dirty_time-.patch b/meta/recipes-kernel/lttng/lttng-modules/0008-fix-writeback-Fix-sync-livelock-due-to-b_dirty_time-.patch deleted file mode 100644 index 7a0d9a38b8..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0008-fix-writeback-Fix-sync-livelock-due-to-b_dirty_time-.patch +++ /dev/null | |||
| @@ -1,117 +0,0 @@ | |||
| 1 | From 87b2affc3eb06f3fb2d0923f18af37713eb6814b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Mon, 31 Aug 2020 14:16:01 -0400 | ||
| 4 | Subject: [PATCH 08/10] fix: writeback: Fix sync livelock due to b_dirty_time | ||
| 5 | processing (v5.9) | ||
| 6 | |||
| 7 | See upstream commit: | ||
| 8 | |||
| 9 | commit f9cae926f35e8230330f28c7b743ad088611a8de | ||
| 10 | Author: Jan Kara <jack@suse.cz> | ||
| 11 | Date: Fri May 29 16:08:58 2020 +0200 | ||
| 12 | |||
| 13 | writeback: Fix sync livelock due to b_dirty_time processing | ||
| 14 | |||
| 15 | When we are processing writeback for sync(2), move_expired_inodes() | ||
| 16 | didn't set any inode expiry value (older_than_this). This can result in | ||
| 17 | writeback never completing if there's steady stream of inodes added to | ||
| 18 | b_dirty_time list as writeback rechecks dirty lists after each writeback | ||
| 19 | round whether there's more work to be done. Fix the problem by using | ||
| 20 | sync(2) start time is inode expiry value when processing b_dirty_time | ||
| 21 | list similarly as for ordinarily dirtied inodes. This requires some | ||
| 22 | refactoring of older_than_this handling which simplifies the code | ||
| 23 | noticeably as a bonus. | ||
| 24 | |||
| 25 | Upstream-Status: Backport | ||
| 26 | |||
| 27 | Change-Id: I8b894b13ccc14d9b8983ee4c2810a927c319560b | ||
| 28 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 29 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 30 | --- | ||
| 31 | .../events/lttng-module/writeback.h | 39 ++++++++++++------- | ||
| 32 | 1 file changed, 26 insertions(+), 13 deletions(-) | ||
| 33 | |||
| 34 | diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h | ||
| 35 | index ece67ad..e9018dd 100644 | ||
| 36 | --- a/instrumentation/events/lttng-module/writeback.h | ||
| 37 | +++ b/instrumentation/events/lttng-module/writeback.h | ||
| 38 | @@ -384,34 +384,48 @@ LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balanc | ||
| 39 | #endif | ||
| 40 | LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage) | ||
| 41 | |||
| 42 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) | ||
| 43 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 44 | +LTTNG_TRACEPOINT_EVENT(writeback_queue_io, | ||
| 45 | + TP_PROTO(struct bdi_writeback *wb, | ||
| 46 | + struct wb_writeback_work *work, | ||
| 47 | + unsigned long dirtied_before, | ||
| 48 | + int moved), | ||
| 49 | + TP_ARGS(wb, work, dirtied_before, moved), | ||
| 50 | + TP_FIELDS( | ||
| 51 | + ctf_array_text(char, name, dev_name(wb->bdi->dev), 32) | ||
| 52 | + ctf_integer(unsigned long, older, dirtied_before) | ||
| 53 | + ctf_integer(int, moved, moved) | ||
| 54 | + ) | ||
| 55 | +) | ||
| 56 | +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | ||
| 57 | LTTNG_TRACEPOINT_EVENT(writeback_queue_io, | ||
| 58 | TP_PROTO(struct bdi_writeback *wb, | ||
| 59 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | ||
| 60 | struct wb_writeback_work *work, | ||
| 61 | -#else | ||
| 62 | - unsigned long *older_than_this, | ||
| 63 | -#endif | ||
| 64 | int moved), | ||
| 65 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | ||
| 66 | TP_ARGS(wb, work, moved), | ||
| 67 | -#else | ||
| 68 | + TP_FIELDS( | ||
| 69 | + ctf_array_text(char, name, dev_name(wb->bdi->dev), 32) | ||
| 70 | + ctf_integer(int, moved, moved) | ||
| 71 | + ) | ||
| 72 | +) | ||
| 73 | +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) | ||
| 74 | +LTTNG_TRACEPOINT_EVENT(writeback_queue_io, | ||
| 75 | + TP_PROTO(struct bdi_writeback *wb, | ||
| 76 | + unsigned long *older_than_this, | ||
| 77 | + int moved), | ||
| 78 | TP_ARGS(wb, older_than_this, moved), | ||
| 79 | -#endif | ||
| 80 | TP_FIELDS( | ||
| 81 | ctf_array_text(char, name, dev_name(wb->bdi->dev), 32) | ||
| 82 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | ||
| 83 | -#else | ||
| 84 | ctf_integer(unsigned long, older, | ||
| 85 | older_than_this ? *older_than_this : 0) | ||
| 86 | ctf_integer(long, age, | ||
| 87 | older_than_this ? | ||
| 88 | (jiffies - *older_than_this) * 1000 / HZ | ||
| 89 | : -1) | ||
| 90 | -#endif | ||
| 91 | ctf_integer(int, moved, moved) | ||
| 92 | ) | ||
| 93 | ) | ||
| 94 | +#endif | ||
| 95 | |||
| 96 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) | ||
| 97 | LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, | ||
| 98 | @@ -460,7 +474,7 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, | ||
| 99 | ctf_integer(unsigned long, dirty_limit, global_dirty_limit) | ||
| 100 | ) | ||
| 101 | ) | ||
| 102 | -#else | ||
| 103 | +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,1,0)) | ||
| 104 | LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, | ||
| 105 | |||
| 106 | writeback_global_dirty_state, | ||
| 107 | @@ -485,7 +499,6 @@ LTTNG_TRACEPOINT_EVENT_MAP(global_dirty_state, | ||
| 108 | ) | ||
| 109 | ) | ||
| 110 | #endif | ||
| 111 | -#endif | ||
| 112 | |||
| 113 | #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) | ||
| 114 | |||
| 115 | -- | ||
| 116 | 2.19.1 | ||
| 117 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0009-fix-version-ranges-for-ext4_discard_preallocations-a.patch b/meta/recipes-kernel/lttng/lttng-modules/0009-fix-version-ranges-for-ext4_discard_preallocations-a.patch deleted file mode 100644 index 346e1d63ad..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0009-fix-version-ranges-for-ext4_discard_preallocations-a.patch +++ /dev/null | |||
| @@ -1,52 +0,0 @@ | |||
| 1 | From b74b25f349e92d7b5bdc8684e406d6a889f13773 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Michael Jeanson <mjeanson@efficios.com> | ||
| 3 | Date: Fri, 4 Sep 2020 11:52:51 -0400 | ||
| 4 | Subject: [PATCH 09/10] fix: version ranges for ext4_discard_preallocations and | ||
| 5 | writeback_queue_io | ||
| 6 | |||
| 7 | Upstream-Status: Backport | ||
| 8 | |||
| 9 | Signed-off-by: Michael Jeanson <mjeanson@efficios.com> | ||
| 10 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 11 | Change-Id: Id4fa53cb2e713cbda651e1a75deed91013115592 | ||
| 12 | --- | ||
| 13 | instrumentation/events/lttng-module/ext4.h | 3 ++- | ||
| 14 | instrumentation/events/lttng-module/writeback.h | 8 +++++++- | ||
| 15 | 2 files changed, 9 insertions(+), 2 deletions(-) | ||
| 16 | |||
| 17 | diff --git a/instrumentation/events/lttng-module/ext4.h b/instrumentation/events/lttng-module/ext4.h | ||
| 18 | index 4476abb..b172c8d 100644 | ||
| 19 | --- a/instrumentation/events/lttng-module/ext4.h | ||
| 20 | +++ b/instrumentation/events/lttng-module/ext4.h | ||
| 21 | @@ -460,7 +460,8 @@ LTTNG_TRACEPOINT_EVENT(ext4_mb_release_group_pa, | ||
| 22 | ) | ||
| 23 | #endif | ||
| 24 | |||
| 25 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 26 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) || \ | ||
| 27 | + LTTNG_KERNEL_RANGE(5,8,6, 5,9,0)) | ||
| 28 | LTTNG_TRACEPOINT_EVENT(ext4_discard_preallocations, | ||
| 29 | TP_PROTO(struct inode *inode, unsigned int len, unsigned int needed), | ||
| 30 | |||
| 31 | diff --git a/instrumentation/events/lttng-module/writeback.h b/instrumentation/events/lttng-module/writeback.h | ||
| 32 | index e9018dd..09637d7 100644 | ||
| 33 | --- a/instrumentation/events/lttng-module/writeback.h | ||
| 34 | +++ b/instrumentation/events/lttng-module/writeback.h | ||
| 35 | @@ -384,7 +384,13 @@ LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_balance_dirty_wait, writeback_wbc_balanc | ||
| 36 | #endif | ||
| 37 | LTTNG_TRACEPOINT_EVENT_WBC_INSTANCE(wbc_writepage, writeback_wbc_writepage) | ||
| 38 | |||
| 39 | -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0)) | ||
| 40 | +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,9,0) || \ | ||
| 41 | + LTTNG_KERNEL_RANGE(5,8,6, 5,9,0) || \ | ||
| 42 | + LTTNG_KERNEL_RANGE(5,4,62, 5,5,0) || \ | ||
| 43 | + LTTNG_KERNEL_RANGE(4,19,143, 4,20,0) || \ | ||
| 44 | + LTTNG_KERNEL_RANGE(4,14,196, 4,15,0) || \ | ||
| 45 | + LTTNG_KERNEL_RANGE(4,9,235, 4,10,0) || \ | ||
| 46 | + LTTNG_KERNEL_RANGE(4,4,235, 4,5,0)) | ||
| 47 | LTTNG_TRACEPOINT_EVENT(writeback_queue_io, | ||
| 48 | TP_PROTO(struct bdi_writeback *wb, | ||
| 49 | struct wb_writeback_work *work, | ||
| 50 | -- | ||
| 51 | 2.19.1 | ||
| 52 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules/0010-Fix-system-call-filter-table.patch b/meta/recipes-kernel/lttng/lttng-modules/0010-Fix-system-call-filter-table.patch deleted file mode 100644 index a16750ddb3..0000000000 --- a/meta/recipes-kernel/lttng/lttng-modules/0010-Fix-system-call-filter-table.patch +++ /dev/null | |||
| @@ -1,918 +0,0 @@ | |||
| 1 | From ad594e3a953db1b0c3c059fde45b5a5494f6be78 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 3 | Date: Tue, 28 Jan 2020 16:02:44 -0500 | ||
| 4 | Subject: [PATCH 10/10] Fix: system call filter table | ||
| 5 | |||
| 6 | The system call filter table has effectively been unused for a long | ||
| 7 | time due to system call name prefix mismatch. This means the overhead of | ||
| 8 | selective system call tracing was larger than it should have been because | ||
| 9 | the event payload preparation would be done for all system calls as soon | ||
| 10 | as a single system call is traced. | ||
| 11 | |||
| 12 | However, fixing this underlying issue unearths several issues that crept | ||
| 13 | unnoticed when the "enabler" concept was introduced (after the original | ||
| 14 | implementation of the system call filter table). | ||
| 15 | |||
| 16 | Here is a list of the issues which are resolved here: | ||
| 17 | |||
| 18 | - Split lttng_syscalls_unregister into an unregister and destroy | ||
| 19 | function, thus awaiting for a grace period (and therefore quiescence | ||
| 20 | of the users) after unregistering the system call tracepoints before | ||
| 21 | freeing the system call filter data structures. This effectively fixes | ||
| 22 | a use-after-free. | ||
| 23 | |||
| 24 | - The state for enabling "all" system calls vs enabling specific system | ||
| 25 | calls (and sequences of enable-disable) was incorrect with respect to | ||
| 26 | the "enablers" semantic. This is solved by always tracking the | ||
| 27 | bitmap of enabled system calls, and keeping this bitmap even when | ||
| 28 | enabling all system calls. The sc_filter is now always allocated | ||
| 29 | before system call tracing is registered to tracepoints, which means | ||
| 30 | it does not need to be RCU dereferenced anymore. | ||
| 31 | |||
| 32 | Padding fields in the ABI are reserved to select whether to: | ||
| 33 | |||
| 34 | - Trace either native or compat system call (or both, which is the | ||
| 35 | behavior currently implemented), | ||
| 36 | - Trace either system call entry or exit (or both, which is the | ||
| 37 | behavior currently implemented), | ||
| 38 | - Select the system call to trace by name (behavior currently | ||
| 39 | implemented) or by system call number, | ||
| 40 | |||
| 41 | Upstream-Status: Backport | ||
| 42 | |||
| 43 | Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> | ||
| 44 | --- | ||
| 45 | lttng-abi.c | 43 ++++++ | ||
| 46 | lttng-abi.h | 26 ++++ | ||
| 47 | lttng-events.c | 112 +++++++++++++-- | ||
| 48 | lttng-events.h | 31 ++++- | ||
| 49 | lttng-syscalls.c | 348 +++++++++++++++++++++++++---------------------- | ||
| 50 | 5 files changed, 380 insertions(+), 180 deletions(-) | ||
| 51 | |||
| 52 | diff --git a/lttng-abi.c b/lttng-abi.c | ||
| 53 | index 64ea99d..b33879d 100644 | ||
| 54 | --- a/lttng-abi.c | ||
| 55 | +++ b/lttng-abi.c | ||
| 56 | @@ -1264,6 +1264,46 @@ nomem: | ||
| 57 | return ret; | ||
| 58 | } | ||
| 59 | |||
| 60 | +static | ||
| 61 | +int lttng_abi_validate_event_param(struct lttng_kernel_event *event_param) | ||
| 62 | +{ | ||
| 63 | + /* Limit ABI to implemented features. */ | ||
| 64 | + switch (event_param->instrumentation) { | ||
| 65 | + case LTTNG_KERNEL_SYSCALL: | ||
| 66 | + switch (event_param->u.syscall.entryexit) { | ||
| 67 | + case LTTNG_KERNEL_SYSCALL_ENTRYEXIT: | ||
| 68 | + break; | ||
| 69 | + default: | ||
| 70 | + return -EINVAL; | ||
| 71 | + } | ||
| 72 | + switch (event_param->u.syscall.abi) { | ||
| 73 | + case LTTNG_KERNEL_SYSCALL_ABI_ALL: | ||
| 74 | + break; | ||
| 75 | + default: | ||
| 76 | + return -EINVAL; | ||
| 77 | + } | ||
| 78 | + switch (event_param->u.syscall.match) { | ||
| 79 | + case LTTNG_SYSCALL_MATCH_NAME: | ||
| 80 | + break; | ||
| 81 | + default: | ||
| 82 | + return -EINVAL; | ||
| 83 | + } | ||
| 84 | + break; | ||
| 85 | + | ||
| 86 | + case LTTNG_KERNEL_TRACEPOINT: /* Fallthrough */ | ||
| 87 | + case LTTNG_KERNEL_KPROBE: /* Fallthrough */ | ||
| 88 | + case LTTNG_KERNEL_KRETPROBE: /* Fallthrough */ | ||
| 89 | + case LTTNG_KERNEL_NOOP: /* Fallthrough */ | ||
| 90 | + case LTTNG_KERNEL_UPROBE: | ||
| 91 | + break; | ||
| 92 | + | ||
| 93 | + case LTTNG_KERNEL_FUNCTION: /* Fallthrough */ | ||
| 94 | + default: | ||
| 95 | + return -EINVAL; | ||
| 96 | + } | ||
| 97 | + return 0; | ||
| 98 | +} | ||
| 99 | + | ||
| 100 | static | ||
| 101 | int lttng_abi_create_event(struct file *channel_file, | ||
| 102 | struct lttng_kernel_event *event_param) | ||
| 103 | @@ -1305,6 +1345,9 @@ int lttng_abi_create_event(struct file *channel_file, | ||
| 104 | ret = -EOVERFLOW; | ||
| 105 | goto refcount_error; | ||
| 106 | } | ||
| 107 | + ret = lttng_abi_validate_event_param(event_param); | ||
| 108 | + if (ret) | ||
| 109 | + goto event_error; | ||
| 110 | if (event_param->instrumentation == LTTNG_KERNEL_TRACEPOINT | ||
| 111 | || event_param->instrumentation == LTTNG_KERNEL_SYSCALL) { | ||
| 112 | struct lttng_enabler *enabler; | ||
| 113 | diff --git a/lttng-abi.h b/lttng-abi.h | ||
| 114 | index 1d356ab..51d60e5 100644 | ||
| 115 | --- a/lttng-abi.h | ||
| 116 | +++ b/lttng-abi.h | ||
| 117 | @@ -90,6 +90,31 @@ struct lttng_kernel_event_callsite { | ||
| 118 | } u; | ||
| 119 | } __attribute__((packed)); | ||
| 120 | |||
| 121 | +enum lttng_kernel_syscall_entryexit { | ||
| 122 | + LTTNG_KERNEL_SYSCALL_ENTRYEXIT = 0, | ||
| 123 | + LTTNG_KERNEL_SYSCALL_ENTRY = 1, /* Not implemented. */ | ||
| 124 | + LTTNG_KERNEL_SYSCALL_EXIT = 2, /* Not implemented. */ | ||
| 125 | +}; | ||
| 126 | + | ||
| 127 | +enum lttng_kernel_syscall_abi { | ||
| 128 | + LTTNG_KERNEL_SYSCALL_ABI_ALL = 0, | ||
| 129 | + LTTNG_KERNEL_SYSCALL_ABI_NATIVE = 1, /* Not implemented. */ | ||
| 130 | + LTTNG_KERNEL_SYSCALL_ABI_COMPAT = 2, /* Not implemented. */ | ||
| 131 | +}; | ||
| 132 | + | ||
| 133 | +enum lttng_kernel_syscall_match { | ||
| 134 | + LTTNG_SYSCALL_MATCH_NAME = 0, | ||
| 135 | + LTTNG_SYSCALL_MATCH_NR = 1, /* Not implemented. */ | ||
| 136 | +}; | ||
| 137 | + | ||
| 138 | +struct lttng_kernel_syscall { | ||
| 139 | + uint8_t entryexit; /* enum lttng_kernel_syscall_entryexit */ | ||
| 140 | + uint8_t abi; /* enum lttng_kernel_syscall_abi */ | ||
| 141 | + uint8_t match; /* enum lttng_kernel_syscall_match */ | ||
| 142 | + uint8_t padding; | ||
| 143 | + uint32_t nr; /* For LTTNG_SYSCALL_MATCH_NR */ | ||
| 144 | +} __attribute__((packed)); | ||
| 145 | + | ||
| 146 | /* | ||
| 147 | * For syscall tracing, name = "*" means "enable all". | ||
| 148 | */ | ||
| 149 | @@ -106,6 +131,7 @@ struct lttng_kernel_event { | ||
| 150 | struct lttng_kernel_kprobe kprobe; | ||
| 151 | struct lttng_kernel_function_tracer ftrace; | ||
| 152 | struct lttng_kernel_uprobe uprobe; | ||
| 153 | + struct lttng_kernel_syscall syscall; | ||
| 154 | char padding[LTTNG_KERNEL_EVENT_PADDING2]; | ||
| 155 | } u; | ||
| 156 | } __attribute__((packed)); | ||
| 157 | diff --git a/lttng-events.c b/lttng-events.c | ||
| 158 | index d719294..4c0b04a 100644 | ||
| 159 | --- a/lttng-events.c | ||
| 160 | +++ b/lttng-events.c | ||
| 161 | @@ -201,6 +201,10 @@ void lttng_session_destroy(struct lttng_session *session) | ||
| 162 | WARN_ON(ret); | ||
| 163 | } | ||
| 164 | synchronize_trace(); /* Wait for in-flight events to complete */ | ||
| 165 | + list_for_each_entry(chan, &session->chan, list) { | ||
| 166 | + ret = lttng_syscalls_destroy(chan); | ||
| 167 | + WARN_ON(ret); | ||
| 168 | + } | ||
| 169 | list_for_each_entry_safe(enabler, tmpenabler, | ||
| 170 | &session->enablers_head, node) | ||
| 171 | lttng_enabler_destroy(enabler); | ||
| 172 | @@ -740,6 +744,28 @@ struct lttng_event *_lttng_event_create(struct lttng_channel *chan, | ||
| 173 | event->enabled = 0; | ||
| 174 | event->registered = 0; | ||
| 175 | event->desc = event_desc; | ||
| 176 | + switch (event_param->u.syscall.entryexit) { | ||
| 177 | + case LTTNG_KERNEL_SYSCALL_ENTRYEXIT: | ||
| 178 | + ret = -EINVAL; | ||
| 179 | + goto register_error; | ||
| 180 | + case LTTNG_KERNEL_SYSCALL_ENTRY: | ||
| 181 | + event->u.syscall.entryexit = LTTNG_SYSCALL_ENTRY; | ||
| 182 | + break; | ||
| 183 | + case LTTNG_KERNEL_SYSCALL_EXIT: | ||
| 184 | + event->u.syscall.entryexit = LTTNG_SYSCALL_EXIT; | ||
| 185 | + break; | ||
| 186 | + } | ||
| 187 | + switch (event_param->u.syscall.abi) { | ||
| 188 | + case LTTNG_KERNEL_SYSCALL_ABI_ALL: | ||
| 189 | + ret = -EINVAL; | ||
| 190 | + goto register_error; | ||
| 191 | + case LTTNG_KERNEL_SYSCALL_ABI_NATIVE: | ||
| 192 | + event->u.syscall.abi = LTTNG_SYSCALL_ABI_NATIVE; | ||
| 193 | + break; | ||
| 194 | + case LTTNG_KERNEL_SYSCALL_ABI_COMPAT: | ||
| 195 | + event->u.syscall.abi = LTTNG_SYSCALL_ABI_COMPAT; | ||
| 196 | + break; | ||
| 197 | + } | ||
| 198 | if (!event->desc) { | ||
| 199 | ret = -EINVAL; | ||
| 200 | goto register_error; | ||
| 201 | @@ -826,8 +852,7 @@ void register_event(struct lttng_event *event) | ||
| 202 | event); | ||
| 203 | break; | ||
| 204 | case LTTNG_KERNEL_SYSCALL: | ||
| 205 | - ret = lttng_syscall_filter_enable(event->chan, | ||
| 206 | - desc->name); | ||
| 207 | + ret = lttng_syscall_filter_enable(event->chan, event); | ||
| 208 | break; | ||
| 209 | case LTTNG_KERNEL_KPROBE: | ||
| 210 | case LTTNG_KERNEL_UPROBE: | ||
| 211 | @@ -870,8 +895,7 @@ int _lttng_event_unregister(struct lttng_event *event) | ||
| 212 | ret = 0; | ||
| 213 | break; | ||
| 214 | case LTTNG_KERNEL_SYSCALL: | ||
| 215 | - ret = lttng_syscall_filter_disable(event->chan, | ||
| 216 | - desc->name); | ||
| 217 | + ret = lttng_syscall_filter_disable(event->chan, event); | ||
| 218 | break; | ||
| 219 | case LTTNG_KERNEL_NOOP: | ||
| 220 | ret = 0; | ||
| 221 | @@ -1203,39 +1227,87 @@ int lttng_desc_match_enabler(const struct lttng_event_desc *desc, | ||
| 222 | struct lttng_enabler *enabler) | ||
| 223 | { | ||
| 224 | const char *desc_name, *enabler_name; | ||
| 225 | + bool compat = false, entry = false; | ||
| 226 | |||
| 227 | enabler_name = enabler->event_param.name; | ||
| 228 | switch (enabler->event_param.instrumentation) { | ||
| 229 | case LTTNG_KERNEL_TRACEPOINT: | ||
| 230 | desc_name = desc->name; | ||
| 231 | + switch (enabler->type) { | ||
| 232 | + case LTTNG_ENABLER_STAR_GLOB: | ||
| 233 | + return lttng_match_enabler_star_glob(desc_name, enabler_name); | ||
| 234 | + case LTTNG_ENABLER_NAME: | ||
| 235 | + return lttng_match_enabler_name(desc_name, enabler_name); | ||
| 236 | + default: | ||
| 237 | + return -EINVAL; | ||
| 238 | + } | ||
| 239 | break; | ||
| 240 | case LTTNG_KERNEL_SYSCALL: | ||
| 241 | desc_name = desc->name; | ||
| 242 | - if (!strncmp(desc_name, "compat_", strlen("compat_"))) | ||
| 243 | + if (!strncmp(desc_name, "compat_", strlen("compat_"))) { | ||
| 244 | desc_name += strlen("compat_"); | ||
| 245 | + compat = true; | ||
| 246 | + } | ||
| 247 | if (!strncmp(desc_name, "syscall_exit_", | ||
| 248 | strlen("syscall_exit_"))) { | ||
| 249 | desc_name += strlen("syscall_exit_"); | ||
| 250 | } else if (!strncmp(desc_name, "syscall_entry_", | ||
| 251 | strlen("syscall_entry_"))) { | ||
| 252 | desc_name += strlen("syscall_entry_"); | ||
| 253 | + entry = true; | ||
| 254 | } else { | ||
| 255 | WARN_ON_ONCE(1); | ||
| 256 | return -EINVAL; | ||
| 257 | } | ||
| 258 | + switch (enabler->event_param.u.syscall.entryexit) { | ||
| 259 | + case LTTNG_KERNEL_SYSCALL_ENTRYEXIT: | ||
| 260 | + break; | ||
| 261 | + case LTTNG_KERNEL_SYSCALL_ENTRY: | ||
| 262 | + if (!entry) | ||
| 263 | + return 0; | ||
| 264 | + break; | ||
| 265 | + case LTTNG_KERNEL_SYSCALL_EXIT: | ||
| 266 | + if (entry) | ||
| 267 | + return 0; | ||
| 268 | + break; | ||
| 269 | + default: | ||
| 270 | + return -EINVAL; | ||
| 271 | + } | ||
| 272 | + switch (enabler->event_param.u.syscall.abi) { | ||
| 273 | + case LTTNG_KERNEL_SYSCALL_ABI_ALL: | ||
| 274 | + break; | ||
| 275 | + case LTTNG_KERNEL_SYSCALL_ABI_NATIVE: | ||
| 276 | + if (compat) | ||
| 277 | + return 0; | ||
| 278 | + break; | ||
| 279 | + case LTTNG_KERNEL_SYSCALL_ABI_COMPAT: | ||
| 280 | + if (!compat) | ||
| 281 | + return 0; | ||
| 282 | + break; | ||
| 283 | + default: | ||
| 284 | + return -EINVAL; | ||
| 285 | + } | ||
| 286 | + switch (enabler->event_param.u.syscall.match) { | ||
| 287 | + case LTTNG_SYSCALL_MATCH_NAME: | ||
| 288 | + switch (enabler->type) { | ||
| 289 | + case LTTNG_ENABLER_STAR_GLOB: | ||
| 290 | + return lttng_match_enabler_star_glob(desc_name, enabler_name); | ||
| 291 | + case LTTNG_ENABLER_NAME: | ||
| 292 | + return lttng_match_enabler_name(desc_name, enabler_name); | ||
| 293 | + default: | ||
| 294 | + return -EINVAL; | ||
| 295 | + } | ||
| 296 | + break; | ||
| 297 | + case LTTNG_SYSCALL_MATCH_NR: | ||
| 298 | + return -EINVAL; /* Not implemented. */ | ||
| 299 | + default: | ||
| 300 | + return -EINVAL; | ||
| 301 | + } | ||
| 302 | break; | ||
| 303 | default: | ||
| 304 | WARN_ON_ONCE(1); | ||
| 305 | return -EINVAL; | ||
| 306 | } | ||
| 307 | - switch (enabler->type) { | ||
| 308 | - case LTTNG_ENABLER_STAR_GLOB: | ||
| 309 | - return lttng_match_enabler_star_glob(desc_name, enabler_name); | ||
| 310 | - case LTTNG_ENABLER_NAME: | ||
| 311 | - return lttng_match_enabler_name(desc_name, enabler_name); | ||
| 312 | - default: | ||
| 313 | - return -EINVAL; | ||
| 314 | - } | ||
| 315 | } | ||
| 316 | |||
| 317 | static | ||
| 318 | @@ -1361,9 +1433,21 @@ void lttng_create_event_if_missing(struct lttng_enabler *enabler) | ||
| 319 | static | ||
| 320 | int lttng_enabler_ref_events(struct lttng_enabler *enabler) | ||
| 321 | { | ||
| 322 | - struct lttng_session *session = enabler->chan->session; | ||
| 323 | + struct lttng_channel *chan = enabler->chan; | ||
| 324 | + struct lttng_session *session = chan->session; | ||
| 325 | struct lttng_event *event; | ||
| 326 | |||
| 327 | + if (enabler->event_param.instrumentation == LTTNG_KERNEL_SYSCALL && | ||
| 328 | + enabler->event_param.u.syscall.entryexit == LTTNG_KERNEL_SYSCALL_ENTRYEXIT && | ||
| 329 | + enabler->event_param.u.syscall.abi == LTTNG_KERNEL_SYSCALL_ABI_ALL && | ||
| 330 | + enabler->event_param.u.syscall.match == LTTNG_SYSCALL_MATCH_NAME && | ||
| 331 | + !strcmp(enabler->event_param.name, "*")) { | ||
| 332 | + if (enabler->enabled) | ||
| 333 | + WRITE_ONCE(chan->syscall_all, 1); | ||
| 334 | + else | ||
| 335 | + WRITE_ONCE(chan->syscall_all, 0); | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | /* First ensure that probe events are created for this enabler. */ | ||
| 339 | lttng_create_event_if_missing(enabler); | ||
| 340 | |||
| 341 | diff --git a/lttng-events.h b/lttng-events.h | ||
| 342 | index a36a312..d4d9976 100644 | ||
| 343 | --- a/lttng-events.h | ||
| 344 | +++ b/lttng-events.h | ||
| 345 | @@ -292,6 +292,16 @@ struct lttng_uprobe_handler { | ||
| 346 | struct list_head node; | ||
| 347 | }; | ||
| 348 | |||
| 349 | +enum lttng_syscall_entryexit { | ||
| 350 | + LTTNG_SYSCALL_ENTRY, | ||
| 351 | + LTTNG_SYSCALL_EXIT, | ||
| 352 | +}; | ||
| 353 | + | ||
| 354 | +enum lttng_syscall_abi { | ||
| 355 | + LTTNG_SYSCALL_ABI_NATIVE, | ||
| 356 | + LTTNG_SYSCALL_ABI_COMPAT, | ||
| 357 | +}; | ||
| 358 | + | ||
| 359 | /* | ||
| 360 | * lttng_event structure is referred to by the tracing fast path. It must be | ||
| 361 | * kept small. | ||
| 362 | @@ -318,6 +328,11 @@ struct lttng_event { | ||
| 363 | struct inode *inode; | ||
| 364 | struct list_head head; | ||
| 365 | } uprobe; | ||
| 366 | + struct { | ||
| 367 | + char *syscall_name; | ||
| 368 | + enum lttng_syscall_entryexit entryexit; | ||
| 369 | + enum lttng_syscall_abi abi; | ||
| 370 | + } syscall; | ||
| 371 | } u; | ||
| 372 | struct list_head list; /* Event list in session */ | ||
| 373 | unsigned int metadata_dumped:1; | ||
| 374 | @@ -457,10 +472,10 @@ struct lttng_channel { | ||
| 375 | struct lttng_syscall_filter *sc_filter; | ||
| 376 | int header_type; /* 0: unset, 1: compact, 2: large */ | ||
| 377 | enum channel_type channel_type; | ||
| 378 | + int syscall_all; | ||
| 379 | unsigned int metadata_dumped:1, | ||
| 380 | sys_enter_registered:1, | ||
| 381 | sys_exit_registered:1, | ||
| 382 | - syscall_all:1, | ||
| 383 | tstate:1; /* Transient enable state */ | ||
| 384 | }; | ||
| 385 | |||
| 386 | @@ -653,10 +668,11 @@ void lttng_clock_unref(void); | ||
| 387 | #if defined(CONFIG_HAVE_SYSCALL_TRACEPOINTS) | ||
| 388 | int lttng_syscalls_register(struct lttng_channel *chan, void *filter); | ||
| 389 | int lttng_syscalls_unregister(struct lttng_channel *chan); | ||
| 390 | +int lttng_syscalls_destroy(struct lttng_channel *chan); | ||
| 391 | int lttng_syscall_filter_enable(struct lttng_channel *chan, | ||
| 392 | - const char *name); | ||
| 393 | + struct lttng_event *event); | ||
| 394 | int lttng_syscall_filter_disable(struct lttng_channel *chan, | ||
| 395 | - const char *name); | ||
| 396 | + struct lttng_event *event); | ||
| 397 | long lttng_channel_syscall_mask(struct lttng_channel *channel, | ||
| 398 | struct lttng_kernel_syscall_mask __user *usyscall_mask); | ||
| 399 | #else | ||
| 400 | @@ -670,14 +686,19 @@ static inline int lttng_syscalls_unregister(struct lttng_channel *chan) | ||
| 401 | return 0; | ||
| 402 | } | ||
| 403 | |||
| 404 | +static inline int lttng_syscalls_destroy(struct lttng_channel *chan) | ||
| 405 | +{ | ||
| 406 | + return 0; | ||
| 407 | +} | ||
| 408 | + | ||
| 409 | static inline int lttng_syscall_filter_enable(struct lttng_channel *chan, | ||
| 410 | - const char *name) | ||
| 411 | + struct lttng_event *event); | ||
| 412 | { | ||
| 413 | return -ENOSYS; | ||
| 414 | } | ||
| 415 | |||
| 416 | static inline int lttng_syscall_filter_disable(struct lttng_channel *chan, | ||
| 417 | - const char *name) | ||
| 418 | + struct lttng_event *event); | ||
| 419 | { | ||
| 420 | return -ENOSYS; | ||
| 421 | } | ||
| 422 | diff --git a/lttng-syscalls.c b/lttng-syscalls.c | ||
| 423 | index 97f1ba9..26cead6 100644 | ||
| 424 | --- a/lttng-syscalls.c | ||
| 425 | +++ b/lttng-syscalls.c | ||
| 426 | @@ -367,8 +367,10 @@ const struct trace_syscall_entry compat_sc_exit_table[] = { | ||
| 427 | #undef CREATE_SYSCALL_TABLE | ||
| 428 | |||
| 429 | struct lttng_syscall_filter { | ||
| 430 | - DECLARE_BITMAP(sc, NR_syscalls); | ||
| 431 | - DECLARE_BITMAP(sc_compat, NR_compat_syscalls); | ||
| 432 | + DECLARE_BITMAP(sc_entry, NR_syscalls); | ||
| 433 | + DECLARE_BITMAP(sc_exit, NR_syscalls); | ||
| 434 | + DECLARE_BITMAP(sc_compat_entry, NR_compat_syscalls); | ||
| 435 | + DECLARE_BITMAP(sc_compat_exit, NR_compat_syscalls); | ||
| 436 | }; | ||
| 437 | |||
| 438 | static void syscall_entry_unknown(struct lttng_event *event, | ||
| 439 | @@ -391,29 +393,23 @@ void syscall_entry_probe(void *__data, struct pt_regs *regs, long id) | ||
| 440 | size_t table_len; | ||
| 441 | |||
| 442 | if (unlikely(in_compat_syscall())) { | ||
| 443 | - struct lttng_syscall_filter *filter; | ||
| 444 | - | ||
| 445 | - filter = lttng_rcu_dereference(chan->sc_filter); | ||
| 446 | - if (filter) { | ||
| 447 | - if (id < 0 || id >= NR_compat_syscalls | ||
| 448 | - || !test_bit(id, filter->sc_compat)) { | ||
| 449 | - /* System call filtered out. */ | ||
| 450 | - return; | ||
| 451 | - } | ||
| 452 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 453 | + | ||
| 454 | + if (id < 0 || id >= NR_compat_syscalls | ||
| 455 | + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_compat_entry))) { | ||
| 456 | + /* System call filtered out. */ | ||
| 457 | + return; | ||
| 458 | } | ||
| 459 | table = compat_sc_table; | ||
| 460 | table_len = ARRAY_SIZE(compat_sc_table); | ||
| 461 | unknown_event = chan->sc_compat_unknown; | ||
| 462 | } else { | ||
| 463 | - struct lttng_syscall_filter *filter; | ||
| 464 | - | ||
| 465 | - filter = lttng_rcu_dereference(chan->sc_filter); | ||
| 466 | - if (filter) { | ||
| 467 | - if (id < 0 || id >= NR_syscalls | ||
| 468 | - || !test_bit(id, filter->sc)) { | ||
| 469 | - /* System call filtered out. */ | ||
| 470 | - return; | ||
| 471 | - } | ||
| 472 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 473 | + | ||
| 474 | + if (id < 0 || id >= NR_syscalls | ||
| 475 | + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_entry))) { | ||
| 476 | + /* System call filtered out. */ | ||
| 477 | + return; | ||
| 478 | } | ||
| 479 | table = sc_table; | ||
| 480 | table_len = ARRAY_SIZE(sc_table); | ||
| 481 | @@ -545,29 +541,23 @@ void syscall_exit_probe(void *__data, struct pt_regs *regs, long ret) | ||
| 482 | |||
| 483 | id = syscall_get_nr(current, regs); | ||
| 484 | if (unlikely(in_compat_syscall())) { | ||
| 485 | - struct lttng_syscall_filter *filter; | ||
| 486 | - | ||
| 487 | - filter = lttng_rcu_dereference(chan->sc_filter); | ||
| 488 | - if (filter) { | ||
| 489 | - if (id < 0 || id >= NR_compat_syscalls | ||
| 490 | - || !test_bit(id, filter->sc_compat)) { | ||
| 491 | - /* System call filtered out. */ | ||
| 492 | - return; | ||
| 493 | - } | ||
| 494 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 495 | + | ||
| 496 | + if (id < 0 || id >= NR_compat_syscalls | ||
| 497 | + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_compat_exit))) { | ||
| 498 | + /* System call filtered out. */ | ||
| 499 | + return; | ||
| 500 | } | ||
| 501 | table = compat_sc_exit_table; | ||
| 502 | table_len = ARRAY_SIZE(compat_sc_exit_table); | ||
| 503 | unknown_event = chan->compat_sc_exit_unknown; | ||
| 504 | } else { | ||
| 505 | - struct lttng_syscall_filter *filter; | ||
| 506 | - | ||
| 507 | - filter = lttng_rcu_dereference(chan->sc_filter); | ||
| 508 | - if (filter) { | ||
| 509 | - if (id < 0 || id >= NR_syscalls | ||
| 510 | - || !test_bit(id, filter->sc)) { | ||
| 511 | - /* System call filtered out. */ | ||
| 512 | - return; | ||
| 513 | - } | ||
| 514 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 515 | + | ||
| 516 | + if (id < 0 || id >= NR_syscalls | ||
| 517 | + || (!READ_ONCE(chan->syscall_all) && !test_bit(id, filter->sc_exit))) { | ||
| 518 | + /* System call filtered out. */ | ||
| 519 | + return; | ||
| 520 | } | ||
| 521 | table = sc_exit_table; | ||
| 522 | table_len = ARRAY_SIZE(sc_exit_table); | ||
| 523 | @@ -713,27 +703,23 @@ int fill_table(const struct trace_syscall_entry *table, size_t table_len, | ||
| 524 | memset(&ev, 0, sizeof(ev)); | ||
| 525 | switch (type) { | ||
| 526 | case SC_TYPE_ENTRY: | ||
| 527 | - strncpy(ev.name, SYSCALL_ENTRY_STR, | ||
| 528 | - LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 529 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY; | ||
| 530 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE; | ||
| 531 | break; | ||
| 532 | case SC_TYPE_EXIT: | ||
| 533 | - strncpy(ev.name, SYSCALL_EXIT_STR, | ||
| 534 | - LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 535 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT; | ||
| 536 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE; | ||
| 537 | break; | ||
| 538 | case SC_TYPE_COMPAT_ENTRY: | ||
| 539 | - strncpy(ev.name, COMPAT_SYSCALL_ENTRY_STR, | ||
| 540 | - LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 541 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY; | ||
| 542 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; | ||
| 543 | break; | ||
| 544 | case SC_TYPE_COMPAT_EXIT: | ||
| 545 | - strncpy(ev.name, COMPAT_SYSCALL_EXIT_STR, | ||
| 546 | - LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 547 | - break; | ||
| 548 | - default: | ||
| 549 | - BUG_ON(1); | ||
| 550 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT; | ||
| 551 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; | ||
| 552 | break; | ||
| 553 | } | ||
| 554 | - strncat(ev.name, desc->name, | ||
| 555 | - LTTNG_KERNEL_SYM_NAME_LEN - strlen(ev.name) - 1); | ||
| 556 | + strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 557 | ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; | ||
| 558 | ev.instrumentation = LTTNG_KERNEL_SYSCALL; | ||
| 559 | chan_table[i] = _lttng_event_create(chan, &ev, filter, | ||
| 560 | @@ -803,6 +789,8 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter) | ||
| 561 | strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 562 | ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; | ||
| 563 | ev.instrumentation = LTTNG_KERNEL_SYSCALL; | ||
| 564 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY; | ||
| 565 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE; | ||
| 566 | chan->sc_unknown = _lttng_event_create(chan, &ev, filter, | ||
| 567 | desc, | ||
| 568 | ev.instrumentation); | ||
| 569 | @@ -820,6 +808,8 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter) | ||
| 570 | strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 571 | ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; | ||
| 572 | ev.instrumentation = LTTNG_KERNEL_SYSCALL; | ||
| 573 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_ENTRY; | ||
| 574 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; | ||
| 575 | chan->sc_compat_unknown = _lttng_event_create(chan, &ev, filter, | ||
| 576 | desc, | ||
| 577 | ev.instrumentation); | ||
| 578 | @@ -837,6 +827,8 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter) | ||
| 579 | strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 580 | ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; | ||
| 581 | ev.instrumentation = LTTNG_KERNEL_SYSCALL; | ||
| 582 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT; | ||
| 583 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_COMPAT; | ||
| 584 | chan->compat_sc_exit_unknown = _lttng_event_create(chan, &ev, | ||
| 585 | filter, desc, | ||
| 586 | ev.instrumentation); | ||
| 587 | @@ -854,6 +846,8 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter) | ||
| 588 | strncpy(ev.name, desc->name, LTTNG_KERNEL_SYM_NAME_LEN); | ||
| 589 | ev.name[LTTNG_KERNEL_SYM_NAME_LEN - 1] = '\0'; | ||
| 590 | ev.instrumentation = LTTNG_KERNEL_SYSCALL; | ||
| 591 | + ev.u.syscall.entryexit = LTTNG_KERNEL_SYSCALL_EXIT; | ||
| 592 | + ev.u.syscall.abi = LTTNG_KERNEL_SYSCALL_ABI_NATIVE; | ||
| 593 | chan->sc_exit_unknown = _lttng_event_create(chan, &ev, filter, | ||
| 594 | desc, ev.instrumentation); | ||
| 595 | WARN_ON_ONCE(!chan->sc_exit_unknown); | ||
| 596 | @@ -883,6 +877,14 @@ int lttng_syscalls_register(struct lttng_channel *chan, void *filter) | ||
| 597 | if (ret) | ||
| 598 | return ret; | ||
| 599 | #endif | ||
| 600 | + | ||
| 601 | + if (!chan->sc_filter) { | ||
| 602 | + chan->sc_filter = kzalloc(sizeof(struct lttng_syscall_filter), | ||
| 603 | + GFP_KERNEL); | ||
| 604 | + if (!chan->sc_filter) | ||
| 605 | + return -ENOMEM; | ||
| 606 | + } | ||
| 607 | + | ||
| 608 | if (!chan->sys_enter_registered) { | ||
| 609 | ret = lttng_wrapper_tracepoint_probe_register("sys_enter", | ||
| 610 | (void *) syscall_entry_probe, chan); | ||
| 611 | @@ -930,7 +932,11 @@ int lttng_syscalls_unregister(struct lttng_channel *chan) | ||
| 612 | return ret; | ||
| 613 | chan->sys_exit_registered = 0; | ||
| 614 | } | ||
| 615 | - /* lttng_event destroy will be performed by lttng_session_destroy() */ | ||
| 616 | + return 0; | ||
| 617 | +} | ||
| 618 | + | ||
| 619 | +int lttng_syscalls_destroy(struct lttng_channel *chan) | ||
| 620 | +{ | ||
| 621 | kfree(chan->sc_table); | ||
| 622 | kfree(chan->sc_exit_table); | ||
| 623 | #ifdef CONFIG_COMPAT | ||
| 624 | @@ -993,136 +999,150 @@ uint32_t get_sc_tables_len(void) | ||
| 625 | return ARRAY_SIZE(sc_table) + ARRAY_SIZE(compat_sc_table); | ||
| 626 | } | ||
| 627 | |||
| 628 | -int lttng_syscall_filter_enable(struct lttng_channel *chan, | ||
| 629 | - const char *name) | ||
| 630 | +static | ||
| 631 | +const char *get_syscall_name(struct lttng_event *event) | ||
| 632 | { | ||
| 633 | - int syscall_nr, compat_syscall_nr, ret; | ||
| 634 | - struct lttng_syscall_filter *filter; | ||
| 635 | + size_t prefix_len = 0; | ||
| 636 | |||
| 637 | - WARN_ON_ONCE(!chan->sc_table); | ||
| 638 | + WARN_ON_ONCE(event->instrumentation != LTTNG_KERNEL_SYSCALL); | ||
| 639 | |||
| 640 | - if (!name) { | ||
| 641 | - /* Enable all system calls by removing filter */ | ||
| 642 | - if (chan->sc_filter) { | ||
| 643 | - filter = chan->sc_filter; | ||
| 644 | - rcu_assign_pointer(chan->sc_filter, NULL); | ||
| 645 | - synchronize_trace(); | ||
| 646 | - kfree(filter); | ||
| 647 | + switch (event->u.syscall.entryexit) { | ||
| 648 | + case LTTNG_SYSCALL_ENTRY: | ||
| 649 | + switch (event->u.syscall.abi) { | ||
| 650 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 651 | + prefix_len = strlen(SYSCALL_ENTRY_STR); | ||
| 652 | + break; | ||
| 653 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 654 | + prefix_len = strlen(COMPAT_SYSCALL_ENTRY_STR); | ||
| 655 | + break; | ||
| 656 | } | ||
| 657 | - chan->syscall_all = 1; | ||
| 658 | - return 0; | ||
| 659 | - } | ||
| 660 | - | ||
| 661 | - if (!chan->sc_filter) { | ||
| 662 | - if (chan->syscall_all) { | ||
| 663 | - /* | ||
| 664 | - * All syscalls are already enabled. | ||
| 665 | - */ | ||
| 666 | - return -EEXIST; | ||
| 667 | + break; | ||
| 668 | + case LTTNG_SYSCALL_EXIT: | ||
| 669 | + switch (event->u.syscall.abi) { | ||
| 670 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 671 | + prefix_len = strlen(SYSCALL_EXIT_STR); | ||
| 672 | + break; | ||
| 673 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 674 | + prefix_len = strlen(COMPAT_SYSCALL_EXIT_STR); | ||
| 675 | + break; | ||
| 676 | } | ||
| 677 | - filter = kzalloc(sizeof(struct lttng_syscall_filter), | ||
| 678 | - GFP_KERNEL); | ||
| 679 | - if (!filter) | ||
| 680 | - return -ENOMEM; | ||
| 681 | - } else { | ||
| 682 | - filter = chan->sc_filter; | ||
| 683 | + break; | ||
| 684 | } | ||
| 685 | - syscall_nr = get_syscall_nr(name); | ||
| 686 | - compat_syscall_nr = get_compat_syscall_nr(name); | ||
| 687 | - if (syscall_nr < 0 && compat_syscall_nr < 0) { | ||
| 688 | - ret = -ENOENT; | ||
| 689 | - goto error; | ||
| 690 | + WARN_ON_ONCE(prefix_len == 0); | ||
| 691 | + return event->desc->name + prefix_len; | ||
| 692 | +} | ||
| 693 | + | ||
| 694 | +int lttng_syscall_filter_enable(struct lttng_channel *chan, | ||
| 695 | + struct lttng_event *event) | ||
| 696 | +{ | ||
| 697 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 698 | + const char *syscall_name; | ||
| 699 | + unsigned long *bitmap; | ||
| 700 | + int syscall_nr; | ||
| 701 | + | ||
| 702 | + WARN_ON_ONCE(!chan->sc_table); | ||
| 703 | + | ||
| 704 | + syscall_name = get_syscall_name(event); | ||
| 705 | + | ||
| 706 | + switch (event->u.syscall.abi) { | ||
| 707 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 708 | + syscall_nr = get_syscall_nr(syscall_name); | ||
| 709 | + break; | ||
| 710 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 711 | + syscall_nr = get_compat_syscall_nr(syscall_name); | ||
| 712 | + break; | ||
| 713 | + default: | ||
| 714 | + return -EINVAL; | ||
| 715 | } | ||
| 716 | - if (syscall_nr >= 0) { | ||
| 717 | - if (test_bit(syscall_nr, filter->sc)) { | ||
| 718 | - ret = -EEXIST; | ||
| 719 | - goto error; | ||
| 720 | + if (syscall_nr < 0) | ||
| 721 | + return -ENOENT; | ||
| 722 | + | ||
| 723 | + | ||
| 724 | + switch (event->u.syscall.entryexit) { | ||
| 725 | + case LTTNG_SYSCALL_ENTRY: | ||
| 726 | + switch (event->u.syscall.abi) { | ||
| 727 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 728 | + bitmap = filter->sc_entry; | ||
| 729 | + break; | ||
| 730 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 731 | + bitmap = filter->sc_compat_entry; | ||
| 732 | + break; | ||
| 733 | } | ||
| 734 | - bitmap_set(filter->sc, syscall_nr, 1); | ||
| 735 | - } | ||
| 736 | - if (compat_syscall_nr >= 0) { | ||
| 737 | - if (test_bit(compat_syscall_nr, filter->sc_compat)) { | ||
| 738 | - ret = -EEXIST; | ||
| 739 | - goto error; | ||
| 740 | + break; | ||
| 741 | + case LTTNG_SYSCALL_EXIT: | ||
| 742 | + switch (event->u.syscall.abi) { | ||
| 743 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 744 | + bitmap = filter->sc_exit; | ||
| 745 | + break; | ||
| 746 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 747 | + bitmap = filter->sc_compat_exit; | ||
| 748 | + break; | ||
| 749 | } | ||
| 750 | - bitmap_set(filter->sc_compat, compat_syscall_nr, 1); | ||
| 751 | + break; | ||
| 752 | + default: | ||
| 753 | + return -EINVAL; | ||
| 754 | } | ||
| 755 | - if (!chan->sc_filter) | ||
| 756 | - rcu_assign_pointer(chan->sc_filter, filter); | ||
| 757 | + if (test_bit(syscall_nr, bitmap)) | ||
| 758 | + return -EEXIST; | ||
| 759 | + bitmap_set(bitmap, syscall_nr, 1); | ||
| 760 | return 0; | ||
| 761 | - | ||
| 762 | -error: | ||
| 763 | - if (!chan->sc_filter) | ||
| 764 | - kfree(filter); | ||
| 765 | - return ret; | ||
| 766 | } | ||
| 767 | |||
| 768 | int lttng_syscall_filter_disable(struct lttng_channel *chan, | ||
| 769 | - const char *name) | ||
| 770 | + struct lttng_event *event) | ||
| 771 | { | ||
| 772 | - int syscall_nr, compat_syscall_nr, ret; | ||
| 773 | - struct lttng_syscall_filter *filter; | ||
| 774 | + struct lttng_syscall_filter *filter = chan->sc_filter; | ||
| 775 | + const char *syscall_name; | ||
| 776 | + unsigned long *bitmap; | ||
| 777 | + int syscall_nr; | ||
| 778 | |||
| 779 | WARN_ON_ONCE(!chan->sc_table); | ||
| 780 | |||
| 781 | - if (!chan->sc_filter) { | ||
| 782 | - if (!chan->syscall_all) | ||
| 783 | - return -EEXIST; | ||
| 784 | - filter = kzalloc(sizeof(struct lttng_syscall_filter), | ||
| 785 | - GFP_KERNEL); | ||
| 786 | - if (!filter) | ||
| 787 | - return -ENOMEM; | ||
| 788 | - /* Trace all system calls, then apply disable. */ | ||
| 789 | - bitmap_set(filter->sc, 0, NR_syscalls); | ||
| 790 | - bitmap_set(filter->sc_compat, 0, NR_compat_syscalls); | ||
| 791 | - } else { | ||
| 792 | - filter = chan->sc_filter; | ||
| 793 | + syscall_name = get_syscall_name(event); | ||
| 794 | + | ||
| 795 | + switch (event->u.syscall.abi) { | ||
| 796 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 797 | + syscall_nr = get_syscall_nr(syscall_name); | ||
| 798 | + break; | ||
| 799 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 800 | + syscall_nr = get_compat_syscall_nr(syscall_name); | ||
| 801 | + break; | ||
| 802 | + default: | ||
| 803 | + return -EINVAL; | ||
| 804 | } | ||
| 805 | + if (syscall_nr < 0) | ||
| 806 | + return -ENOENT; | ||
| 807 | |||
| 808 | - if (!name) { | ||
| 809 | - /* Fail if all syscalls are already disabled. */ | ||
| 810 | - if (bitmap_empty(filter->sc, NR_syscalls) | ||
| 811 | - && bitmap_empty(filter->sc_compat, | ||
| 812 | - NR_compat_syscalls)) { | ||
| 813 | - ret = -EEXIST; | ||
| 814 | - goto error; | ||
| 815 | - } | ||
| 816 | |||
| 817 | - /* Disable all system calls */ | ||
| 818 | - bitmap_clear(filter->sc, 0, NR_syscalls); | ||
| 819 | - bitmap_clear(filter->sc_compat, 0, NR_compat_syscalls); | ||
| 820 | - goto apply_filter; | ||
| 821 | - } | ||
| 822 | - syscall_nr = get_syscall_nr(name); | ||
| 823 | - compat_syscall_nr = get_compat_syscall_nr(name); | ||
| 824 | - if (syscall_nr < 0 && compat_syscall_nr < 0) { | ||
| 825 | - ret = -ENOENT; | ||
| 826 | - goto error; | ||
| 827 | - } | ||
| 828 | - if (syscall_nr >= 0) { | ||
| 829 | - if (!test_bit(syscall_nr, filter->sc)) { | ||
| 830 | - ret = -EEXIST; | ||
| 831 | - goto error; | ||
| 832 | + switch (event->u.syscall.entryexit) { | ||
| 833 | + case LTTNG_SYSCALL_ENTRY: | ||
| 834 | + switch (event->u.syscall.abi) { | ||
| 835 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 836 | + bitmap = filter->sc_entry; | ||
| 837 | + break; | ||
| 838 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 839 | + bitmap = filter->sc_compat_entry; | ||
| 840 | + break; | ||
| 841 | } | ||
| 842 | - bitmap_clear(filter->sc, syscall_nr, 1); | ||
| 843 | - } | ||
| 844 | - if (compat_syscall_nr >= 0) { | ||
| 845 | - if (!test_bit(compat_syscall_nr, filter->sc_compat)) { | ||
| 846 | - ret = -EEXIST; | ||
| 847 | - goto error; | ||
| 848 | + break; | ||
| 849 | + case LTTNG_SYSCALL_EXIT: | ||
| 850 | + switch (event->u.syscall.abi) { | ||
| 851 | + case LTTNG_SYSCALL_ABI_NATIVE: | ||
| 852 | + bitmap = filter->sc_exit; | ||
| 853 | + break; | ||
| 854 | + case LTTNG_SYSCALL_ABI_COMPAT: | ||
| 855 | + bitmap = filter->sc_compat_exit; | ||
| 856 | + break; | ||
| 857 | } | ||
| 858 | - bitmap_clear(filter->sc_compat, compat_syscall_nr, 1); | ||
| 859 | + break; | ||
| 860 | + default: | ||
| 861 | + return -EINVAL; | ||
| 862 | } | ||
| 863 | -apply_filter: | ||
| 864 | - if (!chan->sc_filter) | ||
| 865 | - rcu_assign_pointer(chan->sc_filter, filter); | ||
| 866 | - chan->syscall_all = 0; | ||
| 867 | - return 0; | ||
| 868 | + if (!test_bit(syscall_nr, bitmap)) | ||
| 869 | + return -EEXIST; | ||
| 870 | + bitmap_clear(bitmap, syscall_nr, 1); | ||
| 871 | |||
| 872 | -error: | ||
| 873 | - if (!chan->sc_filter) | ||
| 874 | - kfree(filter); | ||
| 875 | - return ret; | ||
| 876 | + return 0; | ||
| 877 | } | ||
| 878 | |||
| 879 | static | ||
| 880 | @@ -1236,6 +1256,9 @@ const struct file_operations lttng_syscall_list_fops = { | ||
| 881 | .release = seq_release, | ||
| 882 | }; | ||
| 883 | |||
| 884 | +/* | ||
| 885 | + * A syscall is enabled if it is traced for either entry or exit. | ||
| 886 | + */ | ||
| 887 | long lttng_channel_syscall_mask(struct lttng_channel *channel, | ||
| 888 | struct lttng_kernel_syscall_mask __user *usyscall_mask) | ||
| 889 | { | ||
| 890 | @@ -1262,8 +1285,9 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel, | ||
| 891 | char state; | ||
| 892 | |||
| 893 | if (channel->sc_table) { | ||
| 894 | - if (filter) | ||
| 895 | - state = test_bit(bit, filter->sc); | ||
| 896 | + if (!READ_ONCE(channel->syscall_all) && filter) | ||
| 897 | + state = test_bit(bit, filter->sc_entry) | ||
| 898 | + || test_bit(bit, filter->sc_exit); | ||
| 899 | else | ||
| 900 | state = 1; | ||
| 901 | } else { | ||
| 902 | @@ -1275,9 +1299,11 @@ long lttng_channel_syscall_mask(struct lttng_channel *channel, | ||
| 903 | char state; | ||
| 904 | |||
| 905 | if (channel->compat_sc_table) { | ||
| 906 | - if (filter) | ||
| 907 | + if (!READ_ONCE(channel->syscall_all) && filter) | ||
| 908 | state = test_bit(bit - ARRAY_SIZE(sc_table), | ||
| 909 | - filter->sc_compat); | ||
| 910 | + filter->sc_compat_entry) | ||
| 911 | + || test_bit(bit - ARRAY_SIZE(sc_table), | ||
| 912 | + filter->sc_compat_exit); | ||
| 913 | else | ||
| 914 | state = 1; | ||
| 915 | } else { | ||
| 916 | -- | ||
| 917 | 2.19.1 | ||
| 918 | |||
diff --git a/meta/recipes-kernel/lttng/lttng-modules_2.12.2.bb b/meta/recipes-kernel/lttng/lttng-modules_2.12.3.bb index e36b327a08..0b6a69ff5e 100644 --- a/meta/recipes-kernel/lttng/lttng-modules_2.12.2.bb +++ b/meta/recipes-kernel/lttng/lttng-modules_2.12.3.bb | |||
| @@ -11,19 +11,9 @@ include lttng-platforms.inc | |||
| 11 | SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \ | 11 | SRC_URI = "https://lttng.org/files/${BPN}/${BPN}-${PV}.tar.bz2 \ |
| 12 | file://Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch \ | 12 | file://Makefile-Do-not-fail-if-CONFIG_TRACEPOINTS-is-not-en.patch \ |
| 13 | file://BUILD_RUNTIME_BUG_ON-vs-gcc7.patch \ | 13 | file://BUILD_RUNTIME_BUG_ON-vs-gcc7.patch \ |
| 14 | file://0001-Kconfig-fix-dependency-issue-when-building-in-tree-w.patch \ | ||
| 15 | file://0002-fix-Move-mmutrace.h-into-the-mmu-sub-directory-v5.9.patch \ | ||
| 16 | file://0003-fix-KVM-x86-mmu-Make-kvm_mmu_page-definition-and-acc.patch \ | ||
| 17 | file://0004-fix-ext4-limit-the-length-of-per-inode-prealloc-list.patch \ | ||
| 18 | file://0005-fix-ext4-indicate-via-a-block-bitmap-read-is-prefetc.patch \ | ||
| 19 | file://0006-fix-removal-of-smp_-read_barrier_depends-v5.9.patch \ | ||
| 20 | file://0007-fix-writeback-Drop-I_DIRTY_TIME_EXPIRE-v5.9.patch \ | ||
| 21 | file://0008-fix-writeback-Fix-sync-livelock-due-to-b_dirty_time-.patch \ | ||
| 22 | file://0009-fix-version-ranges-for-ext4_discard_preallocations-a.patch \ | ||
| 23 | file://0010-Fix-system-call-filter-table.patch \ | ||
| 24 | " | 14 | " |
| 25 | 15 | ||
| 26 | SRC_URI[sha256sum] = "df50bc3bd58679705714f17721acf619a8b0cedc694f8a97052aa5099626feca" | 16 | SRC_URI[sha256sum] = "673ef85c9f03e9b8fed10795e09d4e68add39404b70068d08b10f7b85754d7f0" |
| 27 | 17 | ||
| 28 | export INSTALL_MOD_DIR="kernel/lttng-modules" | 18 | export INSTALL_MOD_DIR="kernel/lttng-modules" |
| 29 | 19 | ||
