Skip to content

Commit 2dcd9c7

Browse files
committed
Merge tag 'trace-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from - allow module init functions to be traced - clean up some unused or not used by config events (saves space) - clean up of trace histogram code - add support for preempt and interrupt enabled/disable events - other various clean ups * tag 'trace-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (30 commits) tracing, thermal: Hide cpu cooling trace events when not in use tracing, thermal: Hide devfreq trace events when not in use ftrace: Kill FTRACE_OPS_FL_PER_CPU perf/ftrace: Small cleanup perf/ftrace: Fix function trace events perf/ftrace: Revert ("perf/ftrace: Fix double traces of perf on ftrace:function") tracing, dma-buf: Remove unused trace event dma_fence_annotate_wait_on tracing, memcg, vmscan: Hide trace events when not in use tracing/xen: Hide events that are not used when X86_PAE is not defined tracing: mark trace_test_buffer as __maybe_unused printk: Remove superfluous memory barriers from printk_safe ftrace: Clear hashes of stale ips of init memory tracing: Add support for preempt and irq enable/disable events tracing: Prepare to add preempt and irq trace events ftrace/kallsyms: Have /proc/kallsyms show saved mod init functions ftrace: Add freeing algorithm to free ftrace_mod_maps ftrace: Save module init functions kallsyms symbols for tracing ftrace: Allow module init functions to be traced ftrace: Add a ftrace_free_mem() function for modules to use tracing: Reimplement log2 ...
2 parents b1c2a34 + a96a503 commit 2dcd9c7

32 files changed

Lines changed: 903 additions & 518 deletions

‎drivers/dma-buf/dma-fence.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#define CREATE_TRACE_POINTS
2828
#include <trace/events/dma_fence.h>
2929

30-
EXPORT_TRACEPOINT_SYMBOL(dma_fence_annotate_wait_on);
3130
EXPORT_TRACEPOINT_SYMBOL(dma_fence_emit);
3231
EXPORT_TRACEPOINT_SYMBOL(dma_fence_enable_signal);
3332

‎include/linux/ftrace.h‎

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,30 @@ static inline void early_trace_init(void) { }
5252
struct module;
5353
struct ftrace_hash;
5454

55+
#if defined(CONFIG_FUNCTION_TRACER) && defined(CONFIG_MODULES) && \
56+
defined(CONFIG_DYNAMIC_FTRACE)
57+
const char *
58+
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
59+
unsigned long *off, char **modname, char *sym);
60+
int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
61+
char *type, char *name,
62+
char *module_name, int *exported);
63+
#else
64+
static inline const char *
65+
ftrace_mod_address_lookup(unsigned long addr, unsigned long *size,
66+
unsigned long *off, char **modname, char *sym)
67+
{
68+
return NULL;
69+
}
70+
static inline int ftrace_mod_get_kallsym(unsigned int symnum, unsigned long *value,
71+
char *type, char *name,
72+
char *module_name, int *exported)
73+
{
74+
return -1;
75+
}
76+
#endif
77+
78+
5579
#ifdef CONFIG_FUNCTION_TRACER
5680

