Skip to content

Commit 744fab2

Browse files
committed
Merge tag 'trace-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull tracing updates from Steven Rostedt: - Add option traceoff_after_boot In order to debug kernel boot, it sometimes is helpful to enable tracing via the kernel command line. Unfortunately, by the time the login prompt appears, the trace is overwritten by the init process and other user space start up applications. Adding a "traceoff_after_boot" will disable tracing when the kernel passes control to init which will allow developers to be able to see the traces that occurred during boot. - Clean up the mmflags macros that display the GFP flags in trace events The macros to print the GFP flags for trace events had a bit of duplication. The code was restructured to remove duplication and in the process it also adds some flags that were missed before. - Removed some dead code and scripts/draw_functrace.py draw_functrace.py hasn't worked in years and as nobody complained about it, remove it. - Constify struct event_trigger_ops The event_trigger_ops is just a structure that has function pointers that are assigned when the variables are created. These variables should all be constants. - Other minor clean ups and fixes * tag 'trace-v6.15' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Replace strncpy with memcpy for fixed-length substring copy tracing: Fix synth event printk format for str fields tracing: Do not use PERF enums when perf is not defined tracing: Ensure module defining synth event cannot be unloaded while tracing tracing: fix return value in __ftrace_event_enable_disable for TRACE_REG_UNREGISTER tracing/osnoise: Fix possible recursive locking for cpus_read_lock() tracing: Align synth event print fmt tracing: gfp: vsprintf: Do not print "none" when using %pGg printf format tracepoint: Print the function symbol when tracepoint_debug is set tracing: Constify struct event_trigger_ops scripts/tracing: Remove scripts/tracing/draw_functrace.py tracing: Update MAINTAINERS file to include tracepoint.c tracing/user_events: Slightly simplify user_seq_show() tracing/user_events: Don't use %pK through printk tracing: gfp: Remove duplication of recording GFP flags tracing: Remove orphaned event_trace_printk ring-buffer: Fix typo in comment about header page pointer tracing: Add traceoff_after_boot option
2 parents 88221ac + e0344f9 commit 744fab2

File tree

16 files changed

+108
-225
lines changed

16 files changed

+108
-225
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7289,6 +7289,15 @@
72897289
See also "Event triggers" in Documentation/trace/events.rst
72907290

72917291

7292+
traceoff_after_boot
7293+
[FTRACE] Sometimes tracing is used to debug issues
7294+
during the boot process. Since the trace buffer has a
7295+
limited amount of storage, it may be prudent to
7296+
disable tracing after the boot is finished, otherwise
7297+
the critical information may be overwritten. With this
7298+
option, the main tracing buffer will be turned off at
7299+
the end of the boot process.
7300+
72927301
traceoff_on_warning
72937302
[FTRACE] enable this option to disable tracing when a
72947303
warning is hit. This turns off "tracing_on". Tracing can

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24233,6 +24233,7 @@ F: fs/tracefs/
2423324233
F: include/linux/trace*.h
2423424234
F: include/trace/
2423524235
F: kernel/trace/
24236+
F: kernel/tracepoint.c
2423624237
F: scripts/tracing/
2423724238
F: tools/testing/selftests/ftrace/
2423824239

