From 11a1e5f29119132d03b6316384e7a32b917be0dc Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:49:37 -0400 Subject: [PATCH 01/16] event notifier: Add missing static Mark capture_sequence() static because it is only used within the compile unit. Signed-off-by: Mathieu Desnoyers Change-Id: I003e5cf016fbf2f2df24f4550a6c285e020956d0 --- src/lttng-event-notifier-notification.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lttng-event-notifier-notification.c b/src/lttng-event-notifier-notification.c index ecbc0676..29d2d156 100644 --- a/src/lttng-event-notifier-notification.c +++ b/src/lttng-event-notifier-notification.c @@ -246,6 +246,7 @@ int capture_sequence_element_unsigned(uint8_t *ptr, return 0; } +static int capture_sequence(struct lttng_msgpack_writer *writer, struct lttng_interpreter_output *output) { -- 2.34.1 From 435454a76c63eb3f574562aeb8146fba8889b25e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:50:19 -0400 Subject: [PATCH 02/16] lttng-events: Add missing static get_tracker() and lttng_metadata_printf() are only used within the compile unit, mark them as static. Signed-off-by: Mathieu Desnoyers Change-Id: Ie454c85cc29a30d964922fcfe1f88f3fb91bbc8f --- src/lttng-events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lttng-events.c b/src/lttng-events.c index a0bd2322..b8fa11e3 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -1547,6 +1547,7 @@ void _lttng_event_destroy(struct lttng_kernel_event_common *event) } } +static struct lttng_kernel_id_tracker *get_tracker(struct lttng_kernel_session *session, enum tracker_type tracker_type) { @@ -2818,6 +2819,7 @@ void lttng_metadata_end(struct lttng_kernel_session *session) * The content of the printf is printed as a single atomic metadata * transaction. */ +static int lttng_metadata_printf(struct lttng_kernel_session *session, const char *fmt, ...) { -- 2.34.1 From cac5a777e47a880008434922ba931d7c700d6fc4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:51:39 -0400 Subject: [PATCH 03/16] lttng-events: Remove dead code Functions lttng_event_notifier_enabler_enable and lttng_event_notifier_enabler_disable are unused since the 2.13 refactoring, remove them. Signed-off-by: Mathieu Desnoyers Change-Id: I18d0d483bf54cbc7d158413f27111271c68ac37d --- src/lttng-events.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/lttng-events.c b/src/lttng-events.c index b8fa11e3..73f591fd 100644 --- a/src/lttng-events.c +++ b/src/lttng-events.c @@ -2448,26 +2448,6 @@ void lttng_event_notifier_enabler_group_add(struct lttng_event_notifier_group *e mutex_unlock(&sessions_mutex); } -int lttng_event_notifier_enabler_enable( - struct lttng_event_notifier_enabler *event_notifier_enabler) -{ - mutex_lock(&sessions_mutex); - lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->enabled = 1; - lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group); - mutex_unlock(&sessions_mutex); - return 0; -} - -int lttng_event_notifier_enabler_disable( - struct lttng_event_notifier_enabler *event_notifier_enabler) -{ - mutex_lock(&sessions_mutex); - lttng_event_notifier_enabler_as_enabler(event_notifier_enabler)->enabled = 0; - lttng_event_notifier_group_sync_enablers(event_notifier_enabler->group); - mutex_unlock(&sessions_mutex); - return 0; -} - int lttng_event_notifier_enabler_attach_capture_bytecode( struct lttng_event_notifier_enabler *event_notifier_enabler, struct lttng_kernel_abi_capture_bytecode __user *bytecode) -- 2.34.1 From 0f7e7309025e8c95b8e1b47ad3d3378b6b40895d Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:52:54 -0400 Subject: [PATCH 04/16] statedump: Add missing events-internal.h include Include events-internal.h for the declaration of lttng_statedump_start(). Signed-off-by: Mathieu Desnoyers Change-Id: Ieda391aa0d780113efe1d517d8bc5aedb2095a2c --- src/lttng-statedump-impl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c index 4a228ce4..a0e97e1c 100644 --- a/src/lttng-statedump-impl.c +++ b/src/lttng-statedump-impl.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include -- 2.34.1 From f88cb8f515407b94d461a5ad356e3234556943a8 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:54:20 -0400 Subject: [PATCH 05/16] syscalls: Remove unused duplicated code lttng_abi_syscall_list() was moved to src/lttng-abi.c within the 2.13 refactoring. Remove this unused copy. Signed-off-by: Mathieu Desnoyers Change-Id: Iabbab3b576e3d85bc5ac9831729a5786b5c5f224 --- src/lttng-syscalls.c | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/src/lttng-syscalls.c b/src/lttng-syscalls.c index 5ec6be5a..827ca1d3 100644 --- a/src/lttng-syscalls.c +++ b/src/lttng-syscalls.c @@ -1310,35 +1310,3 @@ long lttng_syscall_table_get_active_mask(struct lttng_kernel_syscall_table *sysc kfree(tmp_mask); return ret; } - -int lttng_abi_syscall_list(void) -{ - struct file *syscall_list_file; - int file_fd, ret; - - file_fd = get_unused_fd_flags(0); - if (file_fd < 0) { - ret = file_fd; - goto fd_error; - } - - syscall_list_file = anon_inode_getfile("[lttng_syscall_list]", - <tng_syscall_list_fops, - NULL, O_RDWR); - if (IS_ERR(syscall_list_file)) { - ret = PTR_ERR(syscall_list_file); - goto file_error; - } - ret = lttng_syscall_list_fops.open(NULL, syscall_list_file); - if (ret < 0) - goto open_error; - fd_install(file_fd, syscall_list_file); - return file_fd; - -open_error: - fput(syscall_list_file); -file_error: - put_unused_fd(file_fd); -fd_error: - return ret; -} -- 2.34.1 From e0d345140e84acd4f2716f6f0cc4824ffaf9df4b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:55:16 -0400 Subject: [PATCH 06/16] uprobes: Remove dead code lttng_uprobes_destroy_event_notifier_private is now unused. Remove it. Signed-off-by: Mathieu Desnoyers Change-Id: Ia995c60691f68090b6853b2deb0d265b1d4a047e --- src/probes/lttng-uprobes.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/probes/lttng-uprobes.c b/src/probes/lttng-uprobes.c index edded1e9..5463251a 100644 --- a/src/probes/lttng-uprobes.c +++ b/src/probes/lttng-uprobes.c @@ -305,14 +305,6 @@ void lttng_uprobes_destroy_event_private(struct lttng_kernel_event_common *event } EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_private); -void lttng_uprobes_destroy_event_notifier_private(struct lttng_kernel_event_notifier *event_notifier) -{ - iput(event_notifier->priv->parent.u.uprobe.inode); - kfree(event_notifier->priv->parent.desc->event_name); - kfree(event_notifier->priv->parent.desc); -} -EXPORT_SYMBOL_GPL(lttng_uprobes_destroy_event_notifier_private); - MODULE_LICENSE("GPL and additional rights"); MODULE_AUTHOR("Yannick Brosseau"); MODULE_DESCRIPTION("Linux Trace Toolkit Uprobes Support"); -- 2.34.1 From 75624557016686e35bdd521269abeec49365d170 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 13:55:44 -0400 Subject: [PATCH 07/16] lttng probe: include events-internal.h Include events-internal.h for the declarations of lttng_logger_init and lttng_logger_exit. Signed-off-by: Mathieu Desnoyers Change-Id: I14968060c309083f90a282f186f3c635f1ebfd8d --- src/probes/lttng.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/probes/lttng.c b/src/probes/lttng.c index 98558567..23b1de9e 100644 --- a/src/probes/lttng.c +++ b/src/probes/lttng.c @@ -18,6 +18,7 @@ #include #include #include +#include #define TP_MODULE_NOAUTOLOAD #define LTTNG_PACKAGE_BUILD -- 2.34.1 From d16e08f96b7dd6e1bd5fdeb5aca038896600d9f4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 9 May 2024 14:43:05 -0400 Subject: [PATCH 08/16] page alloc wrapper: Fix get_pfnblock_flags_mask prototype The canary __canary__get_pfnblock_flags_mask has never done its job of detecting changes to the prototype of get_pfnblock_flags_mask because it was actually calling the wrapper, because the wrapper/page_alloc.h header maps get_pfnblock_flags_mask to wrapper_get_pfnblock_flags_mask. Unfortunately, this wrapper is included by page_alloc.c only _after_ the linux/pageblock-flags.h header is included, which means the get_pfnblock_flags_mask prototype does _not_ have the wrapper prefix, which prevents it from being useful for any kind of type validation. This has been detected by a compiler warning stating that wrapper_get_pfnblock_flags_mask() does not have a prior declaration. Move the wrapper/page_alloc.h include _before_ including pageblock-flags.h. This ensures the declaration has the wrapper_ prefix, and therefore the compiler compares the declaration with the definition of wrapper_get_pfnblock_flags_mask within page_alloc.c. The canary function can be removed because it is redundant with this type check. With this proper type check in place, we notice the following two changes upstream: commit 535b81e209219 ("mm/page_alloc.c: remove unnecessary end_bitidx for [set|get]_pfnblock_flags_mask()") introduced in v5.9 removes the end_bitidx argument. commit ca891f41c4c79 ("mm: constify get_pfnblock_flags_mask and get_pfnblock_migratetype") introduced in v5.14 adds a const qualifier to the struct page pointer. Adapt the code to match the evolution of this prototype. Signed-off-by: Mathieu Desnoyers Change-Id: I51b7871edfbff0f74ba1cf4d0ad988eb8d642b4e --- src/wrapper/page_alloc.c | 74 +++++++++++++++++++++++++++++----------- 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/src/wrapper/page_alloc.c b/src/wrapper/page_alloc.c index 5e19d7b5..69988e66 100644 --- a/src/wrapper/page_alloc.c +++ b/src/wrapper/page_alloc.c @@ -11,12 +11,63 @@ #ifdef CONFIG_KALLSYMS +/* Include page_alloc wrapper before pageblock-flags.h. */ +#include + +#include #include #include #include #include -#include +#include + +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,14,0)) +static +unsigned long (*get_pfnblock_flags_mask_sym)(const struct page *page, + unsigned long pfn, + unsigned long mask); + +unsigned long wrapper_get_pfnblock_flags_mask(const struct page *page, + unsigned long pfn, + unsigned long mask) +{ + WARN_ON_ONCE(!get_pfnblock_flags_mask_sym); + if (get_pfnblock_flags_mask_sym) { + struct irq_ibt_state irq_ibt_state; + unsigned long ret; + irq_ibt_state = wrapper_irq_ibt_save(); + ret = get_pfnblock_flags_mask_sym(page, pfn, mask); + wrapper_irq_ibt_restore(irq_ibt_state); + return ret; + } else { + return -ENOSYS; + } +} +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) +static +unsigned long (*get_pfnblock_flags_mask_sym)(struct page *page, + unsigned long pfn, + unsigned long mask); + +unsigned long wrapper_get_pfnblock_flags_mask(struct page *page, + unsigned long pfn, + unsigned long mask) +{ + WARN_ON_ONCE(!get_pfnblock_flags_mask_sym); + if (get_pfnblock_flags_mask_sym) { + struct irq_ibt_state irq_ibt_state; + unsigned long ret; + + irq_ibt_state = wrapper_irq_ibt_save(); + ret = get_pfnblock_flags_mask_sym(page, pfn, mask); + wrapper_irq_ibt_restore(irq_ibt_state); + return ret; + } else { + return -ENOSYS; + } +} +#else /* #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) */ static unsigned long (*get_pfnblock_flags_mask_sym)(struct page *page, unsigned long pfn, @@ -41,6 +92,8 @@ unsigned long wrapper_get_pfnblock_flags_mask(struct page *page, return -ENOSYS; } } +#endif /* #else #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,9,0)) */ + EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask); int wrapper_get_pfnblock_flags_mask_init(void) @@ -53,25 +106,6 @@ int wrapper_get_pfnblock_flags_mask_init(void) } EXPORT_SYMBOL_GPL(wrapper_get_pfnblock_flags_mask_init); -/* - * Canary function to check for 'get_pfnblock_flags_mask()' at compile time. - * - * From 'include/linux/pageblock-flags.h': - * - * unsigned long get_pfnblock_flags_mask(struct page *page, - * unsigned long pfn, - * unsigned long end_bitidx, - * unsigned long mask); - */ -__attribute__((unused)) static -unsigned long __canary__get_pfnblock_flags_mask(struct page *page, - unsigned long pfn, - unsigned long end_bitidx, - unsigned long mask) -{ - return get_pfnblock_flags_mask(page, pfn, end_bitidx, mask); -} - #else #include -- 2.34.1 From 92dd6990b635d31390e073507ec51c19128a562f Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 8 May 2024 14:20:30 -0400 Subject: [PATCH 09/16] fix: Add missing 'pselect6_time32' and 'ppoll_time32' syscall overrides The instrumentation currently has overrides to the generated syscall tracepoints of 'ppoll' and 'pselect6' to extract additional information from the parameters. On arm-32 and x86-32 these 2 syscalls were renamed to 'ppoll_time32' and 'pselect6_time32' and new syscalls using 64-bit time_t were introduced with the old names. This results in missing overrides on these architectures for the 32-bit variants that were renamed. Add the '_time32' overrides to restore the previous behavior. Change-Id: I81e3a3ddc3f3cea58d86edcdf4a1fc9b600637c2 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- .../syscalls/syscalls_pointers_override.h | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/include/instrumentation/syscalls/syscalls_pointers_override.h b/include/instrumentation/syscalls/syscalls_pointers_override.h index 00e5990c..92467749 100644 --- a/include/instrumentation/syscalls/syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/syscalls_pointers_override.h @@ -390,6 +390,11 @@ end: ; /* Label at end of compound statement. */ \ lttng_tp_mempool_free(tp_locvar->fds_ex); #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) +/* + * Instead of extracting the user-space pointers of the 3 fd_set, + * extract the bitmask of the FDs in the sets (in, out, ex) in the form + * of an array of uint8_t (1024 FDs is the limit in the kernel). + */ #define OVERRIDE_32_select #define OVERRIDE_64_select SC_LTTNG_TRACEPOINT_EVENT_CODE(select, @@ -427,6 +432,11 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(select, #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */ #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) +/* + * Instead of extracting the user-space pointers of the 3 fd_set, + * extract the bitmask of the FDs in the sets (in, out, ex) in the form + * of an array of uint8_t (1024 FDs is the limit in the kernel). + */ #define OVERRIDE_32_pselect6 #define OVERRIDE_64_pselect6 SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6, @@ -464,6 +474,48 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6, ) #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ +#if defined(CONFIG_X86_32) || defined(CONFIG_ARM) +/* + * Instead of extracting the user-space pointers of the 3 fd_set, + * extract the bitmask of the FDs in the sets (in, out, ex) in the form + * of an array of uint8_t (1024 FDs is the limit in the kernel). + */ +#define OVERRIDE_32_pselect6_time32 +SC_LTTNG_TRACEPOINT_EVENT_CODE(pselect6_time32, + TP_PROTO(sc_exit(long ret,) int n, fd_set __user * inp, fd_set __user * outp, + fd_set __user * exp, struct old_timespec32 __user * tvp, void __user * sig), + TP_ARGS(sc_exit(ret,) n, inp, outp, exp, tvp, sig), + TP_locvar( + LTTNG_SYSCALL_SELECT_locvar + ), + TP_code_pre( + LTTNG_SYSCALL_SELECT_code_pre + ), + TP_FIELDS( + sc_exit(ctf_integer(long, ret, ret)) + sc_in(ctf_integer(int, n, n)) + sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) + sc_inout(ctf_integer(struct old_timespec32 *, tvp, tvp)) + sc_in(ctf_integer_hex(void *, sig, sig)) + + sc_inout( +#if (__BYTE_ORDER == __LITTLE_ENDIAN) + LTTNG_SYSCALL_SELECT_fds_field_LE(readfds, inp) + LTTNG_SYSCALL_SELECT_fds_field_LE(writefds, outp) + LTTNG_SYSCALL_SELECT_fds_field_LE(exceptfds, exp) +#else + LTTNG_SYSCALL_SELECT_fds_field_BE(readfds, inp) + LTTNG_SYSCALL_SELECT_fds_field_BE(writefds, outp) + LTTNG_SYSCALL_SELECT_fds_field_BE(exceptfds, exp) +#endif + ) + ), + TP_code_post( + LTTNG_SYSCALL_SELECT_code_post + ) +) +#endif /* defined(CONFIG_X86_32) || defined(CONFIG_ARM) */ + #ifdef LTTNG_CREATE_FIELD_METADATA #ifndef ONCE_LTTNG_TRACE_POLL_H #define ONCE_LTTNG_TRACE_POLL_H @@ -652,6 +704,13 @@ end: \ lttng_tp_mempool_free(tp_locvar->fds); #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) +/* + * Instead of printing the pointer address of the poll set, extract all the FDs + * and flags from the poll set. For now, only output the standardized + * set of events to limit the verbosity of the output, and also extract + * the raw value. In the future, moving to CTF2 will allow hiding unset + * fields and then allow extracting all the fields. + */ #define OVERRIDE_32_poll #define OVERRIDE_64_poll SC_LTTNG_TRACEPOINT_EVENT_CODE(poll, @@ -679,6 +738,13 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(poll, #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM) */ #if defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) +/* + * Instead of printing the pointer address of the poll set, extract all the FDs + * and flags from the poll set. For now, only output the standardized + * set of events to limit the verbosity of the output, and also extract + * the raw value. In the future, moving to CTF2 will allow hiding unset + * fields and then allow extracting all the fields. + */ #define OVERRIDE_32_ppoll #define OVERRIDE_64_ppoll SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll, @@ -707,6 +773,41 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll, ) #endif /* defined(CONFIG_X86_32) || defined(CONFIG_X86_64) || defined(CONFIG_ARM64) || defined(CONFIG_ARM) */ +#if defined(CONFIG_X86_32) || defined(CONFIG_ARM) +/* + * Instead of printing the pointer address of the poll set, extract all the FDs + * and flags from the poll set. For now, only output the standardized + * set of events to limit the verbosity of the output, and also extract + * the raw value. In the future, moving to CTF2 will allow hiding unset + * fields and then allow extracting all the fields. + */ +#define OVERRIDE_32_ppoll_time32 +SC_LTTNG_TRACEPOINT_EVENT_CODE(ppoll_time32, + TP_PROTO(sc_exit(long ret,) struct pollfd __user * ufds, + unsigned int nfds, struct old_timespec32 * tsp, const sigset_t * sigmask, size_t sigsetsize), + TP_ARGS(sc_exit(ret,) ufds, nfds, tsp, sigmask, sigsetsize), + TP_locvar( + LTTNG_SYSCALL_POLL_locvar + ), + TP_code_pre( + LTTNG_SYSCALL_POLL_code_pre + ), + TP_FIELDS( + sc_exit(ctf_integer(long, ret, ret)) + sc_in(ctf_integer(struct old_timespec32 *, tsp, tsp)) + sc_in(ctf_integer(const sigset_t *, sigmask, sigmask)) + sc_in(ctf_integer(size_t, sigsetsize, sigsetsize)) + sc_inout(ctf_integer(unsigned int, nfds, nfds)) + sc_inout(ctf_integer(unsigned int, fds_length, tp_locvar->fds_length)) + sc_inout(ctf_integer(uint8_t, overflow, tp_locvar->overflow)) + LTTNG_SYSCALL_POLL_fds_field + ), + TP_code_post( + LTTNG_SYSCALL_POLL_code_post + ) +) +#endif /* defined(CONFIG_X86_32) || defined(CONFIG_ARM) */ + #include SC_LTTNG_TRACEPOINT_ENUM(lttng_epoll_op, -- 2.34.1 From 768388a23715710258b942cd047f423630f83697 Mon Sep 17 00:00:00 2001 From: Martin Hicks Date: Fri, 17 May 2024 11:07:26 -0400 Subject: [PATCH 10/16] Fix mm_vmscan_lru_isolate tracepoint for RHEL 9.4 kernel Redhat has moved to using the format first found in the 6.7 kernel for the mm_vmscan_lru_isolate tracepoint. Change-Id: I2aa84769c0070458d902e9a0305488d6d8a380e1 Signed-off-by: Martin Hicks Signed-off-by: Kienan Stewart Signed-off-by: Mathieu Desnoyers --- include/instrumentation/events/mm_vmscan.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/instrumentation/events/mm_vmscan.h b/include/instrumentation/events/mm_vmscan.h index 90addbf3..66eb490c 100644 --- a/include/instrumentation/events/mm_vmscan.h +++ b/include/instrumentation/events/mm_vmscan.h @@ -334,7 +334,8 @@ LTTNG_TRACEPOINT_EVENT_MAP(mm_shrink_slab_end, ) ) -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0)) +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,7,0) || \ + LTTNG_RHEL_KERNEL_RANGE(5,14,0,427,16,1, 5,15,0,0,0,0)) LTTNG_TRACEPOINT_EVENT(mm_vmscan_lru_isolate, TP_PROTO(int classzone_idx, -- 2.34.1 From a66ce3814ae0a929f0f4516a2813bbc062ba18f8 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 27 May 2024 13:04:42 -0400 Subject: [PATCH 11/16] fix: btrfs: simplify delayed ref tracepoints (v6.10) See upstream commit: commit 1bff6d4f873790cfc675afce9860208576508c5a Author: Josef Bacik Date: Fri Apr 12 20:27:00 2024 -0400 btrfs: simplify delayed ref tracepoints Now that all of the delayed ref information is in the delayed ref node, drastically simplify the delayed ref tracepoints by simply passing in the btrfs_delayed_ref_node and populating the tracepoints with the values from the structure itself. Change-Id: Ic90bc23d6aa558baec33adc33b4d21e052e83375 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/instrumentation/events/btrfs.h | 94 +++++++++++++++++++++++++- 1 file changed, 92 insertions(+), 2 deletions(-) diff --git a/include/instrumentation/events/btrfs.h b/include/instrumentation/events/btrfs.h index 4d286ef4..6ede7c84 100644 --- a/include/instrumentation/events/btrfs.h +++ b/include/instrumentation/events/btrfs.h @@ -958,7 +958,51 @@ LTTNG_TRACEPOINT_EVENT(btrfs_add_block_group, ) #endif -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \ +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0)) +LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_tree_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref), + + TP_FIELDS( + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) + ctf_integer(u64, bytenr, ref->bytenr) + ctf_integer(u64, num_bytes, ref->num_bytes) + ctf_integer(int, action, ref->action) + ctf_integer(u64, parent, ref->tree_ref.parent) + ctf_integer(u64, ref_root, ref->tree_ref.root) + ctf_integer(int, level, ref->tree_ref.level) + ctf_integer(int, type, ref->type) + ctf_integer(u64, seq, ref->seq) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref, + + add_delayed_tree_ref, + + btrfs_add_delayed_tree_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref, + + run_delayed_tree_ref, + + btrfs_run_delayed_tree_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref) +) +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,92,6,0,0, 4,4,92,7,0,0) || \ @@ -1159,7 +1203,53 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_tree_ref, ) #endif -#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \ +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0)) +LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_data_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref), + + TP_FIELDS( + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) + ctf_integer(u64, bytenr, ref->bytenr) + ctf_integer(u64, num_bytes, ref->num_bytes) + ctf_integer(int, action, ref->action) + ctf_integer(u64, parent, ref->data_ref.parent) + ctf_integer(u64, ref_root, ref->data_ref.root) + ctf_integer(u64, owner, ref->data_ref.objectid) + ctf_integer(u64, offset, ref->data_ref.offset) + ctf_integer(int, type, ref->type) + ctf_integer(u64, seq, ref->seq) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_data_ref, + + add_delayed_data_ref, + + btrfs_add_delayed_data_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE_MAP(btrfs_delayed_data_ref, + + run_delayed_data_ref, + + btrfs_run_delayed_data_ref, + + TP_PROTO(const struct btrfs_fs_info *fs_info, + const struct btrfs_delayed_ref_node *ref), + + TP_ARGS(fs_info, ref) +) + +#elif (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(4,14,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,82,6,0,0, 4,4,82,7,0,0) || \ LTTNG_SLE_KERNEL_RANGE(4,4,92,6,0,0, 4,4,92,7,0,0) || \ -- 2.34.1 From d63cafab30cac1644f4ad971626d85665429a892 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 27 May 2024 13:13:15 -0400 Subject: [PATCH 12/16] fix: btrfs: move ->parent and ->ref_root into btrfs_delayed_ref_node (v6.10) See upstream commit: commit cf4f04325b2b27efa5697ba0ea4c1abdee0035b4 Author: Josef Bacik Date: Fri Apr 12 22:57:13 2024 -0400 btrfs: move ->parent and ->ref_root into btrfs_delayed_ref_node These two members are shared by both the tree refs and data refs, so move them into btrfs_delayed_ref_node proper. This allows us to greatly simplify the comparison code, as the shared refs always only sort on parent, and the non shared refs always sort first on ref_root, and then only data refs sort on their specific fields. Change-Id: Ib7c92cc4bb8d674ac66ccfa25c03476f7adaaf90 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/instrumentation/events/btrfs.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/instrumentation/events/btrfs.h b/include/instrumentation/events/btrfs.h index 6ede7c84..88709cfe 100644 --- a/include/instrumentation/events/btrfs.h +++ b/include/instrumentation/events/btrfs.h @@ -971,8 +971,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_tree_ref, ctf_integer(u64, bytenr, ref->bytenr) ctf_integer(u64, num_bytes, ref->num_bytes) ctf_integer(int, action, ref->action) - ctf_integer(u64, parent, ref->tree_ref.parent) - ctf_integer(u64, ref_root, ref->tree_ref.root) + ctf_integer(u64, parent, ref->parent) + ctf_integer(u64, ref_root, ref->ref_root) ctf_integer(int, level, ref->tree_ref.level) ctf_integer(int, type, ref->type) ctf_integer(u64, seq, ref->seq) @@ -1216,8 +1216,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs_delayed_data_ref, ctf_integer(u64, bytenr, ref->bytenr) ctf_integer(u64, num_bytes, ref->num_bytes) ctf_integer(int, action, ref->action) - ctf_integer(u64, parent, ref->data_ref.parent) - ctf_integer(u64, ref_root, ref->data_ref.root) + ctf_integer(u64, parent, ref->parent) + ctf_integer(u64, ref_root, ref->ref_root) ctf_integer(u64, owner, ref->data_ref.objectid) ctf_integer(u64, offset, ref->data_ref.offset) ctf_integer(int, type, ref->type) -- 2.34.1 From c8adc20d19d853527a29411a03e114efdeff5f59 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 27 May 2024 10:49:45 -0400 Subject: [PATCH 13/16] fix: close_on_exec(): pass files_struct instead of fdtable (v6.10) See upstream commit: commit f60d374d2cc88034385265d193a38e3f4a4b430c Author: Al Viro Date: Thu Jan 4 21:35:38 2024 -0500 close_on_exec(): pass files_struct instead of fdtable both callers are happier that way... Change-Id: I8cdabb073c2090842b27b74954d86cb486c43b3e Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/wrapper/fdtable.h | 14 ++++++++++++++ src/lttng-statedump-impl.c | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/wrapper/fdtable.h b/include/wrapper/fdtable.h index 46fc3f33..d81b4f0b 100644 --- a/include/wrapper/fdtable.h +++ b/include/wrapper/fdtable.h @@ -41,4 +41,18 @@ struct file *lttng_lookup_fdget_rcu(unsigned int fd) } #endif +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0)) +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) +{ + return close_on_exec(fd, files); +} +#else +static inline +bool lttng_close_on_exec(unsigned int fd, const struct files_struct *files) +{ + return close_on_exec(fd, files_fdtable(files)); +} +#endif + #endif /* _LTTNG_WRAPPER_FDTABLE_H */ diff --git a/src/lttng-statedump-impl.c b/src/lttng-statedump-impl.c index a0e97e1c..e06649e7 100644 --- a/src/lttng-statedump-impl.c +++ b/src/lttng-statedump-impl.c @@ -42,7 +42,6 @@ #include #include #include -#include #include /* Define the tracepoints, but do not build the probes */ @@ -445,7 +444,7 @@ int lttng_dump_one_fd(const void *p, struct file *file, unsigned int fd) * the lock is taken, but we are not aware whether this is * guaranteed or not, so play safe. */ - if (fd < fdt->max_fds && close_on_exec(fd, fdt)) + if (fd < fdt->max_fds && lttng_close_on_exec(fd, ctx->files)) flags |= O_CLOEXEC; if (IS_ERR(s)) { struct dentry *dentry = file->f_path.dentry; -- 2.34.1 From 8c34b41250497ef69693f3e14045ede4aa076207 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 27 May 2024 11:11:21 -0400 Subject: [PATCH 14/16] fix: net: udp: add IP/port data to the tracepoint udp/udp_fail_queue_rcv_skb (v6.10) See upstream commit: commit e9669a00bba79442dd4862c57761333d6a020c24 Author: Balazs Scheidler Date: Tue Mar 26 19:05:47 2024 +0100 net: udp: add IP/port data to the tracepoint udp/udp_fail_queue_rcv_skb The udp_fail_queue_rcv_skb() tracepoint lacks any details on the source and destination IP/port whereas this information can be critical in case of UDP/syslog. Change-Id: I0c337c5817b0a120298cbf5088d60671d9625b0d Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- include/instrumentation/events/udp.h | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/include/instrumentation/events/udp.h b/include/instrumentation/events/udp.h index b63a1bb5..0a94b466 100644 --- a/include/instrumentation/events/udp.h +++ b/include/instrumentation/events/udp.h @@ -7,7 +7,36 @@ #include #include +#include +#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(6,10,0)) +LTTNG_TRACEPOINT_ENUM(lttng_sk_family, + TP_ENUM_VALUES( + ctf_enum_value("AF_INET", AF_INET) + ctf_enum_value("AF_INET6", AF_INET6) + ) +) + +LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb, + + TP_PROTO(int rc, struct sock *sk, struct sk_buff *skb), + + TP_ARGS(rc, sk, skb), + + TP_FIELDS( + ctf_integer(int, rc, rc) + ctf_integer(__u16, sport, ntohs(udp_hdr(skb)->source)) + ctf_integer(__u16, dport, ntohs(udp_hdr(skb)->dest)) + ctf_enum(lttng_sk_family, __u16, family, sk->sk_family) + /* + * The 'saddr' and 'daddr' fields from the upstream tracepoint + * are currently not extracted. It is recommended to use a + * tracepoint from the 'net' probe instead which includes all + * fields from the IP header. + */ + ) +) +#else LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb, TP_PROTO(int rc, struct sock *sk), @@ -19,6 +48,7 @@ LTTNG_TRACEPOINT_EVENT(udp_fail_queue_rcv_skb, ctf_integer(__u16, lport, inet_sk(sk)->inet_num) ) ) +#endif #endif /* LTTNG_TRACE_UDP_H */ -- 2.34.1 From 2335796b2c5fbc3c432d9952cb447d87c34fbeb4 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 8 May 2024 14:47:09 -0400 Subject: [PATCH 15/16] cleanup: document 'pipe' syscall override Change-Id: Iec84c10b774c1001ff2035024a1d05fdd31c8d9d Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- .../syscalls/arm-32-syscalls_pointers_override.h | 4 ++++ .../syscalls/powerpc-32-syscalls_pointers_override.h | 4 ++++ include/instrumentation/syscalls/syscalls_pointers_override.h | 4 ++++ .../syscalls/x86-32-syscalls_pointers_override.h | 4 ++++ .../syscalls/x86-64-syscalls_pointers_override.h | 4 ++++ 5 files changed, 20 insertions(+) diff --git a/include/instrumentation/syscalls/arm-32-syscalls_pointers_override.h b/include/instrumentation/syscalls/arm-32-syscalls_pointers_override.h index 96fb731f..6c08b794 100644 --- a/include/instrumentation/syscalls/arm-32-syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/arm-32-syscalls_pointers_override.h @@ -31,6 +31,10 @@ #endif /* CONFIG_COMPAT_OLD_SIGACTION */ #endif +/* + * Override 'pipe' to set the output field 'fildes' to an array of 2 integers + * instead of the default integer pointer. + */ #define OVERRIDE_32_pipe SC_LTTNG_TRACEPOINT_EVENT(pipe, TP_PROTO(sc_exit(long ret,) int * fildes), diff --git a/include/instrumentation/syscalls/powerpc-32-syscalls_pointers_override.h b/include/instrumentation/syscalls/powerpc-32-syscalls_pointers_override.h index fde30d27..b0006833 100644 --- a/include/instrumentation/syscalls/powerpc-32-syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/powerpc-32-syscalls_pointers_override.h @@ -4,6 +4,10 @@ #ifndef CREATE_SYSCALL_TABLE +/* + * Override 'pipe' to set the output field 'fildes' to an array of 2 integers + * instead of the default integer pointer. + */ #define OVERRIDE_32_pipe SC_LTTNG_TRACEPOINT_EVENT(pipe, TP_PROTO(sc_exit(long ret,) int * fildes), diff --git a/include/instrumentation/syscalls/syscalls_pointers_override.h b/include/instrumentation/syscalls/syscalls_pointers_override.h index 92467749..b3647ecd 100644 --- a/include/instrumentation/syscalls/syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/syscalls_pointers_override.h @@ -193,6 +193,10 @@ SC_LTTNG_TRACEPOINT_EVENT(getcpu, ) ) +/* + * Override 'pipe2' to set the output field 'fildes' to an array of 2 integers + * instead of the default integer pointer. + */ #define OVERRIDE_32_pipe2 #define OVERRIDE_64_pipe2 SC_LTTNG_TRACEPOINT_EVENT(pipe2, diff --git a/include/instrumentation/syscalls/x86-32-syscalls_pointers_override.h b/include/instrumentation/syscalls/x86-32-syscalls_pointers_override.h index bd63ed09..63a900f6 100644 --- a/include/instrumentation/syscalls/x86-32-syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/x86-32-syscalls_pointers_override.h @@ -29,6 +29,10 @@ #endif /* CONFIG_COMPAT_OLD_SIGACTION */ #endif +/* + * Override 'pipe' to set the output field 'fildes' to an array of 2 integers + * instead of the default integer pointer. + */ #define OVERRIDE_32_pipe #define OVERRIDE_64_pipe SC_LTTNG_TRACEPOINT_EVENT(pipe, diff --git a/include/instrumentation/syscalls/x86-64-syscalls_pointers_override.h b/include/instrumentation/syscalls/x86-64-syscalls_pointers_override.h index bd889451..e88a97aa 100644 --- a/include/instrumentation/syscalls/x86-64-syscalls_pointers_override.h +++ b/include/instrumentation/syscalls/x86-64-syscalls_pointers_override.h @@ -155,6 +155,10 @@ SC_LTTNG_TRACEPOINT_EVENT_CODE(accept4, TP_code_post() ) +/* + * Override 'pipe' to set the output field 'fildes' to an array of 2 integers + * instead of the default integer pointer. + */ #define OVERRIDE_64_pipe SC_LTTNG_TRACEPOINT_EVENT(pipe, TP_PROTO(sc_exit(long ret,) int * fildes), -- 2.34.1 From a16d513016dad678bb3baa30a967033890bb0c37 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 8 May 2024 15:46:23 -0400 Subject: [PATCH 16/16] cleanup: add correct error messages to lttng-get-syscall-inout.sh The script argument parsing was modified in commit 6ae73da43362 ("Fix syscall generator scripts") without adjusting the error messages and comments. Report the proper errors for the current arguments. Change-Id: I86f4d16ffede1a6a48bc6ab5fe1e678ef340585b Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- tools/syscalls/lttng-get-syscall-inout.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/syscalls/lttng-get-syscall-inout.sh b/tools/syscalls/lttng-get-syscall-inout.sh index 1cf96394..e4c55e9d 100755 --- a/tools/syscalls/lttng-get-syscall-inout.sh +++ b/tools/syscalls/lttng-get-syscall-inout.sh @@ -2,7 +2,7 @@ # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) # example usage: -# lttng-get-syscall-inout.sh table-syscall-inout.txt select 1 +# lttng-get-syscall-inout.sh arm-64 select 5 1 ARCH_NAME=$1 SYSCALL_NAME=$2 @@ -14,18 +14,23 @@ GENERIC_INOUT_DESCRIPTION_FILE="$(dirname "$0")/table-syscall-inout.txt" # Delete temp file on exit trap 'rm -f "$TMPFILE"' EXIT -if [ "${GENERIC_INOUT_DESCRIPTION_FILE}" = "" ]; then - echo "Error: Please specify input file name as first argument" >&2 +if [ "${ARCH_NAME}" = "" ]; then + echo "Error: Please specify the arch name as first argument" >&2 exit 1 fi if [ "${SYSCALL_NAME}" = "" ]; then - echo "Error: Please specify system call name as second argument" >&2 + echo "Error: Please specify the system call name as second argument" >&2 + exit 1 +fi + +if [[ "${NB_ARGS}" = "" ]]; then + echo "Error: Please specify a number of arguments as third argument" >&2 exit 1 fi if [[ "${ARG_NR}" = "" || ${ARG_NR} == 0 ]]; then - echo "Error: Please specify argument number larger than 0 as third argument" >&2 + echo "Error: Please specify an argument number larger than 0 as fourth argument" >&2 exit 1 fi -- 2.34.1