5781
extern int ftrace_enabled;
@@ -79,10 +103,6 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops);
79103
* ENABLED - set/unset when ftrace_ops is registered/unregistered
80104
* DYNAMIC - set when ftrace_ops is registered to denote dynamically
81105
* allocated ftrace_ops which need special care
82-
* PER_CPU - set manualy by ftrace_ops user to denote the ftrace_ops
83-
* could be controlled by following calls:
84-
* ftrace_function_local_enable
85-
* ftrace_function_local_disable
86106
* SAVE_REGS - The ftrace_ops wants regs saved at each function called
87107
* and passed to the callback. If this flag is set, but the
88108
* architecture does not support passing regs
@@ -126,21 +146,20 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops);
126146
enum {
127147
FTRACE_OPS_FL_ENABLED = 1 << 0,
128148
FTRACE_OPS_FL_DYNAMIC = 1 << 1,
129-
FTRACE_OPS_FL_PER_CPU = 1 << 2,
130-
FTRACE_OPS_FL_SAVE_REGS = 1 << 3,
131-
FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED = 1 << 4,
132-
FTRACE_OPS_FL_RECURSION_SAFE = 1 << 5,
133-
FTRACE_OPS_FL_STUB = 1 << 6,
134-
FTRACE_OPS_FL_INITIALIZED = 1 << 7,
135-
FTRACE_OPS_FL_DELETED = 1 << 8,
136-
FTRACE_OPS_FL_ADDING = 1 << 9,
137-
FTRACE_OPS_FL_REMOVING = 1 << 10,
138-
FTRACE_OPS_FL_MODIFYING = 1 << 11,
139-
FTRACE_OPS_FL_ALLOC_TRAMP = 1 << 12,
140-
FTRACE_OPS_FL_IPMODIFY = 1 << 13,
141-
FTRACE_OPS_FL_PID = 1 << 14,
142-
FTRACE_OPS_FL_RCU = 1 << 15,
143-
FTRACE_OPS_FL_TRACE_ARRAY = 1 << 16,
149+
FTRACE_OPS_FL_SAVE_REGS = 1 << 2,
150+
FTRACE_OPS_FL_SAVE_REGS_IF_SUPPORTED = 1 << 3,
151+
FTRACE_OPS_FL_RECURSION_SAFE = 1 << 4,
152+
FTRACE_OPS_FL_STUB = 1 << 5,
153+
FTRACE_OPS_FL_INITIALIZED = 1 << 6,
154+
FTRACE_OPS_FL_DELETED = 1 << 7,
155+
FTRACE_OPS_FL_ADDING = 1 << 8,
156+
FTRACE_OPS_FL_REMOVING = 1 << 9,
157+
FTRACE_OPS_FL_MODIFYING = 1 << 10,
158+
FTRACE_OPS_FL_ALLOC_TRAMP = 1 << 11,
159+
FTRACE_OPS_FL_IPMODIFY = 1 << 12,
160+
FTRACE_OPS_FL_PID = 1 << 13,
161+
FTRACE_OPS_FL_RCU = 1 << 14,
162+
FTRACE_OPS_FL_TRACE_ARRAY = 1 << 15,
144163
};
145164

146165
#ifdef CONFIG_DYNAMIC_FTRACE
@@ -152,8 +171,10 @@ struct ftrace_ops_hash {
152171
};
153172

154173
void ftrace_free_init_mem(void);
174+
void ftrace_free_mem(struct module *mod, void *start, void *end);
155175
#else
156176
static inline void ftrace_free_init_mem(void) { }
177+
static inline void ftrace_free_mem(struct module *mod, void *start, void *end) { }
157178
#endif
158179