include/linux/trace_events.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -859,24 +859,6 @@ int ftrace_set_clr_event(struct trace_array *tr, char *buf, int set);
859859
int trace_set_clr_event(const char *system, const char *event, int set);
860860
int trace_array_set_clr_event(struct trace_array *tr, const char *system,
861861
const char *event, bool enable);
862-
/*
863-
* The double __builtin_constant_p is because gcc will give us an error
864-
* if we try to allocate the static variable to fmt if it is not a
865-
* constant. Even with the outer if statement optimizing out.
866-
*/
867-
#define event_trace_printk(ip, fmt, args...) \
868-
do { \
869-
__trace_printk_check_format(fmt, ##args); \
870-
tracing_record_cmdline(current); \
871-
if (__builtin_constant_p(fmt)) { \
872-
static const char *trace_printk_fmt \
873-
__section("__trace_printk_fmt") = \
874-
__builtin_constant_p(fmt) ? fmt : NULL; \
875-
\
876-
__trace_bprintk(ip, trace_printk_fmt, ##args); \
877-
} else \
878-
__trace_printk(ip, fmt, ##args); \
879-
} while (0)
880862

881863
#ifdef CONFIG_PERF_EVENTS
882864
struct perf_event;

include/trace/events/mmflags.h

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
7878

7979
#define gfpflag_string(flag) {(__force unsigned long)flag, #flag}
8080

81+
/*
82+
* For the values that match the bits, use the TRACE_GFP_FLAGS
83+
* which will allow any updates to be included automatically.
84+
*/
85+
#undef TRACE_GFP_EM
86+
#define TRACE_GFP_EM(a) gfpflag_string(__GFP_##a),
87+
8188
#define __def_gfpflag_names \
8289
gfpflag_string(GFP_TRANSHUGE), \
8390
gfpflag_string(GFP_TRANSHUGE_LIGHT), \
@@ -91,41 +98,13 @@ TRACE_DEFINE_ENUM(___GFP_LAST_BIT);
9198
gfpflag_string(GFP_NOIO), \
9299
gfpflag_string(GFP_NOWAIT), \
93100
gfpflag_string(GFP_DMA), \
94-
gfpflag_string(__GFP_HIGHMEM), \
95101
gfpflag_string(GFP_DMA32), \
96-
gfpflag_string(__GFP_HIGH), \
97-
gfpflag_string(__GFP_IO), \
98-
gfpflag_string(__GFP_FS), \
99-
gfpflag_string(__GFP_NOWARN), \
100-
gfpflag_string(__GFP_RETRY_MAYFAIL), \
101-
gfpflag_string(__GFP_NOFAIL), \
102-
gfpflag_string(__GFP_NORETRY), \
103-
gfpflag_string(__GFP_COMP), \
104-
gfpflag_string(__GFP_ZERO), \
105-
gfpflag_string(__GFP_NOMEMALLOC), \
106-
gfpflag_string(__GFP_MEMALLOC), \
107-
gfpflag_string(__GFP_HARDWALL), \
108-
gfpflag_string(__GFP_THISNODE), \
109-
gfpflag_string(__GFP_RECLAIMABLE), \
110-
gfpflag_string(__GFP_MOVABLE), \
111-
gfpflag_string(__GFP_ACCOUNT), \
112-
gfpflag_string(__GFP_WRITE), \
113102
gfpflag_string(__GFP_RECLAIM), \
114-
gfpflag_string(__GFP_DIRECT_RECLAIM), \
115-
gfpflag_string(__GFP_KSWAPD_RECLAIM), \
116-
gfpflag_string(__GFP_ZEROTAGS)
117-
118-
#ifdef CONFIG_KASAN_HW_TAGS
119-
#define __def_gfpflag_names_kasan , \
120-
gfpflag_string(__GFP_SKIP_ZERO), \
121-
gfpflag_string(__GFP_SKIP_KASAN)
122-
#else
123-
#define __def_gfpflag_names_kasan
124-
#endif
103+
TRACE_GFP_FLAGS \
104+
{ 0, NULL }
125105

126106
#define show_gfp_flags(flags) \
127-
(flags) ? __print_flags(flags, "|", \
128-
__def_gfpflag_names __def_gfpflag_names_kasan \
107+
(flags) ? __print_flags(flags, "|", __def_gfpflag_names \
129108
) : "none"
130109

131110
#ifdef CONFIG_MMU

kernel/trace/ring_buffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5318,7 +5318,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
53185318
* moving it. The page before the header page has the
53195319
* flag bit '1' set if it is pointing to the page we want.
53205320
* but if the writer is in the process of moving it
5321-
* than it will be '2' or already moved '0'.
5321+
* then it will be '2' or already moved '0'.
53225322
*/
53235323

53245324
ret = rb_head_page_replace(reader, cpu_buffer->reader_page);

kernel/trace/trace.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ void __init disable_tracing_selftest(const char *reason)
8787
static struct trace_iterator *tracepoint_print_iter;
8888
int tracepoint_printk;
8989
static bool tracepoint_printk_stop_on_boot __initdata;
90+
static bool traceoff_after_boot __initdata;
9091
static DEFINE_STATIC_KEY_FALSE(tracepoint_printk_key);
9192

9293
/* For tracers that don't implement custom flags */
@@ -330,6 +331,13 @@ static int __init set_tracepoint_printk_stop(char *str)
330331
}
331332
__setup("tp_printk_stop_on_boot", set_tracepoint_printk_stop);
332333

334+
static int __init set_traceoff_after_boot(char *str)
335+
{
336+
traceoff_after_boot = true;
337+
return 1;
338+
}
339+
__setup("traceoff_after_boot", set_traceoff_after_boot);
340+
333341
unsigned long long ns2usecs(u64 nsec)
334342
{
335343
nsec += 500;
@@ -10709,6 +10717,9 @@ __init static int late_trace_init(void)
1070910717
tracepoint_printk = 0;
1071010718
}
1071110719

10720+
if (traceoff_after_boot)
10721+
tracing_off();
10722+
1071210723
tracing_set_default_clock();
1071310724
clear_boot_tracer();
1071410725
return 0;

kernel/trace/trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ struct event_trigger_data {
17171717
unsigned long count;
17181718
int ref;
17191719
int flags;
1720-
struct event_trigger_ops *ops;
1720+
const struct event_trigger_ops *ops;
17211721
struct event_command *cmd_ops;
17221722
struct event_filter __rcu *filter;
17231723
char *filter_str;
@@ -1962,7 +1962,7 @@ struct event_command {
19621962
int (*set_filter)(char *filter_str,
19631963
struct event_trigger_data *data,
19641964
struct trace_event_file *file);
1965-
struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
1965+
const struct event_trigger_ops *(*get_trigger_ops)(char *cmd, char *param);
19661966
};
19671967

19681968
/**

kernel/trace/trace_eprobe.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static void eprobe_trigger_func(struct event_trigger_data *data,
478478
__eprobe_trace_func(edata, rec);
479479
}
480480

481-
static struct event_trigger_ops eprobe_trigger_ops = {
481+
static const struct event_trigger_ops eprobe_trigger_ops = {
482482
.trigger = eprobe_trigger_func,
483483
.print = eprobe_trigger_print,
484484
.init = eprobe_trigger_init,
@@ -507,8 +507,8 @@ static void eprobe_trigger_unreg_func(char *glob,
507507

508508
}
509509

510-
static struct event_trigger_ops *eprobe_trigger_get_ops(char *cmd,
511-
char *param)
510+
static const struct event_trigger_ops *eprobe_trigger_get_ops(char *cmd,
511+
char *param)
512512
{
513513
return &eprobe_trigger_ops;
514514
}

kernel/trace/trace_events.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,9 @@ static int __ftrace_event_enable_disable(struct trace_event_file *file,
790790
clear_bit(EVENT_FILE_FL_RECORDED_TGID_BIT, &file->flags);
791791
}
792792

793-
call->class->reg(call, TRACE_REG_UNREGISTER, file);
793+
ret = call->class->reg(call, TRACE_REG_UNREGISTER, file);
794+
795+
WARN_ON_ONCE(ret);
794796
}
795797
/* If in SOFT_MODE, just set the SOFT_DISABLE_BIT, else clear it */
796798
if (file->flags & EVENT_FILE_FL_SOFT_MODE)

kernel/trace/trace_events_hist.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6203,7 +6203,7 @@ static void event_hist_trigger_free(struct event_trigger_data *data)
62036203
}
62046204
}
62056205

6206-
static struct event_trigger_ops event_hist_trigger_ops = {
6206+
static const struct event_trigger_ops event_hist_trigger_ops = {
62076207
.trigger = event_hist_trigger,
62086208
.print = event_hist_trigger_print,
62096209
.init = event_hist_trigger_init,
@@ -6235,15 +6235,15 @@ static void event_hist_trigger_named_free(struct event_trigger_data *data)
62356235
}
62366236
}
62376237

6238-
static struct event_trigger_ops event_hist_trigger_named_ops = {
6238+
static const struct event_trigger_ops event_hist_trigger_named_ops = {
62396239
.trigger = event_hist_trigger,
62406240
.print = event_hist_trigger_print,
62416241
.init = event_hist_trigger_named_init,
62426242
.free = event_hist_trigger_named_free,
62436243
};
62446244

6245-
static struct event_trigger_ops *event_hist_get_trigger_ops(char *cmd,
6246-
char *param)
6245+
static const struct event_trigger_ops *event_hist_get_trigger_ops(char *cmd,
6246+
char *param)
62476247
{
62486248
return &event_hist_trigger_ops;
62496249
}
@@ -6838,38 +6838,38 @@ hist_enable_count_trigger(struct event_trigger_data *data,
68386838
hist_enable_trigger(data, buffer, rec, event);
68396839
}
68406840

6841-
static struct event_trigger_ops hist_enable_trigger_ops = {
6841+
static const struct event_trigger_ops hist_enable_trigger_ops = {
68426842
.trigger = hist_enable_trigger,
68436843
.print = event_enable_trigger_print,
68446844
.init = event_trigger_init,
68456845
.free = event_enable_trigger_free,
68466846
};
68476847

6848-
static struct event_trigger_ops hist_enable_count_trigger_ops = {
6848+
static const struct event_trigger_ops hist_enable_count_trigger_ops = {
68496849
.trigger = hist_enable_count_trigger,
68506850
.print = event_enable_trigger_print,
68516851
.init = event_trigger_init,
68526852
.free = event_enable_trigger_free,
68536853
};
68546854

6855-
static struct event_trigger_ops hist_disable_trigger_ops = {
6855+
static const struct event_trigger_ops hist_disable_trigger_ops = {
68566856
.trigger = hist_enable_trigger,
68576857
.print = event_enable_trigger_print,
68586858
.init = event_trigger_init,
68596859
.free = event_enable_trigger_free,
68606860
};
68616861

6862-
static struct event_trigger_ops hist_disable_count_trigger_ops = {
6862+
static const struct event_trigger_ops hist_disable_count_trigger_ops = {
68636863
.trigger = hist_enable_count_trigger,
68646864
.print = event_enable_trigger_print,
68656865
.init = event_trigger_init,
68666866
.free = event_enable_trigger_free,
68676867
};
68686868

6869-
static struct event_trigger_ops *
6869+
static const struct event_trigger_ops *
68706870
hist_enable_get_trigger_ops(char *cmd, char *param)
68716871
{
6872-
struct event_trigger_ops *ops;
6872+
const struct event_trigger_ops *ops;
68736873
bool enable;
68746874

68756875
enable = (strcmp(cmd, ENABLE_HIST_STR) == 0);

0 commit comments

Comments
 (0)