Skip to content

Commit 2074006

Browse files
committed
Merge tag 'trace-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace
Pull tracing updates from Steven Rostedt: "The new features of this release: - Added TRACE_DEFINE_SIZEOF() which allows trace events that use sizeof() it the TP_printk() to be converted to the actual size such that trace-cmd and perf can parse them correctly. - Some rework of the TRACE_DEFINE_ENUM() such that the above TRACE_DEFINE_SIZEOF() could reuse the same code. - Recording of tgid (Thread Group ID). This is similar to how task COMMs are recorded (cached at sched_switch), where it is in a table and used on output of the trace and trace_pipe files. - Have ":mod:<module>" be cached when written into set_ftrace_filter. Then the functions of the module will be traced at module load. - Some random clean ups and small fixes" * tag 'trace-v4.13' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: (26 commits) ftrace: Test for NULL iter->tr in regex for stack_trace_filter changes ftrace: Decrement count for dyn_ftrace_total_info for init functions ftrace: Unlock hash mutex on failed allocation in process_mod_list() tracing: Add support for display of tgid in trace output tracing: Add support for recording tgid of tasks ftrace: Decrement count for dyn_ftrace_total_info file ftrace: Remove unused function ftrace_arch_read_dyn_info() sh/ftrace: Remove only user of ftrace_arch_read_dyn_info() ftrace: Have cached module filters be an active filter ftrace: Implement cached modules tracing on module load ftrace: Have the cached module list show in set_ftrace_filter ftrace: Add :mod: caching infrastructure to trace_array tracing: Show address when function names are not found ftrace: Add missing comment for FTRACE_OPS_FL_RCU tracing: Rename update the enum_map file tracing: Add TRACE_DEFINE_SIZEOF() macros tracing: define TRACE_DEFINE_SIZEOF() macro to map sizeof's to their values tracing: Rename enum_replace to eval_replace trace: rename enum_map functions trace: rename trace.c enum functions ...
2 parents f72e24a + 69d7187 commit 2074006

17 files changed

Lines changed: 797 additions & 245 deletions

File tree

‎arch/arm64/kvm/trace.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ TRACE_EVENT(kvm_arm_set_dreg32,
9393
TP_printk("%s: 0x%08x", __entry->name, __entry->value)
9494
);
9595

96+
TRACE_DEFINE_SIZEOF(__u64);
97+
9698
TRACE_EVENT(kvm_arm_set_regset,
9799
TP_PROTO(const char *type, int len, __u64 *control, __u64 *value),
98100
TP_ARGS(type, len, control, value),

‎arch/sh/kernel/ftrace.c‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -96,19 +96,6 @@ static int mod_code_status; /* holds return value of text write */
9696
static void *mod_code_ip; /* holds the IP to write to */
9797
static void *mod_code_newcode; /* holds the text to write to the IP */
9898

99-
static unsigned nmi_wait_count;
100-
static atomic_t nmi_update_count = ATOMIC_INIT(0);
101-
102-
int ftrace_arch_read_dyn_info(char *buf, int size)
103-
{
104-
int r;
105-
106-
r = snprintf(buf, size, "%u %u",
107-
nmi_wait_count,
108-
atomic_read(&nmi_update_count));
109-
return r;
110-
}
111-
11299
static void clear_mod_flag(void)
113100
{
114101
int old = atomic_read(&nmi_running);
@@ -144,7 +131,6 @@ void arch_ftrace_nmi_enter(void)
144131
if (atomic_inc_return(&nmi_running) & MOD_CODE_WRITE_FLAG) {
145132
smp_rmb();
146133
ftrace_mod_code();
147-
atomic_inc(&nmi_update_count);
148134
}
149135
/* Must have previous changes seen before executions */
150136
smp_mb();
@@ -165,8 +151,6 @@ static void wait_for_nmi_and_set_mod_flag(void)
165151
do {
166152
cpu_relax();
167153
} while (atomic_cmpxchg(&nmi_running, 0, MOD_CODE_WRITE_FLAG));
168-
169-
nmi_wait_count++;
170154
}
171155

172156
static void wait_for_nmi(void)
@@ -177,8 +161,6 @@ static void wait_for_nmi(void)
177161
do {
178162
cpu_relax();
179163
} while (atomic_read(&nmi_running));
180-
181-
nmi_wait_count++;
182164
}
183165