159180
/*
@@ -173,7 +194,6 @@ struct ftrace_ops {
173194
unsigned long flags;
174195
void *private;
175196
ftrace_func_t saved_func;
176-
int __percpu *disabled;
177197
#ifdef CONFIG_DYNAMIC_FTRACE
178198
struct ftrace_ops_hash local_hash;
179199
struct ftrace_ops_hash *func_hash;
@@ -205,55 +225,6 @@ int register_ftrace_function(struct ftrace_ops *ops);
205225
int unregister_ftrace_function(struct ftrace_ops *ops);
206226
void clear_ftrace_function(void);
207227

208-
/**
209-
* ftrace_function_local_enable - enable ftrace_ops on current cpu
210-
*
211-
* This function enables tracing on current cpu by decreasing
212-
* the per cpu control variable.
213-
* It must be called with preemption disabled and only on ftrace_ops
214-
* registered with FTRACE_OPS_FL_PER_CPU. If called without preemption
215-
* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
216-
*/
217-
static inline void ftrace_function_local_enable(struct ftrace_ops *ops)
218-
{
219-
if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_PER_CPU)))
220-
return;
221-
222-
(*this_cpu_ptr(ops->disabled))--;
223-
}
224-
225-
/**
226-
* ftrace_function_local_disable - disable ftrace_ops on current cpu
227-
*
228-
* This function disables tracing on current cpu by increasing
229-
* the per cpu control variable.
230-
* It must be called with preemption disabled and only on ftrace_ops
231-
* registered with FTRACE_OPS_FL_PER_CPU. If called without preemption
232-
* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
233-
*/
234-
static inline void ftrace_function_local_disable(struct ftrace_ops *ops)
235-
{
236-
if (WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_PER_CPU)))
237-
return;
238-
239-
(*this_cpu_ptr(ops->disabled))++;
240-
}
241-
242-
/**
243-
* ftrace_function_local_disabled - returns ftrace_ops disabled value
244-
* on current cpu
245-
*
246-
* This function returns value of ftrace_ops::disabled on current cpu.
247-
* It must be called with preemption disabled and only on ftrace_ops
248-
* registered with FTRACE_OPS_FL_PER_CPU. If called without preemption
249-
* disabled, this_cpu_ptr will complain when CONFIG_DEBUG_PREEMPT is enabled.
250-
*/
251-
static inline int ftrace_function_local_disabled(struct ftrace_ops *ops)
252-
{
253-
WARN_ON_ONCE(!(ops->flags & FTRACE_OPS_FL_PER_CPU));
254-
return *this_cpu_ptr(ops->disabled);
255-
}
256-
257228
extern void ftrace_stub(unsigned long a0, unsigned long a1,
258229
struct ftrace_ops *op, struct pt_regs *regs);
259230

@@ -271,6 +242,7 @@ static inline int ftrace_nr_registered_ops(void)
271242
static inline void clear_ftrace_function(void) { }
272243
static inline void ftrace_kill(void) { }
273244
static inline void ftrace_free_init_mem(void) { }
245+
static inline void ftrace_free_mem(struct module *mod, void *start, void *end) { }
274246
#endif /* CONFIG_FUNCTION_TRACER */
275247

276248
#ifdef CONFIG_STACK_TRACER
@@ -743,7 +715,8 @@ static inline unsigned long get_lock_parent_ip(void)
743715
static inline void time_hardirqs_off(unsigned long a0, unsigned long a1) { }
744716
#endif
745717

746-
#ifdef CONFIG_PREEMPT_TRACER
718+
#if defined(CONFIG_PREEMPT_TRACER) || \
719+
(defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPTIRQ_EVENTS))
747720
extern void trace_preempt_on(unsigned long a0, unsigned long a1);
748721
extern void trace_preempt_off(unsigned long a0, unsigned long a1);
749722
#else

‎include/linux/init.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
/* These are for everybody (although not all archs will actually
4242
discard it in modules) */
43-
#define __init __section(.init.text) __cold __inittrace __latent_entropy
43+
#define __init __section(.init.text) __cold __latent_entropy
4444
#define __initdata __section(.init.data)
4545
#define __initconst __section(.init.rodata)
4646
#define __exitdata __section(.exit.data)
@@ -69,10 +69,8 @@
6969

7070
#ifdef MODULE
7171
#define __exitused
72-
#define __inittrace notrace
7372
#else
7473
#define __exitused __used
75-
#define __inittrace
7674
#endif
7775

7876
#define __exit __section(.exit.text) __exitused __cold notrace

‎include/linux/perf_event.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ extern void perf_event_init(void);
11691169
extern void perf_tp_event(u16 event_type, u64 count, void *record,
11701170
int entry_size, struct pt_regs *regs,
11711171
struct hlist_head *head, int rctx,
1172-
struct task_struct *task, struct perf_event *event);
1172+
struct task_struct *task);
11731173
extern void perf_bp_event(struct perf_event *event, void *data);
11741174

