linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	"Steven Rostedt (VMware)" <rostedt@goodmis.org>
Subject: [PATCH 4.16 19/47] tracing: Make the snapshot trigger work with instances
Date: Mon,  4 Jun 2018 08:58:31 +0200	[thread overview]
Message-ID: <20180604065550.302266366@linuxfoundation.org> (raw)
In-Reply-To: <20180604065549.468488465@linuxfoundation.org>

4.16-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

commit 2824f5033248600673e3e126a4d135363cbfd9ac upstream.

The snapshot trigger currently only affects the main ring buffer, even when
it is used by the instances. This can be confusing as the snapshot trigger
is listed in the instance.

 > # cd /sys/kernel/tracing
 > # mkdir instances/foo
 > # echo snapshot > instances/foo/events/syscalls/sys_enter_fchownat/trigger
 > # echo top buffer > trace_marker
 > # echo foo buffer > instances/foo/trace_marker
 > # touch /tmp/bar
 > # chown rostedt /tmp/bar
 > # cat instances/foo/snapshot
 # tracer: nop
 #
 #
 # * Snapshot is freed *
 #
 # Snapshot commands:
 # echo 0 > snapshot : Clears and frees snapshot buffer
 # echo 1 > snapshot : Allocates snapshot buffer, if not already allocated.
 #                      Takes a snapshot of the main buffer.
 # echo 2 > snapshot : Clears snapshot buffer (but does not allocate or free)
 #                      (Doesn't have to be '2' works with any number that
 #                       is not a '0' or '1')

 > # cat snapshot
 # tracer: nop
 #
 #                              _-----=> irqs-off
 #                             / _----=> need-resched
 #                            | / _---=> hardirq/softirq
 #                            || / _--=> preempt-depth
 #                            ||| /     delay
 #           TASK-PID   CPU#  ||||    TIMESTAMP  FUNCTION
 #              | |       |   ||||       |         |
             bash-1189  [000] ....   111.488323: tracing_mark_write: top buffer

Not only did the snapshot occur in the top level buffer, but the instance
snapshot buffer should have been allocated, and it is still free.

Cc: stable@vger.kernel.org
Fixes: 85f2b08268c01 ("tracing: Add basic event trigger framework")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/trace/trace.c                |   12 ++++++------
 kernel/trace/trace.h                |   11 +++++++++++
 kernel/trace/trace_events_trigger.c |   10 ++++++++--
 3 files changed, 25 insertions(+), 8 deletions(-)

--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -892,7 +892,7 @@ int __trace_bputs(unsigned long ip, cons
 EXPORT_SYMBOL_GPL(__trace_bputs);
 
 #ifdef CONFIG_TRACER_SNAPSHOT
-static void tracing_snapshot_instance(struct trace_array *tr)
+void tracing_snapshot_instance(struct trace_array *tr)
 {
 	struct tracer *tracer = tr->current_trace;
 	unsigned long flags;
@@ -948,7 +948,7 @@ static int resize_buffer_duplicate_size(
 					struct trace_buffer *size_buf, int cpu_id);
 static void set_buffer_entries(struct trace_buffer *buf, unsigned long val);
 
-static int alloc_snapshot(struct trace_array *tr)
+int tracing_alloc_snapshot_instance(struct trace_array *tr)
 {
 	int ret;
 
@@ -994,7 +994,7 @@ int tracing_alloc_snapshot(void)
 	struct trace_array *tr = &global_trace;
 	int ret;
 
-	ret = alloc_snapshot(tr);
+	ret = tracing_alloc_snapshot_instance(tr);
 	WARN_ON(ret < 0);
 
 	return ret;
@@ -5395,7 +5395,7 @@ static int tracing_set_tracer(struct tra
 
 #ifdef CONFIG_TRACER_MAX_TRACE
 	if (t->use_max_tr && !had_max_tr) {
-		ret = alloc_snapshot(tr);
+		ret = tracing_alloc_snapshot_instance(tr);
 		if (ret < 0)
 			goto out;
 	}
@@ -6373,7 +6373,7 @@ tracing_snapshot_write(struct file *filp
 		}
 #endif
 		if (!tr->allocated_snapshot) {
-			ret = alloc_snapshot(tr);
+			ret = tracing_alloc_snapshot_instance(tr);
 			if (ret < 0)
 				break;
 		}
@@ -7094,7 +7094,7 @@ ftrace_trace_snapshot_callback(struct tr
 		return ret;
 
  out_reg:
-	ret = alloc_snapshot(tr);
+	ret = tracing_alloc_snapshot_instance(tr);
 	if (ret < 0)
 		goto out;
 
--- a/kernel/trace/trace.h
+++ b/kernel/trace/trace.h
@@ -1812,6 +1812,17 @@ static inline void __init trace_event_in
 static inline void trace_event_eval_update(struct trace_eval_map **map, int len) { }
 #endif
 
+#ifdef CONFIG_TRACER_SNAPSHOT
+void tracing_snapshot_instance(struct trace_array *tr);
+int tracing_alloc_snapshot_instance(struct trace_array *tr);
+#else
+static inline void tracing_snapshot_instance(struct trace_array *tr) { }
+static inline int tracing_alloc_snapshot_instance(struct trace_array *tr)
+{
+	return 0;
+}
+#endif
+
 extern struct trace_iterator *tracepoint_print_iter;
 
 #endif /* _LINUX_KERNEL_TRACE_H */
--- a/kernel/trace/trace_events_trigger.c
+++ b/kernel/trace/trace_events_trigger.c
@@ -642,6 +642,7 @@ event_trigger_callback(struct event_comm
 	trigger_data->count = -1;
 	trigger_data->ops = trigger_ops;
 	trigger_data->cmd_ops = cmd_ops;
+	trigger_data->private_data = file;
 	INIT_LIST_HEAD(&trigger_data->list);
 	INIT_LIST_HEAD(&trigger_data->named_list);
 
@@ -1042,7 +1043,12 @@ static struct event_command trigger_trac
 static void
 snapshot_trigger(struct event_trigger_data *data, void *rec)
 {
-	tracing_snapshot();
+	struct trace_event_file *file = data->private_data;
+
+	if (file)
+		tracing_snapshot_instance(file->tr);
+	else
+		tracing_snapshot();
 }
 
 static void
@@ -1064,7 +1070,7 @@ register_snapshot_trigger(char *glob, st
 {
 	int ret = register_trigger(glob, ops, data, file);
 
-	if (ret > 0 && tracing_alloc_snapshot() != 0) {
+	if (ret > 0 && tracing_alloc_snapshot_instance(file->tr) != 0) {
 		unregister_trigger(glob, ops, data, file);
 		ret = 0;
 	}

  parent reply	other threads:[~2018-06-04  7:03 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04  6:58 [PATCH 4.16 00/47] 4.16.14-stable review Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 01/47] objtool: Support GCC 8s cold subfunctions Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 02/47] objtool: Support GCC 8 switch tables Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 03/47] objtool: Detect RIP-relative switch table references Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 04/47] objtool: Detect RIP-relative switch table references, part 2 Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 05/47] objtool: Fix "noreturn" detection for recursive sibling calls Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 06/47] x86/mce/AMD: Carve out SMCA get_block_address() code Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 07/47] x86/MCE/AMD: Cache SMCA MISC block addresses Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 08/47] drm/vmwgfx: Use kasprintf Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 09/47] drm/vmwgfx: Fix host logging / guestinfo reading error paths Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 10/47] Revert "pinctrl: msm: Use dynamic GPIO numbering" Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 11/47] xfs: convert XFS_AGFL_SIZE to a helper function Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 12/47] xfs: detect agfl count corruption and reset agfl Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 13/47] Input: synaptics - Lenovo Carbon X1 Gen5 (2017) devices should use RMI Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 14/47] Input: synaptics - Lenovo Thinkpad X1 Carbon G5 (2017) with Elantech trackpoints " Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 15/47] Input: synaptics - add Intertouch support on X1 Carbon 6th and X280 Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 16/47] Input: synaptics - add Lenovo 80 series ids to SMBus Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 17/47] Input: elan_i2c_smbus - fix corrupted stack Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 18/47] tracing: Fix crash when freeing instances with event triggers Greg Kroah-Hartman
