From 4eaeb54a27fbf701c2a4908a6e90a978b93deb06 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 6 Dec 2018 11:31:51 -0500 Subject: [PATCH 01/16] Fix: timer instrumentation for RHEL 7.6 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/timer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/instrumentation/events/lttng-module/timer.h b/instrumentation/events/lttng-module/timer.h index 6f0cb7f3..8807ad51 100644 --- a/instrumentation/events/lttng-module/timer.h +++ b/instrumentation/events/lttng-module/timer.h @@ -44,7 +44,8 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(timer_class, timer_init, TP_ARGS(timer) ) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,2,0) || \ + LTTNG_RHEL_KERNEL_RANGE(3,10,0,957,0,0, 3,11,0,0,0,0)) /** * timer_start - called when the timer is started * @timer: pointer to struct timer_list -- 2.34.1 From 0039dbe9891cfdf2c0d04691f83c2f342993dfd7 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 9 Jan 2019 14:59:15 -0500 Subject: [PATCH 02/16] Fix: Remove 'type' argument from access_ok() function (v5.0) See upstream commit : commit 96d4f267e40f9509e8a66e2b39e8b95655617693 Author: Linus Torvalds Date: Thu Jan 3 18:57:57 2019 -0800 Remove 'type' argument from access_ok() function Nobody has actually used the type (VERIFY_READ vs VERIFY_WRITE) argument of the user address range verification function since we got rid of the old racy i386-only code to walk page tables by hand. It existed because the original 80386 would not honor the write protect bit when in kernel mode, so you had to do COW by hand before doing any user access. But we haven't supported that in a long time, and these days the 'type' argument is a purely historical artifact. A discussion about extending 'user_access_begin()' to do the range checking resulted this patch, because there is no way we're going to move the old VERIFY_xyz interface to that model. And it's best done at the end of the merge window when I've done most of my merges, so let's just get this done once and for all. This patch was mostly done with a sed-script, with manual fix-ups for the cases that weren't of the trivial 'access_ok(VERIFY_xyz' form. There were a couple of notable cases: - csky still had the old "verify_area()" name as an alias. - the iter_iov code had magical hardcoded knowledge of the actual values of VERIFY_{READ,WRITE} (not that they mattered, since nothing really used it) - microblaze used the type argument for a debug printout but other than those oddities this should be a total no-op patch. I tried to fix up all architectures, did fairly extensive grepping for access_ok() uses, and the changes are trivial, but I may have missed something. Any missed conversion should be trivially fixable, though. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/backend.h | 8 ++++---- lib/ringbuffer/ring_buffer_iterator.c | 3 ++- lttng-filter-interpreter.c | 4 ++-- probes/lttng-probe-user.c | 3 ++- wrapper/uaccess.h | 28 +++++++++++++++++++++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 wrapper/uaccess.h diff --git a/lib/ringbuffer/backend.h b/lib/ringbuffer/backend.h index 0b75de8a..3f8c1081 100644 --- a/lib/ringbuffer/backend.h +++ b/lib/ringbuffer/backend.h @@ -34,7 +34,7 @@ #include #include #include -#include +#include /* Internal helpers */ #include @@ -302,7 +302,7 @@ void lib_ring_buffer_copy_from_user_inatomic(const struct lib_ring_buffer_config set_fs(KERNEL_DS); pagefault_disable(); - if (unlikely(!access_ok(VERIFY_READ, src, len))) + if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) goto fill_buffer; if (likely(pagecpy == len)) { @@ -372,7 +372,7 @@ void lib_ring_buffer_strcpy_from_user_inatomic(const struct lib_ring_buffer_conf set_fs(KERNEL_DS); pagefault_disable(); - if (unlikely(!access_ok(VERIFY_READ, src, len))) + if (unlikely(!lttng_access_ok(VERIFY_READ, src, len))) goto fill_buffer; if (likely(pagecpy == len)) { @@ -462,7 +462,7 @@ unsigned long lib_ring_buffer_copy_from_user_check_nofault(void *dest, unsigned long ret; mm_segment_t old_fs; - if (!access_ok(VERIFY_READ, src, len)) + if (!lttng_access_ok(VERIFY_READ, src, len)) return 1; old_fs = get_fs(); set_fs(KERNEL_DS); diff --git a/lib/ringbuffer/ring_buffer_iterator.c b/lib/ringbuffer/ring_buffer_iterator.c index 61eaa5b7..96459469 100644 --- a/lib/ringbuffer/ring_buffer_iterator.c +++ b/lib/ringbuffer/ring_buffer_iterator.c @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -621,7 +622,7 @@ ssize_t channel_ring_buffer_file_read(struct file *filp, ssize_t len; might_sleep(); - if (!access_ok(VERIFY_WRITE, user_buf, count)) + if (!lttng_access_ok(VERIFY_WRITE, user_buf, count)) return -EFAULT; /* Finish copy of previous record */ diff --git a/lttng-filter-interpreter.c b/lttng-filter-interpreter.c index e1314624..bee29187 100644 --- a/lttng-filter-interpreter.c +++ b/lttng-filter-interpreter.c @@ -24,7 +24,7 @@ * SOFTWARE. */ -#include +#include #include #include @@ -46,7 +46,7 @@ char get_char(struct estack_entry *reg, size_t offset) char c; /* Handle invalid access as end of string. */ - if (unlikely(!access_ok(VERIFY_READ, + if (unlikely(!lttng_access_ok(VERIFY_READ, reg->u.s.user_str + offset, sizeof(c)))) return '\0'; diff --git a/probes/lttng-probe-user.c b/probes/lttng-probe-user.c index 099a66b2..ed566ddb 100644 --- a/probes/lttng-probe-user.c +++ b/probes/lttng-probe-user.c @@ -20,6 +20,7 @@ #include #include +#include #include /* @@ -43,7 +44,7 @@ long lttng_strlen_user_inatomic(const char *addr) char v; unsigned long ret; - if (unlikely(!access_ok(VERIFY_READ, + if (unlikely(!lttng_access_ok(VERIFY_READ, (__force const char __user *) addr, sizeof(v)))) break; diff --git a/wrapper/uaccess.h b/wrapper/uaccess.h new file mode 100644 index 00000000..c56427c5 --- /dev/null +++ b/wrapper/uaccess.h @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) + * + * wrapper/uaccess.h + * + * wrapper around linux/uaccess.h. + * + * Copyright (C) 2019 Michael Jeanson + */ + +#ifndef _LTTNG_WRAPPER_UACCESS_H +#define _LTTNG_WRAPPER_UACCESS_H + +#include +#include + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) + +#define VERIFY_READ 0 +#define VERIFY_WRITE 1 +#define lttng_access_ok(type, addr, size) access_ok(addr, size) + +#else /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) */ + +#define lttng_access_ok(type, addr, size) access_ok(type, addr, size) + +#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0) */ + +#endif /* _LTTNG_WRAPPER_UACCESS_H */ -- 2.34.1 From 89f0be35e1baf411df6852014013ac64ad1bbcf8 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 9 Jan 2019 14:59:16 -0500 Subject: [PATCH 03/16] Fix: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid Introduced in v3.12. See upstream commit : commit 92cb6c5be8134db6f7c38f25f6afd13e444cebaf Author: Trond Myklebust Date: Wed Sep 4 22:09:50 2013 -0400 SUNRPC: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid Instead of the pointer values, use the task and client identifier values for tracing purposes. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/rpc.h | 108 ++++++++++++++++++++-- 1 file changed, 102 insertions(+), 6 deletions(-) diff --git a/instrumentation/events/lttng-module/rpc.h b/instrumentation/events/lttng-module/rpc.h index b9e45fef..a4ac5570 100644 --- a/instrumentation/events/lttng-module/rpc.h +++ b/instrumentation/events/lttng-module/rpc.h @@ -8,6 +8,20 @@ #include #include +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) +LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, + + TP_PROTO(struct rpc_task *task), + + TP_ARGS(task), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer(int, status, task->tk_status) + ) +) +#else LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, TP_PROTO(struct rpc_task *task), @@ -20,6 +34,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, ctf_integer(int, status, task->tk_status) ) ) +#endif LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status, TP_PROTO(struct rpc_task *task), @@ -40,8 +55,8 @@ LTTNG_TRACEPOINT_EVENT(rpc_connect_status, TP_ARGS(task), TP_FIELDS( - ctf_integer_hex(const struct rpc_task *, task, task) - ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client) + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) ctf_integer(int, status, task->tk_status) ) ) @@ -53,8 +68,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running, TP_ARGS(task, action), TP_FIELDS( - ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client) - ctf_integer_hex(const struct rpc_task *, task, task) + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) ctf_integer_hex(const void *, action, action) ctf_integer(unsigned long, runstate, task->tk_runstate) ctf_integer(int, status, task->tk_status) @@ -90,8 +105,8 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued, TP_ARGS(task, q), TP_FIELDS( - ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client) - ctf_integer_hex(const struct rpc_task *, task, task) + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) ctf_integer(unsigned long, timeout, task->tk_timeout) ctf_integer(unsigned long, runstate, task->tk_runstate) ctf_integer(int, status, task->tk_status) @@ -114,6 +129,87 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup, TP_ARGS(task, q) ) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) +LTTNG_TRACEPOINT_EVENT(rpc_connect_status, + TP_PROTO(struct rpc_task *task, int status), + + TP_ARGS(task, status), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer(int, status, status) + ) +) + +LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), + + TP_ARGS(clnt, task, action), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer_hex(const void *, action, action) + ctf_integer(unsigned long, runstate, task->tk_runstate) + ctf_integer(int, status, task->tk_status) + ctf_integer(unsigned short, flags, task->tk_flags) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_begin, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), + + TP_ARGS(clnt, task, action) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_run_action, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), + + TP_ARGS(clnt, task, action) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_running, rpc_task_complete, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), + + TP_ARGS(clnt, task, action) +) + +LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_queued, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q), + + TP_ARGS(clnt, task, q), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer(unsigned long, timeout, task->tk_timeout) + ctf_integer(unsigned long, runstate, task->tk_runstate) + ctf_integer(int, status, task->tk_status) + ctf_integer(unsigned short, flags, task->tk_flags) + ctf_string(q_name, rpc_qname(q)) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_sleep, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q), + + TP_ARGS(clnt, task, q) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup, + + TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const struct rpc_wait_queue *q), + + TP_ARGS(clnt, task, q) +) + #else LTTNG_TRACEPOINT_EVENT(rpc_connect_status, TP_PROTO(struct rpc_task *task, int status), -- 2.34.1 From d11b568681f87c2df6ecb0516d3f16d153f24bd2 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Wed, 9 Jan 2019 14:59:17 -0500 Subject: [PATCH 04/16] Fix: SUNRPC: Simplify defining common RPC trace events (v5.0) See upstream commit : commit dc5820bd21d84ee34770b0a1e2fca9378f8f7456 Author: Chuck Lever Date: Wed Dec 19 11:00:16 2018 -0500 SUNRPC: Simplify defining common RPC trace events Clean up, no functional change is expected. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/rpc.h | 99 ++++++++++++++++------- 1 file changed, 72 insertions(+), 27 deletions(-) diff --git a/instrumentation/events/lttng-module/rpc.h b/instrumentation/events/lttng-module/rpc.h index a4ac5570..4239280c 100644 --- a/instrumentation/events/lttng-module/rpc.h +++ b/instrumentation/events/lttng-module/rpc.h @@ -8,7 +8,32 @@ #include #include -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) +LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, + + TP_PROTO(const struct rpc_task *task), + + TP_ARGS(task), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer(int, status, task->tk_status) + ) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status, + TP_PROTO(const struct rpc_task *task), + + TP_ARGS(task) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status, + TP_PROTO(const struct rpc_task *task), + + TP_ARGS(task) +) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, TP_PROTO(struct rpc_task *task), @@ -21,6 +46,18 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, ctf_integer(int, status, task->tk_status) ) ) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status, + TP_PROTO(struct rpc_task *task), + + TP_ARGS(task) +) + +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status, + TP_PROTO(struct rpc_task *task), + + TP_ARGS(task) +) #else LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, @@ -34,7 +71,6 @@ LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_status, ctf_integer(int, status, task->tk_status) ) ) -#endif LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_call_status, TP_PROTO(struct rpc_task *task), @@ -47,8 +83,15 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_bind_status, TP_ARGS(task) ) +#endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) +LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_status, rpc_connect_status, + TP_PROTO(const struct rpc_task *task), + + TP_ARGS(task) +) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)) LTTNG_TRACEPOINT_EVENT(rpc_connect_status, TP_PROTO(const struct rpc_task *task), @@ -60,7 +103,33 @@ LTTNG_TRACEPOINT_EVENT(rpc_connect_status, ctf_integer(int, status, task->tk_status) ) ) +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) +LTTNG_TRACEPOINT_EVENT(rpc_connect_status, + TP_PROTO(struct rpc_task *task, int status), + + TP_ARGS(task, status), + + TP_FIELDS( + ctf_integer(unsigned int, task_id, task->tk_pid) + ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) + ctf_integer(int, status, status) + ) +) +#else +LTTNG_TRACEPOINT_EVENT(rpc_connect_status, + TP_PROTO(struct rpc_task *task, int status), + + TP_ARGS(task, status), + + TP_FIELDS( + ctf_integer_hex(const struct rpc_task *, task, task) + ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client) + ctf_integer(int, status, status) + ) +) +#endif +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,17,0)) LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running, TP_PROTO(const struct rpc_task *task, const void *action), @@ -130,18 +199,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup, ) #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,12,0)) -LTTNG_TRACEPOINT_EVENT(rpc_connect_status, - TP_PROTO(struct rpc_task *task, int status), - - TP_ARGS(task, status), - - TP_FIELDS( - ctf_integer(unsigned int, task_id, task->tk_pid) - ctf_integer(unsigned int, client_id, task->tk_client->cl_clid) - ctf_integer(int, status, status) - ) -) - LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running, TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), @@ -211,18 +268,6 @@ LTTNG_TRACEPOINT_EVENT_INSTANCE(rpc_task_queued, rpc_task_wakeup, ) #else -LTTNG_TRACEPOINT_EVENT(rpc_connect_status, - TP_PROTO(struct rpc_task *task, int status), - - TP_ARGS(task, status), - - TP_FIELDS( - ctf_integer_hex(const struct rpc_task *, task, task) - ctf_integer_hex(const struct rpc_clnt *, clnt, task->tk_client) - ctf_integer(int, status, status) - ) -) - LTTNG_TRACEPOINT_EVENT_CLASS(rpc_task_running, TP_PROTO(const struct rpc_clnt *clnt, const struct rpc_task *task, const void *action), -- 2.34.1 From 8af8245f6f86370d01cc4acaabafb90de45e143f Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 10 Jan 2019 14:56:15 -0500 Subject: [PATCH 05/16] Fix: btrfs: Remove fsid/metadata_fsid fields from btrfs_info Introduced in v5.0. See upstream commit : commit de37aa513105f864d3c21105bf5542d498f21ca2 Author: Nikolay Borisov Date: Tue Oct 30 16:43:24 2018 +0200 btrfs: Remove fsid/metadata_fsid fields from btrfs_info Currently btrfs_fs_info structure contains a copy of the fsid/metadata_uuid fields. Same values are also contained in the btrfs_fs_devices structure which fs_info has a reference to. Let's reduce duplication by removing the fields from fs_info and always refer to the ones in fs_devices. No functional changes. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- instrumentation/events/lttng-module/btrfs.h | 100 +++++++++++--------- 1 file changed, 53 insertions(+), 47 deletions(-) diff --git a/instrumentation/events/lttng-module/btrfs.h b/instrumentation/events/lttng-module/btrfs.h index 4dfbf5b3..ec45a1e1 100644 --- a/instrumentation/events/lttng-module/btrfs.h +++ b/instrumentation/events/lttng-module/btrfs.h @@ -32,6 +32,12 @@ struct extent_state; #define BTRFS_UUID_SIZE 16 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,0,0)) +#define lttng_fs_info_fsid fs_info->fs_devices->fsid +#else +#define lttng_fs_info_fsid fs_info->fsid +#endif + #if (LINUX_VERSION_CODE >= 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) || \ @@ -629,7 +635,7 @@ LTTNG_TRACEPOINT_EVENT(btrfs_add_block_group, TP_ARGS(fs_info, block_group, create), TP_FIELDS( - ctf_array(u8, fsid, fs_info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, offset, block_group->key.objectid) ctf_integer(u64, size, block_group->key.offset) ctf_integer(u64, flags, block_group->flags) @@ -647,7 +653,7 @@ LTTNG_TRACEPOINT_EVENT(btrfs_add_block_group, TP_ARGS(fs_info, block_group, create), TP_FIELDS( - ctf_array(u8, fsid, fs_info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, offset, block_group->key.objectid) ctf_integer(u64, size, block_group->key.offset) ctf_integer(u64, flags, block_group->flags) @@ -1015,18 +1021,18 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__chunk, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__chunk, btrfs_chunk_alloc, - TP_PROTO(const struct btrfs_fs_info *info, const struct map_lookup *map, + TP_PROTO(const struct btrfs_fs_info *fs_info, const struct map_lookup *map, u64 offset, u64 size), - TP_ARGS(info, map, offset, size) + TP_ARGS(fs_info, map, offset, size) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__chunk, btrfs_chunk_free, - TP_PROTO(const struct btrfs_fs_info *info, const struct map_lookup *map, + TP_PROTO(const struct btrfs_fs_info *fs_info, const struct map_lookup *map, u64 offset, u64 size), - TP_ARGS(info, map, offset, size) + TP_ARGS(fs_info, map, offset, size) ) #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) @@ -1050,18 +1056,18 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__chunk, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__chunk, btrfs_chunk_alloc, - TP_PROTO(struct btrfs_fs_info *info, struct map_lookup *map, + TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, u64 offset, u64 size), - TP_ARGS(info, map, offset, size) + TP_ARGS(fs_info, map, offset, size) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__chunk, btrfs_chunk_free, - TP_PROTO(struct btrfs_fs_info *info, struct map_lookup *map, + TP_PROTO(struct btrfs_fs_info *fs_info, struct map_lookup *map, u64 offset, u64 size), - TP_ARGS(info, map, offset, size) + TP_ARGS(fs_info, map, offset, size) ) #elif (LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ @@ -1192,7 +1198,7 @@ LTTNG_TRACEPOINT_EVENT(btrfs_space_reservation, TP_ARGS(fs_info, type, val, bytes, reserve), TP_FIELDS( - ctf_array(u8, fsid, fs_info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_string(type, type) ctf_integer(u64, val, val) ctf_integer(u64, bytes, bytes) @@ -1208,7 +1214,7 @@ LTTNG_TRACEPOINT_EVENT(btrfs_space_reservation, TP_ARGS(fs_info, type, val, bytes, reserve), TP_FIELDS( - ctf_array(u8, fsid, fs_info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_string(type, type) ctf_integer(u64, val, val) ctf_integer(u64, bytes, bytes) @@ -1221,9 +1227,9 @@ LTTNG_TRACEPOINT_EVENT(btrfs_space_reservation, LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserved_extent, - TP_PROTO(const struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len), + TP_ARGS(fs_info, start, len), TP_FIELDS( ctf_integer(u64, start, start) @@ -1233,25 +1239,25 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserved_extent, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserved_extent, btrfs_reserved_extent_alloc, - TP_PROTO(const struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len) + TP_ARGS(fs_info, start, len) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserved_extent, btrfs_reserved_extent_free, - TP_PROTO(const struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(const struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len) + TP_ARGS(fs_info, start, len) ) #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserved_extent, - TP_PROTO(struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len), + TP_ARGS(fs_info, start, len), TP_FIELDS( ctf_integer(u64, start, start) @@ -1261,16 +1267,16 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserved_extent, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserved_extent, btrfs_reserved_extent_alloc, - TP_PROTO(struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len) + TP_ARGS(fs_info, start, len) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserved_extent, btrfs_reserved_extent_free, - TP_PROTO(struct btrfs_fs_info *info, u64 start, u64 len), + TP_PROTO(struct btrfs_fs_info *fs_info, u64 start, u64 len), - TP_ARGS(info, start, len) + TP_ARGS(fs_info, start, len) ) #elif (LTTNG_SLE_KERNEL_RANGE(4,4,73,5,0,0, 4,4,73,6,0,0) || \ @@ -1341,13 +1347,13 @@ LTTNG_TRACEPOINT_EVENT_MAP(find_free_extent, btrfs_find_free_extent, - TP_PROTO(const struct btrfs_fs_info *info, u64 num_bytes, u64 empty_size, + TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size, u64 data), - TP_ARGS(info, num_bytes, empty_size, data), + TP_ARGS(fs_info, num_bytes, empty_size, data), TP_FIELDS( - ctf_array(u8, fsid, info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, num_bytes, num_bytes) ctf_integer(u64, empty_size, empty_size) ctf_integer(u64, data, data) @@ -1362,7 +1368,7 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserve_extent, TP_ARGS(block_group, start, len), TP_FIELDS( - ctf_array(u8, fsid, block_group->fs_info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, block_group->lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, bg_objectid, block_group->key.objectid) ctf_integer(u64, flags, block_group->flags) ctf_integer(u64, start, start) @@ -1391,13 +1397,13 @@ LTTNG_TRACEPOINT_EVENT_MAP(find_free_extent, btrfs_find_free_extent, - TP_PROTO(const struct btrfs_fs_info *info, u64 num_bytes, u64 empty_size, + TP_PROTO(const struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size, u64 data), - TP_ARGS(info, num_bytes, empty_size, data), + TP_ARGS(fs_info, num_bytes, empty_size, data), TP_FIELDS( - ctf_array(u8, fsid, info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, num_bytes, num_bytes) ctf_integer(u64, empty_size, empty_size) ctf_integer(u64, data, data) @@ -1406,14 +1412,14 @@ LTTNG_TRACEPOINT_EVENT_MAP(find_free_extent, LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserve_extent, - TP_PROTO(const struct btrfs_fs_info *info, + TP_PROTO(const struct btrfs_fs_info *fs_info, const struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len), + TP_ARGS(fs_info, block_group, start, len), TP_FIELDS( - ctf_array(u8, fsid, info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, bg_objectid, block_group->key.objectid) ctf_integer(u64, flags, block_group->flags) ctf_integer(u64, start, start) @@ -1423,20 +1429,20 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserve_extent, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserve_extent, btrfs_reserve_extent, - TP_PROTO(const struct btrfs_fs_info *info, + TP_PROTO(const struct btrfs_fs_info *fs_info, const struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len) + TP_ARGS(fs_info, block_group, start, len) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserve_extent, btrfs_reserve_extent_cluster, - TP_PROTO(const struct btrfs_fs_info *info, + TP_PROTO(const struct btrfs_fs_info *fs_info, const struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len) + TP_ARGS(fs_info, block_group, start, len) ) #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,10,0)) @@ -1445,13 +1451,13 @@ LTTNG_TRACEPOINT_EVENT_MAP(find_free_extent, btrfs_find_free_extent, - TP_PROTO(struct btrfs_fs_info *info, u64 num_bytes, u64 empty_size, + TP_PROTO(struct btrfs_fs_info *fs_info, u64 num_bytes, u64 empty_size, u64 data), - TP_ARGS(info, num_bytes, empty_size, data), + TP_ARGS(fs_info, num_bytes, empty_size, data), TP_FIELDS( - ctf_array(u8, fsid, info->fsid, BTRFS_UUID_SIZE) + ctf_array(u8, fsid, lttng_fs_info_fsid, BTRFS_UUID_SIZE) ctf_integer(u64, num_bytes, num_bytes) ctf_integer(u64, empty_size, empty_size) ctf_integer(u64, data, data) @@ -1460,11 +1466,11 @@ LTTNG_TRACEPOINT_EVENT_MAP(find_free_extent, LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserve_extent, - TP_PROTO(struct btrfs_fs_info *info, + TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len), + TP_ARGS(fs_info, block_group, start, len), TP_FIELDS( ctf_integer(u64, bg_objectid, block_group->key.objectid) @@ -1476,20 +1482,20 @@ LTTNG_TRACEPOINT_EVENT_CLASS(btrfs__reserve_extent, LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserve_extent, btrfs_reserve_extent, - TP_PROTO(struct btrfs_fs_info *info, + TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len) + TP_ARGS(fs_info, block_group, start, len) ) LTTNG_TRACEPOINT_EVENT_INSTANCE(btrfs__reserve_extent, btrfs_reserve_extent_cluster, - TP_PROTO(struct btrfs_fs_info *info, + TP_PROTO(struct btrfs_fs_info *fs_info, struct btrfs_block_group_cache *block_group, u64 start, u64 len), - TP_ARGS(info, block_group, start, len) + TP_ARGS(fs_info, block_group, start, len) ) #elif (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) || \ -- 2.34.1 From 416cee8707053a9015dfec8332e12f8c263098e3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 14 Feb 2019 11:40:50 -0500 Subject: [PATCH 06/16] Cleanup: tp mempool: Remove logically dead code Found by Coverity: CID 1391045 (#1 of 1): Logically dead code (DEADCODE) Signed-off-by: Mathieu Desnoyers --- lttng-tp-mempool.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/lttng-tp-mempool.c b/lttng-tp-mempool.c index d984bd45..21e8376c 100644 --- a/lttng-tp-mempool.c +++ b/lttng-tp-mempool.c @@ -151,19 +151,12 @@ void lttng_tp_mempool_free(void *ptr) struct lttng_tp_buf_entry *entry; struct per_cpu_buf *cpu_buf; - if (!ptr) { + if (!ptr) goto end; - } - entry = container_of(ptr, struct lttng_tp_buf_entry, buf); - if (!entry) { - goto end; - } - cpu_buf = per_cpu_ptr(pool, entry->cpu); - if (!cpu_buf) { + if (!cpu_buf) goto end; - } /* Add it to the free list. */ list_add_tail(&entry->list, &cpu_buf->free_list); -- 2.34.1 From 2d16de12b197aed57212826187bcb0ab24ad071e Mon Sep 17 00:00:00 2001 From: Jonathan Rajotte Date: Thu, 7 Mar 2019 14:57:59 -0500 Subject: [PATCH 07/16] Blacklist: kprobe for arm This upstream kernel commit broke optimized kprobe. commit e46daee53bb50bde38805f1823a182979724c229 Author: Kees Cook Date: Tue Oct 30 22:12:56 2018 +0100 ARM: 8806/1: kprobes: Fix false positive with FORTIFY_SOURCE The arm compiler internally interprets an inline assembly label as an unsigned long value, not a pointer. As a result, under CONFIG_FORTIFY_SOURCE, the address of a label has a size of 4 bytes, which was tripping the runtime checks. Instead, we can just cast the label (as done with the size calculations earlier). Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1639397 Reported-by: William Cohen Fixes: 6974f0c4555e ("include/linux/string.h: add the option of fortified string.h functions") Cc: stable@vger.kernel.org Acked-by: Laura Abbott Acked-by: Masami Hiramatsu Tested-by: William Cohen Signed-off-by: Kees Cook Signed-off-by: Russell King It was introduced in the 4.20 cycle. It was also backported to the 4.19 and 4.14 branch. This issue is fixed upstream by [1] and is present in the 5.0 kernel release. [1] 0ac569bf6a7983c0c5747d6df8db9dc05bc92b6c The fix was backported to 4.20, 4.19 and 4.14 branch. It is included starting at: v5.0.0 v4.20.13 v4.19.26 v4.14.104 Fixes #1174 Signed-off-by: Jonathan Rajotte Signed-off-by: Mathieu Desnoyers --- blacklist/kprobes.h | 23 +++++++++++++++++++++++ probes/lttng-kprobes.c | 1 + probes/lttng-kretprobes.c | 1 + 3 files changed, 25 insertions(+) create mode 100644 blacklist/kprobes.h diff --git a/blacklist/kprobes.h b/blacklist/kprobes.h new file mode 100644 index 00000000..6c1d7a53 --- /dev/null +++ b/blacklist/kprobes.h @@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1) + * + * blacklist/kprobes.h + * + * Blacklist of kernel for buggy kprobes implementation. + * + * Copyright (C) 2019 Jonathan Rajotte-Julien + */ + +#ifndef _LTTNG_BLACKLIST_KPROBES_H +#define _LTTNG_BLACKLIST_KPROBES_H + +#include + +#if LTTNG_KERNEL_RANGE(4,20,0, 4,20,13) \ + || LTTNG_KERNEL_RANGE(4,19,9, 4,19,26) \ + || LTTNG_KERNEL_RANGE(4,14,87, 4,14,104) +# if defined(CONFIG_ARM) && defined(CONFIG_OPTPROBES) +# error "Your kernel is known to have buggy optimized kprobes implementation. Fixed by commit 0ac569bf6a7983c0c5747d6df8db9dc05bc92b6c \"ARM: 8834/1: Fix: kprobes: optimized kprobes illegal instruction\" in Linux. Disable CONFIG_OPTPROBES or upgrade your kernel." +# endif /* #if defined(CONFIG_ARM) && defined(CONFIG_OPTPROBES) */ +#endif + +#endif /* _LTTNG_BLACKLIST_KPROBES_H */ diff --git a/probes/lttng-kprobes.c b/probes/lttng-kprobes.c index b58a09b4..6d2038e7 100644 --- a/probes/lttng-kprobes.c +++ b/probes/lttng-kprobes.c @@ -28,6 +28,7 @@ #include #include #include +#include static int lttng_kprobes_handler_pre(struct kprobe *p, struct pt_regs *regs) diff --git a/probes/lttng-kretprobes.c b/probes/lttng-kretprobes.c index 49b7de82..307e6777 100644 --- a/probes/lttng-kretprobes.c +++ b/probes/lttng-kretprobes.c @@ -29,6 +29,7 @@ #include #include #include +#include enum lttng_kretprobe_type { EVENT_ENTRY = 0, -- 2.34.1 From 7dc3141177fff50aff4c0f7d90f36436398361b4 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 12 Mar 2019 12:13:49 -0400 Subject: [PATCH 08/16] Version 2.10.9 Signed-off-by: Mathieu Desnoyers --- ChangeLog | 12 ++++++++++++ lttng-tracer.h | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ee686327..942f1288 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2019-03-12 (Homer Simpson Birthday) LTTng modules 2.10.9 + * Blacklist: kprobe for arm + * Cleanup: tp mempool: Remove logically dead code + * Fix: btrfs: Remove fsid/metadata_fsid fields from btrfs_info + * Fix: SUNRPC: Simplify defining common RPC trace events (v5.0) + * Fix: Replace pointer values with task->tk_pid and rpc_clnt->cl_clid + * Fix: Remove 'type' argument from access_ok() function (v5.0) + * Fix: timer instrumentation for RHEL 7.6 + * Fix: ext4: adjust reserved cluster count when removing extents (v4.20) + * Fix: signal: Remove SEND_SIG_FORCED (v4.20) + * Fix: signal: Distinguish between kernel_siginfo and siginfo (v4.20) + 2018-11-01 (National Men Make Dinner Day) LTTng modules 2.10.8 * Fix: update kvm instrumentation for SLES12 SP2 LTSS >= 4.4.121-92.92 * Fix: Add missing const to lttng_tracepoint_ptr_deref prototype diff --git a/lttng-tracer.h b/lttng-tracer.h index c9f4769d..18a0c60e 100644 --- a/lttng-tracer.h +++ b/lttng-tracer.h @@ -42,7 +42,7 @@ #define LTTNG_MODULES_MAJOR_VERSION 2 #define LTTNG_MODULES_MINOR_VERSION 10 -#define LTTNG_MODULES_PATCHLEVEL_VERSION 8 +#define LTTNG_MODULES_PATCHLEVEL_VERSION 9 #define LTTNG_MODULES_EXTRAVERSION "" #define LTTNG_VERSION_NAME "KeKriek" -- 2.34.1 From 80f8783b611cc11e5cad9ad40173b4ee3538ca1c Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 15 Mar 2019 11:13:39 -0400 Subject: [PATCH 09/16] Fix: extra-version-git.sh redirect stderr to /dev/null Running make in a git repo that does not contain any tag prints: fatal: No names found, cannot describe anything. in the make and make clean outputs. It's fine to have no tag name available (extra-version-git.sh will return the value 0), but we should not print an error in the make output. Redirect this error to /dev/null. Signed-off-by: Mathieu Desnoyers Suggested-by: Michael Jeanson --- extra-version-git.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra-version-git.sh b/extra-version-git.sh index e5a3e176..0f1a9857 100755 --- a/extra-version-git.sh +++ b/extra-version-git.sh @@ -7,7 +7,7 @@ TOP_LTTNG_MODULES_DIR="$1" GIT_VERSION="0" if test -x "$(which git 2>&1;true)" && test -r "${TOP_LTTNG_MODULES_DIR}/.git"; then - GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty)" + GIT_VERSION_STR="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --dirty 2> /dev/null)" GIT_CURRENT_TAG="$(cd "${TOP_LTTNG_MODULES_DIR}" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null)" GIT_VERSION="${GIT_VERSION_STR}" -- 2.34.1 From 21b373831ce9c022d379c3a53acc301541b73292 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 18 Mar 2019 16:20:32 -0400 Subject: [PATCH 10/16] Fix: mm: create the new vm_fault_t type (v5.1) See upstream commit: commit 3d3539018d2cbd12e5af4a132636ee7fd8d43ef0 Author: Souptick Joarder Date: Thu Mar 7 16:31:14 2019 -0800 mm: create the new vm_fault_t type Page fault handlers are supposed to return VM_FAULT codes, but some drivers/file systems mistakenly return error numbers. Now that all drivers/file systems have been converted to use the vm_fault_t return type, change the type definition to no longer be compatible with 'int'. By making it an unsigned int, the function prototype becomes incompatible with a function which returns int. Sparse will detect any attempts to return a value which is not a VM_FAULT code. VM_FAULT_SET_HINDEX and VM_FAULT_GET_HINDEX values are changed to avoid conflict with other VM_FAULT codes. Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/ring_buffer_mmap.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ringbuffer/ring_buffer_mmap.c b/lib/ringbuffer/ring_buffer_mmap.c index 4b1b7b31..6592a824 100644 --- a/lib/ringbuffer/ring_buffer_mmap.c +++ b/lib/ringbuffer/ring_buffer_mmap.c @@ -32,7 +32,11 @@ /* * fault() vm_op implementation for ring buffer file mapping. */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) +static vm_fault_t lib_ring_buffer_fault_compat(struct vm_area_struct *vma, struct vm_fault *vmf) +#else static int lib_ring_buffer_fault_compat(struct vm_area_struct *vma, struct vm_fault *vmf) +#endif { struct lib_ring_buffer *buf = vma->vm_private_data; struct channel *chan = buf->backend.chan; @@ -65,7 +69,13 @@ static int lib_ring_buffer_fault_compat(struct vm_area_struct *vma, struct vm_fa return 0; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) +static vm_fault_t lib_ring_buffer_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + return lib_ring_buffer_fault_compat(vma, vmf); +} +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4,11,0)) static int lib_ring_buffer_fault(struct vm_fault *vmf) { struct vm_area_struct *vma = vmf->vma; -- 2.34.1 From 06980203105c37bc9fd10ef93bb290d92c475545 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 18 Mar 2019 16:20:33 -0400 Subject: [PATCH 11/16] Fix: rcu: Remove wrapper definitions for obsolete RCU... (v5.1) See upstream commit : commit 6ba7d681aca22e53385bdb35b1d7662e61905760 Author: Paul E. McKenney Date: Wed Jan 9 15:22:03 2019 -0800 rcu: Remove wrapper definitions for obsolete RCU update functions None of synchronize_rcu_bh, synchronize_rcu_bh_expedited, call_rcu_bh, rcu_barrier_bh, synchronize_sched, synchronize_sched_expedited, call_rcu_sched, rcu_barrier_sched, get_state_synchronize_sched, and cond_synchronize_sched are actually used. This commit therefore removes their trivial wrapper-function definitions. Signed-off-by: Mathieu Desnoyers --- lttng-events.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lttng-events.c b/lttng-events.c index 47431ca9..3481bd41 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -89,7 +89,12 @@ int _lttng_field_statedump(struct lttng_session *session, void synchronize_trace(void) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) + synchronize_rcu(); +#else synchronize_sched(); +#endif + #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0)) #ifdef CONFIG_PREEMPT_RT_FULL synchronize_rcu(); -- 2.34.1 From 332bbef53824f38f48a71080f2171410470b2b5f Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 18 Mar 2019 16:20:34 -0400 Subject: [PATCH 12/16] Fix: pipe: stop using ->can_merge (v5.1) See upstream commit: commit 01e7187b41191376cee8bea8de9f907b001e87b4 Author: Jann Horn Date: Wed Jan 23 15:19:18 2019 +0100 pipe: stop using ->can_merge Al Viro pointed out that since there is only one pipe buffer type to which new data can be appended, it isn't necessary to have a ->can_merge field in struct pipe_buf_operations, we can just check for a magic type. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/ring_buffer_splice.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ringbuffer/ring_buffer_splice.c b/lib/ringbuffer/ring_buffer_splice.c index 8d146667..93cad295 100644 --- a/lib/ringbuffer/ring_buffer_splice.c +++ b/lib/ringbuffer/ring_buffer_splice.c @@ -56,7 +56,9 @@ static void lib_ring_buffer_pipe_buf_release(struct pipe_inode_info *pipe, } static const struct pipe_buf_operations ring_buffer_pipe_buf_ops = { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,1,0)) .can_merge = 0, +#endif #if (LINUX_VERSION_CODE < KERNEL_VERSION(3,15,0)) .map = generic_pipe_buf_map, .unmap = generic_pipe_buf_unmap, -- 2.34.1 From 8af1abdc9576e807a15766e8faaadd7010c906ab Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 18 Mar 2019 16:20:35 -0400 Subject: [PATCH 13/16] Fix: Revert "KVM: MMU: show mmu_valid_gen..." (v5.1) See upstream commit : commit b59c4830ca185ba0e9f9e046fb1cd10a4a92627a Author: Sean Christopherson Date: Tue Feb 5 13:01:30 2019 -0800 Revert "KVM: MMU: show mmu_valid_gen in shadow page related tracepoints" ...as part of removing x86 KVM's fast invalidate mechanism, i.e. this is one part of a revert all patches from the series that introduced the mechanism[1]. This reverts commit 2248b023219251908aedda0621251cffc548f258. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- .../events/lttng-module/arch/x86/kvm/mmutrace.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h b/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h index e3f7abd5..71e8b344 100644 --- a/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h +++ b/instrumentation/events/lttng-module/arch/x86/kvm/mmutrace.h @@ -13,7 +13,15 @@ #undef TRACE_SYSTEM #define TRACE_SYSTEM kvm_mmu -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,1,0)) + +#define LTTNG_KVM_MMU_PAGE_FIELDS \ + ctf_integer(__u64, gfn, (sp)->gfn) \ + ctf_integer(__u32, role, (sp)->role.word) \ + ctf_integer(__u32, root_count, (sp)->root_count) \ + ctf_integer(bool, unsync, (sp)->unsync) + +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3,11,0)) #define LTTNG_KVM_MMU_PAGE_FIELDS \ ctf_integer(unsigned long, mmu_valid_gen, (sp)->mmu_valid_gen) \ -- 2.34.1 From afbee416289de1de537ae0992e05ac14f85f69fd Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 18 Mar 2019 16:20:36 -0400 Subject: [PATCH 14/16] Fix: atomic_long_add_unless() returns a boolean Because of a documentation error in older kernels, it was assumed that atomic_long_add_unless would return the old value, but the implementation actually returns a boolean. Also add missing error code int 'ret' and compare against the right type max value. Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- lttng-abi.c | 7 +++---- lttng-events.c | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lttng-abi.c b/lttng-abi.c index a57e5e9f..223c1ee4 100644 --- a/lttng-abi.c +++ b/lttng-abi.c @@ -430,8 +430,8 @@ int lttng_abi_create_channel(struct file *session_file, transport_name = ""; break; } - if (atomic_long_add_unless(&session_file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&session_file->f_count, 1, LONG_MAX)) { + ret = -EOVERFLOW; goto refcount_error; } /* @@ -1039,8 +1039,7 @@ int lttng_abi_create_event(struct file *channel_file, goto file_error; } /* The event holds a reference on the channel */ - if (atomic_long_add_unless(&channel_file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&channel_file->f_count, 1, LONG_MAX)) { ret = -EOVERFLOW; goto refcount_error; } diff --git a/lttng-events.c b/lttng-events.c index 3481bd41..ee0e7f90 100644 --- a/lttng-events.c +++ b/lttng-events.c @@ -1122,8 +1122,8 @@ int lttng_session_list_tracker_pids(struct lttng_session *session) ret = PTR_ERR(tracker_pids_list_file); goto file_error; } - if (atomic_long_add_unless(&session->file->f_count, - 1, INT_MAX) == INT_MAX) { + if (!atomic_long_add_unless(&session->file->f_count, 1, LONG_MAX)) { + ret = -EOVERFLOW; goto refcount_error; } ret = lttng_tracker_pids_list_fops.open(NULL, tracker_pids_list_file); -- 2.34.1 From 43bd70bc9e00729ddf3825bba326b221b20a653f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 30 May 2018 02:11:43 +0200 Subject: [PATCH 15/16] Implement ring buffer clear Signed-off-by: Mathieu Desnoyers --- lib/ringbuffer/frontend_internal.h | 26 ++++++++++++++++++++++++++ lib/ringbuffer/ring_buffer_frontend.c | 10 ++++++++++ lib/ringbuffer/ring_buffer_vfs.c | 6 ++++++ lib/ringbuffer/vfs.h | 10 ++++++++++ 4 files changed, 52 insertions(+) diff --git a/lib/ringbuffer/frontend_internal.h b/lib/ringbuffer/frontend_internal.h index f143ecae..adda26c7 100644 --- a/lib/ringbuffer/frontend_internal.h +++ b/lib/ringbuffer/frontend_internal.h @@ -169,6 +169,8 @@ extern void lib_ring_buffer_switch_remote(struct lib_ring_buffer *buf); extern void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf); +extern +void lib_ring_buffer_clear(struct lib_ring_buffer *buf); /* Buffer write helpers */ @@ -200,6 +202,30 @@ void lib_ring_buffer_reserve_push_reader(struct lib_ring_buffer *buf, consumed_new) != consumed_old)); } +/* + * Move consumed position to the beginning of subbuffer in which the + * write offset is. + */ +static inline +void lib_ring_buffer_clear_reader(struct lib_ring_buffer *buf, + struct channel *chan) +{ + const struct lib_ring_buffer_config *config = &chan->backend.config; + unsigned long offset, consumed_old, consumed_new; + + do { + offset = v_read(config, &buf->offset); + consumed_old = atomic_long_read(&buf->consumed); + if (unlikely(subbuf_trunc(offset, chan) + - subbuf_trunc(consumed_old, chan) + > 0)) + consumed_new = subbuf_trunc(offset, chan); + else + return; + } while (unlikely(atomic_long_cmpxchg(&buf->consumed, consumed_old, + consumed_new) != consumed_old)); +} + static inline int lib_ring_buffer_pending_data(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, diff --git a/lib/ringbuffer/ring_buffer_frontend.c b/lib/ringbuffer/ring_buffer_frontend.c index 4a8919b3..cd94bbb7 100644 --- a/lib/ringbuffer/ring_buffer_frontend.c +++ b/lib/ringbuffer/ring_buffer_frontend.c @@ -1917,6 +1917,16 @@ void lib_ring_buffer_switch_remote_empty(struct lib_ring_buffer *buf) } EXPORT_SYMBOL_GPL(lib_ring_buffer_switch_remote_empty); +void lib_ring_buffer_clear(struct lib_ring_buffer *buf) +{ + struct lib_ring_buffer_backend *bufb = &buf->backend; + struct channel *chan = bufb->chan; + + lib_ring_buffer_switch_remote(buf); + lib_ring_buffer_clear_reader(buf, chan); +} +EXPORT_SYMBOL_GPL(lib_ring_buffer_clear); + /* * Returns : * 0 if ok diff --git a/lib/ringbuffer/ring_buffer_vfs.c b/lib/ringbuffer/ring_buffer_vfs.c index 97be8356..8f83c856 100644 --- a/lib/ringbuffer/ring_buffer_vfs.c +++ b/lib/ringbuffer/ring_buffer_vfs.c @@ -276,6 +276,9 @@ long lib_ring_buffer_ioctl(struct file *filp, unsigned int cmd, case RING_BUFFER_FLUSH_EMPTY: lib_ring_buffer_switch_remote_empty(buf); return 0; + case RING_BUFFER_CLEAR: + lib_ring_buffer_clear(buf); + return 0; default: return -ENOIOCTLCMD; } @@ -427,6 +430,9 @@ long lib_ring_buffer_compat_ioctl(struct file *filp, unsigned int cmd, case RING_BUFFER_COMPAT_FLUSH_EMPTY: lib_ring_buffer_switch_remote_empty(buf); return 0; + case RING_BUFFER_COMPAT_CLEAR: + lib_ring_buffer_clear(buf); + return 0; default: return -ENOIOCTLCMD; } diff --git a/lib/ringbuffer/vfs.h b/lib/ringbuffer/vfs.h index b2e5b1c8..07e51ba2 100644 --- a/lib/ringbuffer/vfs.h +++ b/lib/ringbuffer/vfs.h @@ -123,6 +123,13 @@ ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos, #define RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS _IO(0xF6, 0x0E) /* Flush the current sub-buffer, even if empty. */ #define RING_BUFFER_FLUSH_EMPTY _IO(0xF6, 0x0F) +/* + * Reset the position of what has been consumed from the metadata cache to 0 + * so it can be read again. + */ +#define RING_BUFFER_METADATA_CACHE_DUMP _IO(0xF6, 0x10) +/* Clear ring buffer content. */ +#define RING_BUFFER_CLEAR _IO(0xF6, 0x11) #ifdef CONFIG_COMPAT /* Get a snapshot of the current ring buffer producer and consumer positions */ @@ -167,6 +174,9 @@ ssize_t vfs_lib_ring_buffer_splice_read(struct file *in, loff_t *ppos, /* Flush the current sub-buffer, even if empty. */ #define RING_BUFFER_COMPAT_FLUSH_EMPTY \ RING_BUFFER_FLUSH_EMPTY +/* Clear ring buffer content. */ +#define RING_BUFFER_COMPAT_CLEAR \ + RING_BUFFER_CLEAR #endif /* CONFIG_COMPAT */ #endif /* _LIB_RING_BUFFER_VFS_H */ -- 2.34.1 From 509c3da905302a1ffb6ad0fa6e367a08b4d3fbaa Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 10 Apr 2019 10:48:57 -0400 Subject: [PATCH 16/16] Fix: don't access packet header for stream_id and stream_instance_id getters The stream ID and stream instance ID are invariant for a stream, so there is no point reading them from the packet header currently owned by the consumer (between get/put subbuf). Actually, the consumer try to access the stream_id from the live timer when sending a live beacon without getting the reader subbuffer first, which can trigger WARN_ON safety nets in libringbuffer. This safety net triggers a kernel OOPS report and disables tracing for that channel. In the case where a ring buffer does not have any data ready, it makes no sense to try to get a subbuffer for reading anyway, so the approach was broken. So return the stream id and stream instance id from the internal data structures rather than reading it from the ring buffer. Signed-off-by: Mathieu Desnoyers --- lttng-ring-buffer-client.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lttng-ring-buffer-client.h b/lttng-ring-buffer-client.h index 63f2b4ca..8916ab02 100644 --- a/lttng-ring-buffer-client.h +++ b/lttng-ring-buffer-client.h @@ -464,9 +464,10 @@ static int client_stream_id(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, uint64_t *stream_id) { - struct packet_header *header = client_packet_header(config, buf); - *stream_id = header->stream_id; + struct channel *chan = buf->backend.chan; + struct lttng_channel *lttng_chan = channel_get_private(chan); + *stream_id = lttng_chan->id; return 0; } @@ -495,8 +496,7 @@ int client_instance_id(const struct lib_ring_buffer_config *config, struct lib_ring_buffer *buf, uint64_t *id) { - struct packet_header *header = client_packet_header(config, buf); - *id = header->stream_instance_id; + *id = buf->backend.cpu; return 0; } -- 2.34.1