11751175
#ifndef perf_misc_flags

‎include/linux/trace_events.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,11 @@ enum trace_reg {
174174
TRACE_REG_PERF_UNREGISTER,
175175
TRACE_REG_PERF_OPEN,
176176
TRACE_REG_PERF_CLOSE,
177+
/*
178+
* These (ADD/DEL) use a 'boolean' return value, where 1 (true) means a
179+
* custom action was taken and the default action is not to be
180+
* performed.
181+
*/
177182
TRACE_REG_PERF_ADD,
178183
TRACE_REG_PERF_DEL,
179184
#endif
@@ -542,9 +547,9 @@ void perf_trace_run_bpf_submit(void *raw_data, int size, int rctx,
542547
static inline void
543548
perf_trace_buf_submit(void *raw_data, int size, int rctx, u16 type,
544549
u64 count, struct pt_regs *regs, void *head,
545-
struct task_struct *task, struct perf_event *event)
550+
struct task_struct *task)
546551
{
547-
perf_tp_event(type, count, raw_data, size, regs, head, rctx, task, event);
552+
perf_tp_event(type, count, raw_data, size, regs, head, rctx, task);
548553
}
549554

550555
#endif

‎include/trace/events/dma_fence.h‎

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,6 @@
99

1010
struct dma_fence;
1111

12-
TRACE_EVENT(dma_fence_annotate_wait_on,
13-
14-
/* fence: the fence waiting on f1, f1: the fence to be waited on. */
15-
TP_PROTO(struct dma_fence *fence, struct dma_fence *f1),
16-
17-
TP_ARGS(fence, f1),
18-
19-
TP_STRUCT__entry(
20-
__string(driver, fence->ops->get_driver_name(fence))
21-
__string(timeline, fence->ops->get_timeline_name(fence))
22-
__field(unsigned int, context)
23-
__field(unsigned int, seqno)
24-
25-
__string(waiting_driver, f1->ops->get_driver_name(f1))
26-
__string(waiting_timeline, f1->ops->get_timeline_name(f1))
27-
__field(unsigned int, waiting_context)
28-
__field(unsigned int, waiting_seqno)
29-
),
30-
31-
TP_fast_assign(
32-
__assign_str(driver, fence->ops->get_driver_name(fence))
33-
__assign_str(timeline, fence->ops->get_timeline_name(fence))
34-
__entry->context = fence->context;
35-
__entry->seqno = fence->seqno;
36-
37-
__assign_str(waiting_driver, f1->ops->get_driver_name(f1))
38-
__assign_str(waiting_timeline, f1->ops->get_timeline_name(f1))
39-
__entry->waiting_context = f1->context;
40-
__entry->waiting_seqno = f1->seqno;
41-
42-
),
43-
44-
TP_printk("driver=%s timeline=%s context=%u seqno=%u " \
45-
"waits on driver=%s timeline=%s context=%u seqno=%u",
46-
__get_str(driver), __get_str(timeline), __entry->context,
47-
__entry->seqno,
48-
__get_str(waiting_driver), __get_str(waiting_timeline),
49-
__entry->waiting_context, __entry->waiting_seqno)
50-
);
51-
5212
DECLARE_EVENT_CLASS(dma_fence,
5313

5414
TP_PROTO(struct dma_fence *fence),

‎include/trace/events/preemptirq.h‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#ifdef CONFIG_PREEMPTIRQ_EVENTS
2+
3+
#undef TRACE_SYSTEM
4+
#define TRACE_SYSTEM preemptirq
5+
6+
#if !defined(_TRACE_PREEMPTIRQ_H) || defined(TRACE_HEADER_MULTI_READ)
7+
#define _TRACE_PREEMPTIRQ_H
8+
9+
#include <linux/ktime.h>
10+
#include <linux/tracepoint.h>
11+
#include <linux/string.h>
12+
#include <asm/sections.h>
13+
14+
DECLARE_EVENT_CLASS(preemptirq_template,
15+
16+
TP_PROTO(unsigned long ip, unsigned long parent_ip),
17+
18+
TP_ARGS(ip, parent_ip),
19+
20+
TP_STRUCT__entry(
21+
__field(u32, caller_offs)
22+
__field(u32, parent_offs)
23+
),
24+
25+
TP_fast_assign(
26+
__entry->caller_offs = (u32)(ip - (unsigned long)_stext);
27+
__entry->parent_offs = (u32)(parent_ip - (unsigned long)_stext);
28+
),
29+
30+
TP_printk("caller=%pF parent=%pF",
31+
(void *)((unsigned long)(_stext) + __entry->caller_offs),
32+
(void *)((unsigned long)(_stext) + __entry->parent_offs))
33+
);
34+
35+
#ifndef CONFIG_PROVE_LOCKING
36+
DEFINE_EVENT(preemptirq_template, irq_disable,
37+
TP_PROTO(unsigned long ip, unsigned long parent_ip),
38+
TP_ARGS(ip, parent_ip));
39+
40+
DEFINE_EVENT(preemptirq_template, irq_enable,
41+
TP_PROTO(unsigned long ip, unsigned long parent_ip),
42+
TP_ARGS(ip, parent_ip));
43+
#endif
44+
45+
#ifdef CONFIG_DEBUG_PREEMPT
46+
DEFINE_EVENT(preemptirq_template, preempt_disable,
47+
TP_PROTO(unsigned long ip, unsigned long parent_ip),
48+
TP_ARGS(ip, parent_ip));
49+
50+
DEFINE_EVENT(preemptirq_template, preempt_enable,
51+
TP_PROTO(unsigned long ip, unsigned long parent_ip),
52+
TP_ARGS(ip, parent_ip));
53+
#endif
54+
55+
#endif /* _TRACE_PREEMPTIRQ_H */
56+
57+
#include <trace/define_trace.h>
58+
59+
#else /* !CONFIG_PREEMPTIRQ_EVENTS */
60+
61+
#define trace_irq_enable(...)
62+
#define trace_irq_disable(...)
63+
#define trace_preempt_enable(...)
64+
#define trace_preempt_disable(...)
65+
#define trace_irq_enable_rcuidle(...)
66+
#define trace_irq_disable_rcuidle(...)
67+
#define trace_preempt_enable_rcuidle(...)
68+
#define trace_preempt_disable_rcuidle(...)
69+
70+
#endif

‎include/trace/events/thermal.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ TRACE_EVENT(thermal_zone_trip,
9191
show_tzt_type(__entry->trip_type))
9292
);
9393

94+
#ifdef CONFIG_CPU_THERMAL
9495
TRACE_EVENT(thermal_power_cpu_get_power,
9596
TP_PROTO(const struct cpumask *cpus, unsigned long freq, u32 *load,
9697
size_t load_len, u32 dynamic_power, u32 static_power),
@@ -148,7 +149,9 @@ TRACE_EVENT(thermal_power_cpu_limit,
148149
__get_bitmask(cpumask), __entry->freq, __entry->cdev_state,
149150
__entry->power)
150151
);
152+
#endif /* CONFIG_CPU_THERMAL */
151153

154+
#ifdef CONFIG_DEVFREQ_THERMAL
152155
TRACE_EVENT(thermal_power_devfreq_get_power,
153156
TP_PROTO(struct thermal_cooling_device *cdev,
154157
struct devfreq_dev_status *status, unsigned long freq,
@@ -204,6 +207,7 @@ TRACE_EVENT(thermal_power_devfreq_limit,
204207
__get_str(type), __entry->freq, __entry->cdev_state,
205208
__entry->power)
206209
);
210+
#endif /* CONFIG_DEVFREQ_THERMAL */
207211
#endif /* _TRACE_THERMAL_H */
208212

209213
/* This part must be outside protection */

0 commit comments

Comments
 (0)