2018-06-04  6:58 ` Greg Kroah-Hartman [this message]
2018-06-04  6:58 ` [PATCH 4.16 20/47] nvme: fix extended data LBA supported setting Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 21/47] selinux: KASAN: slab-out-of-bounds in xattr_getsecurity Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 22/47] cfg80211: further limit wiphy names to 64 bytes Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 23/47] drm/amd/powerplay: Fix enum mismatch Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 24/47] rtlwifi: rtl8192cu: Remove variable self-assignment in rf.c Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 25/47] iio: ad7793: implement IIO_CHAN_INFO_SAMP_FREQ Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 26/47] iio: hid-sensor-trigger: Fix sometimes not powering up the sensor after resume Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 27/47] iio:buffer: make length types match kfifo types Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 28/47] iio:kfifo_buf: check for uint overflow Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 29/47] iio: adc: stm32-dfsdm: fix successive oversampling settings Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 30/47] iio: adc: stm32-dfsdm: fix sample rate for div2 spi clock Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 31/47] iio: adc: at91-sama5d2_adc: fix channel configuration for differential channels Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 32/47] iio: adc: select buffer for at91-sama5d2_adc Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 33/47] MIPS: lantiq: gphy: Drop reboot/remove reset asserts Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 34/47] MIPS: ptrace: Fix PTRACE_PEEKUSR requests for 64-bit FGRs Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 35/47] MIPS: prctl: Disallow FRE without FR with PR_SET_FP_MODE requests Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 36/47] scsi: scsi_transport_srp: Fix shost to rport translation Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 37/47] stm class: Use vmalloc for the master map Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 38/47] hwtracing: stm: fix build error on some arches Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 39/47] IB/core: Fix error code for invalid GID entry Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 40/47] mm/huge_memory.c: __split_huge_page() use atomic ClearPageDirty() Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 41/47] Revert "rt2800: use TXOP_BACKOFF for probe frames" Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 42/47] intel_th: Use correct device when freeing buffers Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 46/47] fix io_destroy()/aio_complete() race Greg Kroah-Hartman
2018-06-04  6:58 ` [PATCH 4.16 47/47] mm: fix the NULL mapping case in __isolate_lru_page() Greg Kroah-Hartman
2018-06-04 13:20 ` [PATCH 4.16 00/47] 4.16.14-stable review Guenter Roeck
2018-06-05  8:15   ` Greg Kroah-Hartman
2018-06-04 19:47 ` Shuah Khan
2018-06-05  8:15   ` Greg Kroah-Hartman
2018-06-05  6:47 ` Naresh Kamboju
2018-06-05  8:28   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180604065550.302266366@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).