History

Merge tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace

Pull more tracing updates from Steven Rostedt: - Rename the staging files to give them some meaning. Just stage1,stag2,etc, does not show what they are for - Check for NULL from allocation in bootconfig - Hold event mutex for dyn_event call in user events - Mark user events to broken (to work on the API) - Remove eBPF updates from user events - Remove user events from uapi header to keep it from being installed. - Move ftrace_graph_is_dead() into inline as it is called from hot paths and also convert it into a static branch. * tag 'trace-v5.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace: tracing: Move user_events.h temporarily out of include/uapi ftrace: Make ftrace_graph_is_dead() a static branch tracing: Set user_events to BROKEN tracing/user_events: Remove eBPF interfaces tracing/user_events: Hold event_mutex during dyn_event_add proc: bootconfig: Add null pointer check tracing: Rename the staging files for trace_events

Linus Torvalds committed 4 years ago

Commit 09bb8852 parents 34a53ff 5cfff5615 files · +44 −167Browse files

Showing the changes to kernel (2 of 15 files). Show all

Unified · Split

2 files
  1. kernel/trace/fgraph.c +3 −14
  2. kernel/trace/trace_events_user.c +7 −74
kernel/trace/fgraph.c+3−14
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 *
88 * Highly modified by Steven Rostedt (VMware).
99 */
10+#include <linux/jump_label.h>
1011 #include <linux/suspend.h>
1112 #include <linux/ftrace.h>
1213 #include <linux/slab.h>
@@ -23,24 +24,12 @@ · 10 unmodified lines
2324 #define ASSIGN_OPS_HASH(opsname, val)
2425 #endif
2526
26−static bool kill_ftrace_graph;
27+DEFINE_STATIC_KEY_FALSE(kill_ftrace_graph);
2728 int ftrace_graph_active;
2829
2930 /* Both enabled by default (can be cleared by function_graph tracer flags */
3031 static bool fgraph_sleep_time = true;
3132
32−/**
33− * ftrace_graph_is_dead - returns true if ftrace_graph_stop() was called
34− *
35− * ftrace_graph_stop() is called when a severe error is detected in
36− * the function graph tracing. This function is called by the critical
37− * paths of function graph to keep those paths from doing any more harm.
38− */
39−bool ftrace_graph_is_dead(void)
40−{
41− return kill_ftrace_graph;
42−}
43−
4433 /**
4534 * ftrace_graph_stop - set to permanently disable function graph tracing
4635 *
@@ -51,7 +40,7 @@ bool ftrace_graph_is_dead(void) · 4 unmodified lines
5140 */
5241 void ftrace_graph_stop(void)
5342 {
54− kill_ftrace_graph = true;
43+ static_branch_enable(&kill_ftrace_graph);
5544 }
5645
5746 /* Add a function return address to the trace stack on thread info.*/
kernel/trace/trace_events_user.c+7−74
@@ -47,9 +47,6 @@ · 46 unmodified lines
4747 #define MAX_FIELD_ARRAY_SIZE 1024
4848 #define MAX_FIELD_ARG_NAME 256
4949
50−#define MAX_BPF_COPY_SIZE PAGE_SIZE
51−#define MAX_STACK_BPF_DATA 512
52−
5350 static char *register_page_data;
5451
5552 static DEFINE_MUTEX(reg_mutex);
@@ -410,19 +407,6 @@ parse: · 354 unmodified lines
410407 type[0] != 'u', FILTER_OTHER);
411408 }
412409
413−static void user_event_parse_flags(struct user_event *user, char *flags)
414−{
415− char *flag;
416−
417− if (flags == NULL)
418− return;
419−
420− while ((flag = strsep(&flags, ",")) != NULL) {
421− if (strcmp(flag, "BPF_ITER") == 0)
422− user->flags |= FLAG_BPF_ITER;
423− }
424−}
425−
426410 static int user_event_parse_fields(struct user_event *user, char *args)
427411 {
428412 char *field;
@@ -718,64 +702,14 @@ discard: · 289 unmodified lines
718702 }
719703
720704 #ifdef CONFIG_PERF_EVENTS
721−static void user_event_bpf(struct user_event *user, struct iov_iter *i)
722−{
723− struct user_bpf_context context;
724− struct user_bpf_iter bpf_i;
725− char fast_data[MAX_STACK_BPF_DATA];
726− void *temp = NULL;
727−
728− if ((user->flags & FLAG_BPF_ITER) && iter_is_iovec(i)) {
729− /* Raw iterator */
730− context.data_type = USER_BPF_DATA_ITER;
731− context.data_len = i->count;
732− context.iter = &bpf_i;
733−
734− bpf_i.iov_offset = i->iov_offset;
735− bpf_i.iov = i->iov;
736− bpf_i.nr_segs = i->nr_segs;
737− } else if (i->nr_segs == 1 && iter_is_iovec(i)) {
738− /* Single buffer from user */
739− context.data_type = USER_BPF_DATA_USER;
740− context.data_len = i->count;
741− context.udata = i->iov->iov_base + i->iov_offset;
742− } else {
743− /* Multi buffer from user */
744− struct iov_iter copy = *i;
745− size_t copy_size = min_t(size_t, i->count, MAX_BPF_COPY_SIZE);
746−
747− context.data_type = USER_BPF_DATA_KERNEL;
748− context.kdata = fast_data;
749−
750− if (unlikely(copy_size > sizeof(fast_data))) {
751− temp = kmalloc(copy_size, GFP_NOWAIT);
752−
753− if (temp)
754− context.kdata = temp;
755− else
756− copy_size = sizeof(fast_data);
757− }
758−
759− context.data_len = copy_nofault(context.kdata,
760− copy_size, &copy);
761− }
762−
763− trace_call_bpf(&user->call, &context);
764−
765− kfree(temp);
766−}
767−
768705 /*
769− * Writes the user supplied payload out to perf ring buffer or eBPF program.
706+ * Writes the user supplied payload out to perf ring buffer.
770707 */
771708 static void user_event_perf(struct user_event *user, struct iov_iter *i,
772709 void *tpdata, bool *faulted)
773710 {
774711 struct hlist_head *perf_head;
775712
776− if (bpf_prog_array_valid(&user->call))
777− user_event_bpf(user, i);
778−
779713 perf_head = this_cpu_ptr(user->call.perf_events);
780714
781715 if (perf_head && !hlist_empty(perf_head)) {
@@ -1141,8 +1075,6 @@ static int user_event_parse(char *name, char *args, char *flags, · 359 unmodified lines
11411075
11421076 user->tracepoint.name = name;
11431077
1144− user_event_parse_flags(user, flags);
1145−
11461078 ret = user_event_parse_fields(user, args);
11471079
11481080 if (ret)
@@ -1170,11 +1102,11 @@ static int user_event_parse(char *name, char *args, char *flags, · 21 unmodified lines
11701102 #endif
11711103
11721104 mutex_lock(&event_mutex);
1105+
11731106 ret = user_event_trace_register(user);
1174− mutex_unlock(&event_mutex);
11751107
11761108 if (ret)
1177− goto put_user;
1109+ goto put_user_lock;
11781110
11791111 user->index = index;
11801112
@@ -1186,8 +1118,12 @@ static int user_event_parse(char *name, char *args, char *flags, · 5 unmodified lines
11861118 set_bit(user->index, page_bitmap);
11871119 hash_add(register_table, &user->node, key);
11881120
1121+ mutex_unlock(&event_mutex);
1122+
11891123 *newuser = user;
11901124 return 0;
1125+put_user_lock:
1126+ mutex_unlock(&event_mutex);
11911127 put_user:
11921128 user_event_destroy_fields(user);
11931129 user_event_destroy_validators(user);
@@ -1580,9 +1516,6 @@ static int user_seq_show(struct seq_file *m, void *p) · 386 unmodified lines
15801516 busy++;
15811517 }
15821518
1583− if (flags & FLAG_BPF_ITER)
1584− seq_puts(m, " FLAG:BPF_ITER");
1585−
15861519 seq_puts(m, "\n");
15871520 active++;
15881521 }