Skip to contentSkip to conversation

tracing: Final clean ups for 5.20 (or 6.0)

PATCH New Steven Rostedt 1 participant 6 messages Aug 3, 2022 Tracing

lore
Share & tools
lore
author maintainer
#2 lore raw

PATCH 2/5 tracepoints: It is CONFIG_TRACEPOINTS not CONFIG_TRACEPOINT

In reply to Steven Rostedt

From: Li zeming <[email protected]>

When reading this note, CONFIG_TRACEPOINT searches my configuration file, and the result is CONFIG_TRACEPOINTS, the search results are consistent with the following macro definitions. I think it should be repaired.

---
 include/linux/tracepoint.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/tracepoint.h +1 -1
index 28031b15f878..2908cc5ed70e 100644
@@ -151,7 +151,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)
 /*
  * Individual subsystem my have a separate configuration to
  * enable their tracepoints. By default, this file will create
- * the tracepoints if CONFIG_TRACEPOINT is defined. If a subsystem
+ * the tracepoints if CONFIG_TRACEPOINTS is defined. If a subsystem
  * wants to be able to disable its tracepoints from being created
  * it can define NOTRACE before including the tracepoint headers.
  */
Signature · 1 line
2.35.1
author maintainer
#3 lore raw

PATCH 3/5 scripts/tracing: Fix typo the the in comment

In reply to Steven Rostedt

From: Slark Xiao <[email protected]>

Replace 'the the' with 'the' in the comment.

---
 scripts/tracing/draw_functrace.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/tracing/draw_functrace.py +1 -1
index 7011fbe003ff..438516bdfb3c 100755
@@ -8,7 +8,7 @@ This script parses a trace provided by the function tracer in
 kernel/trace/trace_functions.c
 The resulted trace is processed into a tree to produce a more human
 view of the call stack by drawing textual but hierarchical tree of
-calls. Only the functions's names and the the call time are provided.
+calls. Only the functions's names and the call time are provided.
 
 Usage:
 	Be sure that you have CONFIG_FUNCTION_TRACER
Signature · 1 line
2.35.1

Steven Rostedt

author maintainer
#0 lore raw

cover tracing: Final clean ups for 5.20 (or 6.0)

Li zeming (1):
tracepoints: It is CONFIG_TRACEPOINTS not CONFIG_TRACEPOINT

Masami Hiramatsu (Google) (1):
tracing/eprobe: Show syntax error logs in error_log file

Slark Xiao (1):
scripts/tracing: Fix typo 'the the' in comment

Steven Rostedt (Google) (1):
tracing: Use alignof__(struct {type b;}) instead of offsetof()

Zhiqiang Liu (1):
tracing: Use free_trace_buffer() in allocate_trace_buffers()

----

 include/linux/tracepoint.h                 |  2 +-
 include/trace/stages/stage4_event_fields.h |  2 +-
 kernel/trace/trace.c                       | 25 +++++++++++--------------
 kernel/trace/trace_eprobe.c                | 11 +++++++++--
 kernel/trace/trace_probe.h                 |  5 ++++-
 scripts/tracing/draw_functrace.py          |  2 +-
 6 files changed, 27 insertions(+), 20 deletions(-)
author maintainer
#5 lore raw

PATCH 5/5 tracing: Use alignof__(struct {type b;}) instead of offsetof()

From: "Steven Rostedt (Google)" <[email protected]>

Simplify:

  #define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))

with

  #define  ALIGN_STRUCTFIELD(type) __alignof__(struct {type b;})

Which works just the same.

---
 include/trace/stages/stage4_event_fields.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/trace/stages/stage4_event_fields.h +1 -1
index 80d34f396555..a8fb25f39a99 100644
@@ -2,7 +2,7 @@
 
 /* Stage 4 definitions for creating trace events */
 
-#define ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))
+#define ALIGN_STRUCTFIELD(type) ((int)(__alignof__(struct {type b;})))
 
 #undef __field_ext
 #define __field_ext(_type, _item, _filter_type) {			\
Signature · 1 line
2.35.1
author maintainer
#4 lore raw

PATCH 4/5 tracing/eprobe: Show syntax error logs in error_log file

In reply to Steven Rostedt

From: "Masami Hiramatsu (Google)" <[email protected]>

Show the syntax errors for event probes in error_log file as same as other dynamic events, so that user can understand what is the problem.

---
 kernel/trace/trace_eprobe.c | 11 +++++++++--
 kernel/trace/trace_probe.h  |  5 ++++-
 2 files changed, 13 insertions(+), 3 deletions(-)
