Skip to content

Commit

Permalink
Merge tag 'trace-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/…
Browse files Browse the repository at this point in the history
…git/rostedt/linux-trace

Pull tracing updates from Steven Rostedt:
 "This release has a few updates:

   - STM can hook into the function tracer
   - Function filtering now supports more advance glob matching
   - Ftrace selftests updates and added tests
   - Softirq tag in traces now show only softirqs
   - ARM nop added to non traced locations at compile time
   - New trace_marker_raw file that allows for binary input
   - Optimizations to the ring buffer
   - Removal of kmap in trace_marker
   - Wakeup and irqsoff tracers now adhere to the set_graph_notrace file
   - Other various fixes and clean ups"

* tag 'trace-v4.10' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (42 commits)
  selftests: ftrace: Shift down default message verbosity
  kprobes/trace: Fix kprobe selftest for newer gcc
  tracing/kprobes: Add a helper method to return number of probe hits
  tracing/rb: Init the CPU mask on allocation
  tracing: Use SOFTIRQ_OFFSET for softirq dectection for more accurate results
  tracing/fgraph: Have wakeup and irqsoff tracers ignore graph functions too
  fgraph: Handle a case where a tracer ignores set_graph_notrace
  tracing: Replace kmap with copy_from_user() in trace_marker writing
  ftrace/x86_32: Set ftrace_stub to weak to prevent gcc from using short jumps to it
  tracing: Allow benchmark to be enabled at early_initcall()
  tracing: Have system enable return error if one of the events fail
  tracing: Do not start benchmark on boot up
  tracing: Have the reg function allow to fail
  ring-buffer: Force rb_end_commit() and rb_set_commit_to_write() inline
  ring-buffer: Froce rb_update_write_stamp() to be inlined
  ring-buffer: Force inline of hotpath helper functions
  tracing: Make __buffer_unlock_commit() always_inline
  tracing: Make tracepoint_printk a static_key
  ring-buffer: Always inline rb_event_data()
  ring-buffer: Make rb_reserve_next_event() always inlined
  ...
  • Loading branch information
torvalds committed Dec 15, 2016
2 parents 5e176d6 + 3dbb16b commit 179a7ba
Show file tree
Hide file tree
Showing 52 changed files with 1,064 additions and 300 deletions.
9 changes: 3 additions & 6 deletions Documentation/trace/events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,13 @@ And for string fields they are:

==, !=, ~