184166
static int

‎include/asm-generic/vmlinux.lds.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
VMLINUX_SYMBOL(__start_ftrace_events) = .; \
126126
KEEP(*(_ftrace_events)) \
127127
VMLINUX_SYMBOL(__stop_ftrace_events) = .; \
128-
VMLINUX_SYMBOL(__start_ftrace_enum_maps) = .; \
129-
KEEP(*(_ftrace_enum_map)) \
130-
VMLINUX_SYMBOL(__stop_ftrace_enum_maps) = .;
128+
VMLINUX_SYMBOL(__start_ftrace_eval_maps) = .; \
129+
KEEP(*(_ftrace_eval_map)) \
130+
VMLINUX_SYMBOL(__stop_ftrace_eval_maps) = .;
131131
#else
132132
#define FTRACE_EVENTS()
133133
#endif

‎include/linux/ftrace.h‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ ftrace_func_t ftrace_ops_get_func(struct ftrace_ops *ops);
119119
* for any of the functions that this ops will be registered for, then
120120
* this ops will fail to register or set_filter_ip.
121121
* PID - Is affected by set_ftrace_pid (allows filtering on those pids)
122+
* RCU - Set when the ops can only be called when RCU is watching.
123+
* TRACE_ARRAY - The ops->private points to a trace_array descriptor.
122124
*/
123125
enum {
124126
FTRACE_OPS_FL_ENABLED = 1 << 0,
@@ -137,6 +139,7 @@ enum {
137139
FTRACE_OPS_FL_IPMODIFY = 1 << 13,
138140
FTRACE_OPS_FL_PID = 1 << 14,
139141
FTRACE_OPS_FL_RCU = 1 << 15,
142+
FTRACE_OPS_FL_TRACE_ARRAY = 1 << 16,
140143
};
141144

142145
#ifdef CONFIG_DYNAMIC_FTRACE
@@ -445,7 +448,8 @@ enum {
445448
FTRACE_ITER_PRINTALL = (1 << 2),
446449
FTRACE_ITER_DO_PROBES = (1 << 3),
447450
FTRACE_ITER_PROBE = (1 << 4),
448-
FTRACE_ITER_ENABLED = (1 << 5),
451+
FTRACE_ITER_MOD = (1 << 5),
452+
FTRACE_ITER_ENABLED = (1 << 6),
449453
};
450454

451455
void arch_ftrace_update_code(int command);

‎include/linux/module.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,8 @@ struct module {
442442
#ifdef CONFIG_EVENT_TRACING
443443
struct trace_event_call **trace_events;
444444
unsigned int num_trace_events;
445-
struct trace_enum_map **trace_enums;
446-
unsigned int num_trace_enums;
445+
struct trace_eval_map **trace_evals;
446+
unsigned int num_trace_evals;
447447
#endif
448448
#ifdef CONFIG_FTRACE_MCOUNT_RECORD
449449
unsigned int num_ftrace_callsites;

‎include/linux/trace_events.h‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ trace_event_buffer_lock_reserve(struct ring_buffer **current_buffer,
151151
int type, unsigned long len,
152152
unsigned long flags, int pc);
153153

154-
void tracing_record_cmdline(struct task_struct *tsk);
154+
#define TRACE_RECORD_CMDLINE BIT(0)
155+
#define TRACE_RECORD_TGID BIT(1)
156+
157+
void tracing_record_taskinfo(struct task_struct *task, int flags);
158+
void tracing_record_taskinfo_sched_switch(struct task_struct *prev,
159+
struct task_struct *next, int flags);
160+
161+
void tracing_record_cmdline(struct task_struct *task);
162+
void tracing_record_tgid(struct task_struct *task);
155163

156164
int trace_output_call(struct trace_iterator *iter, char *name, char *fmt, ...);
157165

@@ -290,6 +298,7 @@ struct trace_subsystem_dir;
290298
enum {
291299
EVENT_FILE_FL_ENABLED_BIT,
292300
EVENT_FILE_FL_RECORDED_CMD_BIT,
301+
EVENT_FILE_FL_RECORDED_TGID_BIT,
293302
EVENT_FILE_FL_FILTERED_BIT,
294303
EVENT_FILE_FL_NO_SET_FILTER_BIT,
295304
EVENT_FILE_FL_SOFT_MODE_BIT,
@@ -303,6 +312,7 @@ enum {
303312
* Event file flags:
304313
* ENABLED - The event is enabled
305314
* RECORDED_CMD - The comms should be recorded at sched_switch
315+
* RECORDED_TGID - The tgids should be recorded at sched_switch
306316
* FILTERED - The event has a filter attached
307317
* NO_SET_FILTER - Set when filter has error and is to be ignored
308318
* SOFT_MODE - The event is enabled/disabled by SOFT_DISABLED
@@ -315,6 +325,7 @@ enum {
315325
enum {
316326
EVENT_FILE_FL_ENABLED = (1 << EVENT_FILE_FL_ENABLED_BIT),
317327
EVENT_FILE_FL_RECORDED_CMD = (1 << EVENT_FILE_FL_RECORDED_CMD_BIT),
328+
EVENT_FILE_FL_RECORDED_TGID = (1 << EVENT_FILE_FL_RECORDED_TGID_BIT),
318329
EVENT_FILE_FL_FILTERED = (1 << EVENT_FILE_FL_FILTERED_BIT),
319330
EVENT_FILE_FL_NO_SET_FILTER = (1 << EVENT_FILE_FL_NO_SET_FILTER_BIT),
320331
EVENT_FILE_FL_SOFT_MODE = (1 << EVENT_FILE_FL_SOFT_MODE_BIT),

‎include/linux/tracepoint.h‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ struct module;
2525
struct tracepoint;
2626
struct notifier_block;
2727

28-
struct trace_enum_map {
28+
struct trace_eval_map {
2929
const char *system;
30-
const char *enum_string;
31-
unsigned long enum_value;
30+
const char *eval_string;
31+
unsigned long eval_value;
3232
};
3333

3434
#define TRACEPOINT_DEFAULT_PRIO 10
@@ -88,6 +88,7 @@ extern void syscall_unregfunc(void);
8888
#define PARAMS(args...) args
8989

9090
#define TRACE_DEFINE_ENUM(x)
91+
#define TRACE_DEFINE_SIZEOF(x)
9192

9293
#endif /* _LINUX_TRACEPOINT_H */
9394

‎include/trace/events/xen.h‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ DECLARE_EVENT_CLASS(xen_mc__batch,
3030
DEFINE_XEN_MC_BATCH(xen_mc_batch);
3131
DEFINE_XEN_MC_BATCH(xen_mc_issue);
3232

33+
TRACE_DEFINE_SIZEOF(ulong);
34+
3335
TRACE_EVENT(xen_mc_entry,
3436
TP_PROTO(struct multicall_entry *mc, unsigned nargs),
3537
TP_ARGS(mc, nargs),
@@ -40,8 +42,8 @@ TRACE_EVENT(xen_mc_entry,
4042
),
4143
TP_fast_assign(__entry->op = mc->op;
4244
__entry->nargs = nargs;
43-
memcpy(__entry->args, mc->args, sizeof(unsigned long) * nargs);
44-
memset(__entry->args + nargs, 0, sizeof(unsigned long) * (6 - nargs));
45+
memcpy(__entry->args, mc->args, sizeof(ulong) * nargs);
46+
memset(__entry->args + nargs, 0, sizeof(ulong) * (6 - nargs));
4547
),
4648
TP_printk("op %u%s args [%lx, %lx, %lx, %lx, %lx, %lx]",
4749
__entry->op, xen_hypercall_name(__entry->op),
@@ -122,6 +124,7 @@ TRACE_EVENT(xen_mc_extend_args,
122124
__entry->res == XEN_MC_XE_NO_SPACE ? "NO_SPACE" : "???")
123125
);
124126

127+
TRACE_DEFINE_SIZEOF(pteval_t);
125128
/* mmu */
126129
DECLARE_EVENT_CLASS(xen_mmu__set_pte,
127130
TP_PROTO(pte_t *ptep, pte_t pteval),
@@ -199,6 +202,8 @@ TRACE_EVENT(xen_mmu_pte_clear,
199202
__entry->mm, __entry->addr, __entry->ptep)
200203
);
201204

205+
TRACE_DEFINE_SIZEOF(pmdval_t);
206+
202207
TRACE_EVENT(xen_mmu_set_pmd,
203208
TP_PROTO(pmd_t *pmdp, pmd_t pmdval),
204209
TP_ARGS(pmdp, pmdval),
@@ -226,6 +231,8 @@ TRACE_EVENT(xen_mmu_pmd_clear,
226231

227232
#if CONFIG_PGTABLE_LEVELS >= 4
228233

234+
TRACE_DEFINE_SIZEOF(pudval_t);
235+
229236
TRACE_EVENT(xen_mmu_set_pud,
230237
TP_PROTO(pud_t *pudp, pud_t pudval),
231238
TP_ARGS(pudp, pudval),
@@ -241,6 +248,8 @@ TRACE_EVENT(xen_mmu_set_pud,
241248
(int)sizeof(pudval_t) * 2, (unsigned long long)__entry->pudval)
242249
);
243250

251+
TRACE_DEFINE_SIZEOF(p4dval_t);
252+
244253
TRACE_EVENT(xen_mmu_set_p4d,
245254
TP_PROTO(p4d_t *p4dp, p4d_t *user_p4dp, p4d_t p4dval),
246255
TP_ARGS(p4dp, user_p4dp, p4dval),

‎include/trace/trace_events.h‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,28 @@ TRACE_MAKE_SYSTEM_STR();
3535

3636
#undef TRACE_DEFINE_ENUM
3737
#define TRACE_DEFINE_ENUM(a) \
38-
static struct trace_enum_map __used __initdata \
38+
static struct trace_eval_map __used __initdata \
3939
__##TRACE_SYSTEM##_##a = \
4040
{ \
4141
.system = TRACE_SYSTEM_STRING, \
42-
.enum_string = #a, \
43-
.enum_value = a \
42+
.eval_string = #a, \
43+
.eval_value = a \
4444
}; \
45-
static struct trace_enum_map __used \
46-
__attribute__((section("_ftrace_enum_map"))) \
45+
static struct trace_eval_map __used \
46+
__attribute__((section("_ftrace_eval_map"))) \
47+
*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
48+
49+
#undef TRACE_DEFINE_SIZEOF
50+
#define TRACE_DEFINE_SIZEOF(a) \
51+
static struct trace_eval_map __used __initdata \
52+
__##TRACE_SYSTEM##_##a = \
53+
{ \
54+
.system = TRACE_SYSTEM_STRING, \
55+
.eval_string = "sizeof(" #a ")", \
56+
.eval_value = sizeof(a) \
57+
}; \
58+
static struct trace_eval_map __used \
59+
__attribute__((section("_ftrace_eval_map"))) \
4760
*TRACE_SYSTEM##_##a = &__##TRACE_SYSTEM##_##a
4861

4962
/*
@@ -158,6 +171,9 @@ TRACE_MAKE_SYSTEM_STR();
158171
#undef TRACE_DEFINE_ENUM
159172
#define TRACE_DEFINE_ENUM(a)
160173

174+
#undef TRACE_DEFINE_SIZEOF
175+
#define TRACE_DEFINE_SIZEOF(a)
176+
161177
#undef __field
162178
#define __field(type, item)
163179

‎kernel/module.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,9 +3074,9 @@ static int find_module_sections(struct module *mod, struct load_info *info)
30743074
mod->trace_events = section_objs(info, "_ftrace_events",
30753075
sizeof(*mod->trace_events),
30763076
&mod->num_trace_events);
3077-
mod->trace_enums = section_objs(info, "_ftrace_enum_map",
3078-
sizeof(*mod->trace_enums),
3079-
&mod->num_trace_enums);
3077+
mod->trace_evals = section_objs(info, "_ftrace_eval_map",
3078+
sizeof(*mod->trace_evals),
3079+
&mod->num_trace_evals);
30803080
#endif
30813081
#ifdef CONFIG_TRACING
30823082
mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",

0 commit comments

Comments
 (0)