kernel/trace/trace_eprobe.c +9 -2
index a30f21499e81..4a0e9d927443 100644
@@ -839,8 +839,11 @@ static int trace_eprobe_tp_update_arg(struct trace_eprobe *ep, const char *argv[
 	if (ret)
 		return ret;
 
-	if (ep->tp.args[i].code->op == FETCH_OP_TP_ARG)
+	if (ep->tp.args[i].code->op == FETCH_OP_TP_ARG) {
 		ret = trace_eprobe_tp_arg_update(ep, i);
+		if (ret)
+			trace_probe_log_err(0, BAD_ATTACH_ARG);
+	}
 
 	return ret;
 }
@@ -880,8 +883,10 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 	trace_probe_log_set_index(1);
 	sys_event = argv[1];
 	ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
-	if (!sys_event || !sys_name)
+	if (!sys_event || !sys_name) {
+		trace_probe_log_err(0, NO_EVENT_INFO);
 		goto parse_error;
+	}
 
 	if (!event) {
 		strscpy(buf1, argv[1], MAX_EVENT_NAME_LEN);
@@ -896,6 +901,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
 
 	if (IS_ERR(ep)) {
 		ret = PTR_ERR(ep);
+		if (ret == -ENODEV)
+			trace_probe_log_err(0, BAD_ATTACH_EVENT);
 		/* This must return -ENOMEM or missing event, else there is a bug */
 		WARN_ON_ONCE(ret != -ENOMEM && ret != -ENODEV);
 		ep = NULL;
kernel/trace/trace_probe.h +4 -1
index 92cc149af0fd..3b3869ae8cfd 100644
@@ -442,7 +442,10 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
 	C(FAIL_REG_PROBE,	"Failed to register probe event"),\
 	C(DIFF_PROBE_TYPE,	"Probe type is different from existing probe"),\
 	C(DIFF_ARG_TYPE,	"Argument type or name is different from existing probe"),\
-	C(SAME_PROBE,		"There is already the exact same probe event"),
+	C(SAME_PROBE,		"There is already the exact same probe event"),\
+	C(NO_EVENT_INFO,	"This requires both group and event name to attach"),\
+	C(BAD_ATTACH_EVENT,	"Attached event does not exist"),\
+	C(BAD_ATTACH_ARG,	"Attached event does not have this field"),
 
 #undef C
 #define C(a, b)		TP_ERR_##a
Signature · 1 line
2.35.1
author maintainer
#1 lore raw

PATCH 1/5 tracing: Use free_trace_buffer() in allocate_trace_buffers()

In reply to Steven Rostedt

From: Zhiqiang Liu <[email protected]>

In allocate_trace_buffers(), if allocating tr->max_buffer fails, we can directly call free_trace_buffer to free tr->array_buffer.

---
 kernel/trace/trace.c | 25 +++++++++++--------------
 1 file changed, 11 insertions(+), 14 deletions(-)
kernel/trace/trace.c +11 -14
index 301305ec134b..27febd4ee33e 100644
@@ -9101,6 +9101,16 @@ allocate_trace_buffer(struct trace_array *tr, struct array_buffer *buf, int size
 	return 0;
 }
 
+static void free_trace_buffer(struct array_buffer *buf)
+{
+	if (buf->buffer) {
+		ring_buffer_free(buf->buffer);
+		buf->buffer = NULL;
+		free_percpu(buf->data);
+		buf->data = NULL;
+	}
+}
+
 static int allocate_trace_buffers(struct trace_array *tr, int size)
 {
 	int ret;
@@ -9113,10 +9123,7 @@ static int allocate_trace_buffers(struct trace_array *tr, int size)
 	ret = allocate_trace_buffer(tr, &tr->max_buffer,
 				    allocate_snapshot ? size : 1);
 	if (MEM_FAIL(ret, "Failed to allocate trace buffer\n")) {
-		ring_buffer_free(tr->array_buffer.buffer);
-		tr->array_buffer.buffer = NULL;
-		free_percpu(tr->array_buffer.data);
-		tr->array_buffer.data = NULL;
+		free_trace_buffer(&tr->array_buffer);
 		return -ENOMEM;
 	}
 	tr->allocated_snapshot = allocate_snapshot;
@@ -9131,16 +9138,6 @@ static int allocate_trace_buffers(struct trace_array *tr, int size)
 	return 0;
 }
 
-static void free_trace_buffer(struct array_buffer *buf)
-{
-	if (buf->buffer) {
-		ring_buffer_free(buf->buffer);
-		buf->buffer = NULL;
-		free_percpu(buf->data);
-		buf->data = NULL;
-	}
-}
-
 static void free_trace_buffers(struct trace_array *tr)
 {
 	if (!tr)
Signature · 1 line
2.35.1