The glob (~) only accepts a wild card character (*) at the start and or
end of the string. For example:
The glob (~) accepts a wild card character (*,?) and character classes
([). For example:

prev_comm ~ "*sh"
prev_comm ~ "sh*"
prev_comm ~ "*sh*"

But does not allow for it to be within the string:

prev_comm ~ "ba*sh" <-- is invalid
prev_comm ~ "ba*sh"

5.2 Setting filters
-------------------
Expand Down
15 changes: 9 additions & 6 deletions Documentation/trace/ftrace.txt
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,12 @@ of ftrace. Here is a list of some of the key files:

trace_fd = open("trace_marker", WR_ONLY);

trace_marker_raw:

This is similar to trace_marker above, but is meant for for binary data
to be written to it, where a tool can be used to parse the data
from trace_pipe_raw.

uprobe_events:

Add dynamic tracepoints in programs.
Expand Down Expand Up @@ -2238,16 +2244,13 @@ hrtimer_interrupt
sys_nanosleep


Perhaps this is not enough. The filters also allow simple wild
cards. Only the following are currently available
Perhaps this is not enough. The filters also allow glob(7) matching.

<match>* - will match functions that begin with <match>
*<match> - will match functions that end with <match>
*<match>* - will match functions that have <match> in it

These are the only wild cards which are supported.

<match>*<match> will not work.
<match1>*<match2> - will match functions that begin with
<match1> and end with <match2>

Note: It is better to use quotes to enclose the wild cards,
otherwise the shell may expand the parameters into names
Expand Down
4 changes: 2 additions & 2 deletions arch/powerpc/include/asm/trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ DEFINE_EVENT(ppc64_interrupt_class, timer_interrupt_exit,
);

#ifdef CONFIG_PPC_PSERIES
extern void hcall_tracepoint_regfunc(void);
extern int hcall_tracepoint_regfunc(void);
extern void hcall_tracepoint_unregfunc(void);

TRACE_EVENT_FN_COND(hcall_entry,
Expand Down Expand Up @@ -104,7 +104,7 @@ TRACE_EVENT_FN_COND(hcall_exit,
#endif

#ifdef CONFIG_PPC_POWERNV
extern void opal_tracepoint_regfunc(void);
extern int opal_tracepoint_regfunc(void);
extern void opal_tracepoint_unregfunc(void);

TRACE_EVENT_FN(opal_entry,
Expand Down
6 changes: 4 additions & 2 deletions arch/powerpc/platforms/powernv/opal-tracepoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
#ifdef HAVE_JUMP_LABEL
struct static_key opal_tracepoint_key = STATIC_KEY_INIT;

void opal_tracepoint_regfunc(void)
int opal_tracepoint_regfunc(void)
{
static_key_slow_inc(&opal_tracepoint_key);
return 0;
}

void opal_tracepoint_unregfunc(void)
Expand All @@ -25,9 +26,10 @@ void opal_tracepoint_unregfunc(void)
/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
extern long opal_tracepoint_refcount;

void opal_tracepoint_regfunc(void)
int opal_tracepoint_regfunc(void)
{
opal_tracepoint_refcount++;
return 0;
}

void opal_tracepoint_unregfunc(void)
Expand Down
6 changes: 4 additions & 2 deletions arch/powerpc/platforms/pseries/lpar.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,10 @@ EXPORT_SYMBOL(arch_free_page);
#ifdef HAVE_JUMP_LABEL
struct static_key hcall_tracepoint_key = STATIC_KEY_INIT;

void hcall_tracepoint_regfunc(void)
int hcall_tracepoint_regfunc(void)
{
static_key_slow_inc(&hcall_tracepoint_key);
return 0;
}

void hcall_tracepoint_unregfunc(void)
Expand All @@ -680,9 +681,10 @@ void hcall_tracepoint_unregfunc(void)
/* NB: reg/unreg are called while guarded with the tracepoints_mutex */
extern long hcall_tracepoint_refcount;

void hcall_tracepoint_regfunc(void)
int hcall_tracepoint_regfunc(void)
{
hcall_tracepoint_refcount++;
return 0;
}

void hcall_tracepoint_unregfunc(void)
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/entry/entry_32.S
Original file line number Diff line number Diff line change
Expand Up @@ -926,8 +926,8 @@ ftrace_graph_call:
jmp ftrace_stub
#endif

.globl ftrace_stub
ftrace_stub:
/* This is weak to keep gas from relaxing the jumps */
WEAK(ftrace_stub)
ret
END(ftrace_caller)

Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/trace/exceptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <linux/tracepoint.h>

extern void trace_irq_vector_regfunc(void);
extern int trace_irq_vector_regfunc(void);
extern void trace_irq_vector_unregfunc(void);

DECLARE_EVENT_CLASS(x86_exceptions,
Expand Down
2 changes: 1 addition & 1 deletion arch/x86/include/asm/trace/irq_vectors.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <linux/tracepoint.h>

extern void trace_irq_vector_regfunc(void);
extern int trace_irq_vector_regfunc(void);
extern void trace_irq_vector_unregfunc(void);

DECLARE_EVENT_CLASS(x86_irq_vector,
Expand Down
3 changes: 2 additions & 1 deletion arch/x86/kernel/tracepoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void switch_idt(void *arg)
local_irq_restore(flags);
}

void trace_irq_vector_regfunc(void)
int trace_irq_vector_regfunc(void)
{
mutex_lock(&irq_vector_mutex);
if (!trace_irq_vector_refcount) {
Expand All @@ -44,6 +44,7 @@ void trace_irq_vector_regfunc(void)
}
trace_irq_vector_refcount++;
mutex_unlock(&irq_vector_mutex);
return 0;
}

void trace_irq_vector_unregfunc(void)
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwtracing/coresight/coresight-stm.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ static long stm_generic_set_options(struct stm_data *stm_data,
return 0;
}

static ssize_t stm_generic_packet(struct stm_data *stm_data,
static ssize_t notrace stm_generic_packet(struct stm_data *stm_data,
unsigned int master,
unsigned int channel,
unsigned int packet,
Expand Down
11 changes: 7 additions & 4 deletions drivers/hwtracing/intel_th/sth.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,13 @@ static void sth_iowrite(void __iomem *dest, const unsigned char *payload,
}
}

static ssize_t sth_stm_packet(struct stm_data *stm_data, unsigned int master,
unsigned int channel, unsigned int packet,
unsigned int flags, unsigned int size,
const unsigned char *payload)
static ssize_t notrace sth_stm_packet(struct stm_data *stm_data,
unsigned int master,
unsigned int channel,
unsigned int packet,
unsigned int flags,
unsigned int size,
const unsigned char *payload)
{
struct sth_device *sth = container_of(stm_data, struct sth_device, stm);
struct intel_th_channel __iomem *out =
Expand Down
11 changes: 11 additions & 0 deletions drivers/hwtracing/stm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,15 @@ config STM_SOURCE_HEARTBEAT
If you want to send heartbeat messages over STM devices,
say Y.

config STM_SOURCE_FTRACE
tristate "Copy the output from kernel Ftrace to STM engine"
depends on FUNCTION_TRACER
help
This option can be used to copy the output from kernel Ftrace
to STM engine. Enabling this option will introduce a slight
timing effect.

If you want to send kernel Ftrace messages over STM devices,
say Y.

endif
2 changes: 2 additions & 0 deletions drivers/hwtracing/stm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ obj-$(CONFIG_STM_DUMMY) += dummy_stm.o

obj-$(CONFIG_STM_SOURCE_CONSOLE) += stm_console.o
obj-$(CONFIG_STM_SOURCE_HEARTBEAT) += stm_heartbeat.o
obj-$(CONFIG_STM_SOURCE_FTRACE) += stm_ftrace.o

stm_console-y := console.o
stm_heartbeat-y := heartbeat.o
stm_ftrace-y := ftrace.o
7 changes: 4 additions & 3 deletions drivers/hwtracing/stm/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ static int stm_file_assign(struct stm_file *stmf, char *id, unsigned int width)
return ret;
}

static ssize_t stm_write(struct stm_data *data, unsigned int master,
static ssize_t notrace stm_write(struct stm_data *data, unsigned int master,
unsigned int channel, const char *buf, size_t count)
{
unsigned int flags = STP_PACKET_TIMESTAMPED;
Expand Down Expand Up @@ -1123,8 +1123,9 @@ void stm_source_unregister_device(struct stm_source_data *data)
}
EXPORT_SYMBOL_GPL(stm_source_unregister_device);

int stm_source_write(struct stm_source_data *data, unsigned int chan,
const char *buf, size_t count)
int notrace stm_source_write(struct stm_source_data *data,
unsigned int chan,
const char *buf, size_t count)
{
struct stm_source_device *src = data->src;
struct stm_device *stm;
Expand Down
2 changes: 1 addition & 1 deletion drivers/hwtracing/stm/dummy_stm.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include <linux/slab.h>
#include <linux/stm.h>

static ssize_t
static ssize_t notrace
dummy_stm_packet(struct stm_data *stm_data, unsigned int master,
unsigned int channel, unsigned int packet, unsigned int flags,
unsigned int size, const unsigned char *payload)
Expand Down
87 changes: 87 additions & 0 deletions drivers/hwtracing/stm/ftrace.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Simple kernel driver to link kernel Ftrace and an STM device
* Copyright (c) 2016, Linaro Ltd.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* STM Ftrace will be registered as a trace_export.
*/

#include <linux/module.h>
#include <linux/stm.h>
#include <linux/trace.h>

#define STM_FTRACE_NR_CHANNELS 1
#define STM_FTRACE_CHAN 0

static int stm_ftrace_link(struct stm_source_data *data);
static void stm_ftrace_unlink(struct stm_source_data *data);

static struct stm_ftrace {
struct stm_source_data data;
struct trace_export ftrace;
} stm_ftrace = {
.data = {
.name = "ftrace",
.nr_chans = STM_FTRACE_NR_CHANNELS,
.link = stm_ftrace_link,
.unlink = stm_ftrace_unlink,
},
};

/**
* stm_ftrace_write() - write data to STM via 'stm_ftrace' source
* @buf: buffer containing the data packet
* @len: length of the data packet
*/
static void notrace
stm_ftrace_write(const void *buf, unsigned int len)
{
stm_source_write(&stm_ftrace.data, STM_FTRACE_CHAN, buf, len);
}

static int stm_ftrace_link(struct stm_source_data *data)
{
struct stm_ftrace *sf = container_of(data, struct stm_ftrace, data);

sf->ftrace.write = stm_ftrace_write;

return register_ftrace_export(&sf->ftrace);
}

static void stm_ftrace_unlink(struct stm_source_data *data)
{
struct stm_ftrace *sf = container_of(data, struct stm_ftrace, data);

unregister_ftrace_export(&sf->ftrace);
}

static int __init stm_ftrace_init(void)
{
int ret;

ret = stm_source_register_device(NULL, &stm_ftrace.data);
if (ret)
pr_err("Failed to register stm_source - ftrace.\n");

return ret;
}

static void __exit stm_ftrace_exit(void)
{
stm_source_unregister_device(&stm_ftrace.data);
}

module_init(stm_ftrace_init);
module_exit(stm_ftrace_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("stm_ftrace driver");
MODULE_AUTHOR("Chunyan Zhang <[email protected]>");
3 changes: 2 additions & 1 deletion drivers/i2c/i2c-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@ static int i2c_detect(struct i2c_adapter *adapter, struct i2c_driver *driver);
static struct static_key i2c_trace_msg = STATIC_KEY_INIT_FALSE;
static bool is_registered;

void i2c_transfer_trace_reg(void)
int i2c_transfer_trace_reg(void)
{
static_key_slow_inc(&i2c_trace_msg);
return 0;
}

void i2c_transfer_trace_unreg(void)
Expand Down
4 changes: 4 additions & 0 deletions include/linux/ftrace.h
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,10 @@ extern int __disable_trace_on_warning;
#define INIT_TRACE_RECURSION .trace_recursion = 0,
#endif

int tracepoint_printk_sysctl(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos);

#else /* CONFIG_TRACING */
static inline void disable_trace_on_warning(void) { }
#endif /* CONFIG_TRACING */
Expand Down
4 changes: 2 additions & 2 deletions include/linux/stm.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ int stm_source_register_device(struct device *parent,
struct stm_source_data *data);
void stm_source_unregister_device(struct stm_source_data *data);

int stm_source_write(struct stm_source_data *data, unsigned int chan,
const char *buf, size_t count);
int notrace stm_source_write(struct stm_source_data *data, unsigned int chan,
const char *buf, size_t count);

#endif /* _STM_H_ */
28 changes: 28 additions & 0 deletions include/linux/trace.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef _LINUX_TRACE_H
#define _LINUX_TRACE_H

#ifdef CONFIG_TRACING
/*
* The trace export - an export of Ftrace output. The trace_export
* can process traces and export them to a registered destination as
* an addition to the current only output of Ftrace - i.e. ring buffer.
*
* If you want traces to be sent to some other place rather than ring
* buffer only, just need to register a new trace_export and implement
* its own .write() function for writing traces to the storage.
*
* next - pointer to the next trace_export
* write - copy traces which have been delt with ->commit() to
* the destination
*/
struct trace_export {
struct trace_export __rcu *next;
void (*write)(const void *, unsigned int);
};

int register_ftrace_export(struct trace_export *export);
int unregister_ftrace_export(struct trace_export *export);

#endif /* CONFIG_TRACING */

#endif /* _LINUX_TRACE_H */
Loading

0 comments on commit 179a7ba

Please sign in to comment.