public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [for-linus][PATCH 0/7] tracing: Fixes for 5.5
@ 2020-01-06 21:19 Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 1/7] tracing: Initialize val to zero in parse_entry of inject code Steven Rostedt
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton


Colin Ian King (1):
      tracing: Fix indentation issue

Joel Fernandes (Google) (1):
      tracing: Change offset type to s32 in preempt/irq tracepoints

Kaitao Cheng (1):
      kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail

Steven Rostedt (VMware) (3):
      tracing: Initialize val to zero in parse_entry of inject code
      tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls
      tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined

Wen Yang (1):
      ftrace: Avoid potential division by zero in function profiler

----
 include/trace/events/preemptirq.h  |  8 ++++----
 kernel/trace/fgraph.c              | 14 ++++++++++++++
 kernel/trace/ftrace.c              |  6 +++---
 kernel/trace/trace_events_inject.c |  2 +-
 kernel/trace/trace_sched_wakeup.c  |  4 +++-
 kernel/trace/trace_seq.c           |  2 +-
 kernel/trace/trace_stack.c         |  5 +++++
 7 files changed, 31 insertions(+), 10 deletions(-)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 1/7] tracing: Initialize val to zero in parse_entry of inject code
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 2/7] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, kbuild test robot

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

gcc produces a variable may be uninitialized warning for "val" in
parse_entry(). This is really a false positive, but the code is subtle
enough to just initialize val to zero and it's not a fast path to worry
about it.

Marked for stable to remove the warning in the stable trees as well.

Cc: stable@vger.kernel.org
Fixes: 6c3edaf9fd6a3 ("tracing: Introduce trace event injection")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_events_inject.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_events_inject.c b/kernel/trace/trace_events_inject.c
index d45079ee62f8..22bcf7c51d1e 100644
--- a/kernel/trace/trace_events_inject.c
+++ b/kernel/trace/trace_events_inject.c
@@ -195,7 +195,7 @@ static int parse_entry(char *str, struct trace_event_call *call, void **pentry)
 	unsigned long irq_flags;
 	void *entry = NULL;
 	int entry_size;
-	u64 val;
+	u64 val = 0;
 	int len;
 
 	entry = trace_alloc_entry(call, &entry_size);
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 2/7] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 1/7] tracing: Initialize val to zero in parse_entry of inject code Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 3/7] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, kbuild test robot

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

In order to handle direct calls along side of function graph tracer, a check
is made to see if the address being traced by the function graph tracer is a
direct call or not. To get the address used by direct callers, the return
address is subtracted by MCOUNT_INSN_SIZE.

For some archs with certain configurations, MCOUNT_INSN_SIZE is undefined
here. But these should not be using direct calls anyway. Just define
MCOUNT_INSN_SIZE to zero in this case.

Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com

Reported-by: kbuild test robot <lkp@intel.com>
Fixes: ff205766dbbee ("ftrace: Fix function_graph tracer interaction with BPF trampoline")
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/fgraph.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/kernel/trace/fgraph.c b/kernel/trace/fgraph.c
index a2659735db73..1af321dec0f1 100644
--- a/kernel/trace/fgraph.c
+++ b/kernel/trace/fgraph.c
@@ -96,6 +96,20 @@ ftrace_push_return_trace(unsigned long ret, unsigned long func,
 	return 0;
 }
 
+/*
+ * Not all archs define MCOUNT_INSN_SIZE which is used to look for direct
+ * functions. But those archs currently don't support direct functions
+ * anyway, and ftrace_find_rec_direct() is just a stub for them.
+ * Define MCOUNT_INSN_SIZE to keep those archs compiling.
+ */
+#ifndef MCOUNT_INSN_SIZE
+/* Make sure this only works without direct calls */
+# ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
+#  error MCOUNT_INSN_SIZE not defined with direct calls enabled
+# endif
+# define MCOUNT_INSN_SIZE 0
+#endif
+
 int function_graph_enter(unsigned long ret, unsigned long func,
 			 unsigned long frame_pointer, unsigned long *retp)
 {
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 3/7] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 1/7] tracing: Initialize val to zero in parse_entry of inject code Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 2/7] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 4/7] ftrace: Avoid potential division by zero in function profiler Steven Rostedt
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, kbuild test robot

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

On some archs with some configurations, MCOUNT_INSN_SIZE is not defined, and
this makes the stack tracer fail to compile. Just define it to zero in this
case.

Link: https://lore.kernel.org/r/202001020219.zvE3vsty%lkp@intel.com

Cc: stable@vger.kernel.org
Fixes: 4df297129f622 ("tracing: Remove most or all of stack tracer stack size from stack_max_size")
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_stack.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index 4df9a209f7ca..c557f42a9397 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -283,6 +283,11 @@ static void check_stack(unsigned long ip, unsigned long *stack)
 	local_irq_restore(flags);
 }
 
+/* Some archs may not define MCOUNT_INSN_SIZE */
+#ifndef MCOUNT_INSN_SIZE
+# define MCOUNT_INSN_SIZE 0
+#endif
+
 static void
 stack_trace_call(unsigned long ip, unsigned long parent_ip,
 		 struct ftrace_ops *op, struct pt_regs *pt_regs)
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 4/7] ftrace: Avoid potential division by zero in function profiler
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
                   ` (2 preceding siblings ...)
  2020-01-06 21:19 ` [for-linus][PATCH 3/7] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 5/7] tracing: Change offset type to s32 in preempt/irq tracepoints Steven Rostedt
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, Wen Yang

From: Wen Yang <wenyang@linux.alibaba.com>

The ftrace_profile->counter is unsigned long and
do_div truncates it to 32 bits, which means it can test
non-zero and be truncated to zero for division.
Fix this issue by using div64_ul() instead.

Link: http://lkml.kernel.org/r/20200103030248.14516-1-wenyang@linux.alibaba.com

Cc: stable@vger.kernel.org
Fixes: e330b3bcd8319 ("tracing: Show sample std dev in function profiling")
Fixes: 34886c8bc590f ("tracing: add average time in function to function profiler")
Signed-off-by: Wen Yang <wenyang@linux.alibaba.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/ftrace.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index ac99a3500076..9bf1f2cd515e 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -526,8 +526,7 @@ static int function_stat_show(struct seq_file *m, void *v)
 	}
 
 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
-	avg = rec->time;
-	do_div(avg, rec->counter);
+	avg = div64_ul(rec->time, rec->counter);
 	if (tracing_thresh && (avg < tracing_thresh))
 		goto out;
 #endif
@@ -553,7 +552,8 @@ static int function_stat_show(struct seq_file *m, void *v)
 		 * Divide only 1000 for ns^2 -> us^2 conversion.
 		 * trace_print_graph_duration will divide 1000 again.
 		 */
-		do_div(stddev, rec->counter * (rec->counter - 1) * 1000);
+		stddev = div64_ul(stddev,
+				  rec->counter * (rec->counter - 1) * 1000);
 	}
 
 	trace_seq_init(&s);
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 5/7] tracing: Change offset type to s32 in preempt/irq tracepoints
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
                   ` (3 preceding siblings ...)
  2020-01-06 21:19 ` [for-linus][PATCH 4/7] ftrace: Avoid potential division by zero in function profiler Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 6/7] kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 7/7] tracing: Fix indentation issue Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel
  Cc: Ingo Molnar, Andrew Morton, Bjorn Helgaas, David Sterba,
	Ingo Molnar, Mike Rapoport, Rafael J. Wysocki, Sakari Ailus,
	Antonio Borneo, stable, Joel Fernandes (Google)

From: "Joel Fernandes (Google)" <joel@joelfernandes.org>

Discussion in the below link reported that symbols in modules can appear
to be before _stext on ARM architecture, causing wrapping with the
offsets of this tracepoint. Change the offset type to s32 to fix this.

Link: http://lore.kernel.org/r/20191127154428.191095-1-antonio.borneo@st.com
Link: http://lkml.kernel.org/r/20200102194625.226436-1-joel@joelfernandes.org

Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: David Sterba <dsterba@suse.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Mike Rapoport <rppt@linux.ibm.com>
Cc: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Antonio Borneo <antonio.borneo@st.com>
Cc: stable@vger.kernel.org
Fixes: d59158162e032 ("tracing: Add support for preempt and irq enable/disable events")
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 include/trace/events/preemptirq.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/include/trace/events/preemptirq.h b/include/trace/events/preemptirq.h
index 95fba0471e5b..3f249e150c0c 100644
--- a/include/trace/events/preemptirq.h
+++ b/include/trace/events/preemptirq.h
@@ -18,13 +18,13 @@ DECLARE_EVENT_CLASS(preemptirq_template,
 	TP_ARGS(ip, parent_ip),
 
 	TP_STRUCT__entry(
-		__field(u32, caller_offs)
-		__field(u32, parent_offs)
+		__field(s32, caller_offs)
+		__field(s32, parent_offs)
 	),
 
 	TP_fast_assign(
-		__entry->caller_offs = (u32)(ip - (unsigned long)_stext);
-		__entry->parent_offs = (u32)(parent_ip - (unsigned long)_stext);
+		__entry->caller_offs = (s32)(ip - (unsigned long)_stext);
+		__entry->parent_offs = (s32)(parent_ip - (unsigned long)_stext);
 	),
 
 	TP_printk("caller=%pS parent=%pS",
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 6/7] kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
                   ` (4 preceding siblings ...)
  2020-01-06 21:19 ` [for-linus][PATCH 5/7] tracing: Change offset type to s32 in preempt/irq tracepoints Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  2020-01-06 21:19 ` [for-linus][PATCH 7/7] tracing: Fix indentation issue Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, stable, Kaitao Cheng

From: Kaitao Cheng <pilgrimtao@gmail.com>

In the function, if register_trace_sched_migrate_task() returns error,
sched_switch/sched_wakeup_new/sched_wakeup won't unregister. That is
why fail_deprobe_sched_switch was added.

Link: http://lkml.kernel.org/r/20191231133530.2794-1-pilgrimtao@gmail.com

Cc: stable@vger.kernel.org
Fixes: 478142c39c8c2 ("tracing: do not grab lock in wakeup latency function tracing")
Signed-off-by: Kaitao Cheng <pilgrimtao@gmail.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_sched_wakeup.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/trace_sched_wakeup.c b/kernel/trace/trace_sched_wakeup.c
index 5e43b9664eca..617e297f46dc 100644
--- a/kernel/trace/trace_sched_wakeup.c
+++ b/kernel/trace/trace_sched_wakeup.c
@@ -630,7 +630,7 @@ static void start_wakeup_tracer(struct trace_array *tr)
 	if (ret) {
 		pr_info("wakeup trace: Couldn't activate tracepoint"
 			" probe to kernel_sched_migrate_task\n");
-		return;
+		goto fail_deprobe_sched_switch;
 	}
 
 	wakeup_reset(tr);
@@ -648,6 +648,8 @@ static void start_wakeup_tracer(struct trace_array *tr)
 		printk(KERN_ERR "failed to start wakeup tracer\n");
 
 	return;
+fail_deprobe_sched_switch:
+	unregister_trace_sched_switch(probe_wakeup_sched_switch, NULL);
 fail_deprobe_wake_new:
 	unregister_trace_sched_wakeup_new(probe_wakeup, NULL);
 fail_deprobe:
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [for-linus][PATCH 7/7] tracing: Fix indentation issue
  2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
                   ` (5 preceding siblings ...)
  2020-01-06 21:19 ` [for-linus][PATCH 6/7] kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail Steven Rostedt
@ 2020-01-06 21:19 ` Steven Rostedt
  6 siblings, 0 replies; 8+ messages in thread
From: Steven Rostedt @ 2020-01-06 21:19 UTC (permalink / raw)
  To: linux-kernel; +Cc: Ingo Molnar, Andrew Morton, Colin Ian King

From: Colin Ian King <colin.king@canonical.com>

There is a declaration that is indented one level too deeply, remove
the extraneous tab.

Link: http://lkml.kernel.org/r/20191221154825.33073-1-colin.king@canonical.com

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 kernel/trace/trace_seq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_seq.c b/kernel/trace/trace_seq.c
index 344e4c1aa09c..87de6edafd14 100644
--- a/kernel/trace/trace_seq.c
+++ b/kernel/trace/trace_seq.c
@@ -381,7 +381,7 @@ int trace_seq_hex_dump(struct trace_seq *s, const char *prefix_str,
 		       int prefix_type, int rowsize, int groupsize,
 		       const void *buf, size_t len, bool ascii)
 {
-		unsigned int save_len = s->seq.len;
+	unsigned int save_len = s->seq.len;
 
 	if (s->full)
 		return 0;
-- 
2.24.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-01-06 21:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-06 21:19 [for-linus][PATCH 0/7] tracing: Fixes for 5.5 Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 1/7] tracing: Initialize val to zero in parse_entry of inject code Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 2/7] tracing: Define MCOUNT_INSN_SIZE when not defined without direct calls Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 3/7] tracing: Have stack tracer compile when MCOUNT_INSN_SIZE is not defined Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 4/7] ftrace: Avoid potential division by zero in function profiler Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 5/7] tracing: Change offset type to s32 in preempt/irq tracepoints Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 6/7] kernel/trace: Fix do not unregister tracepoints when register sched_migrate_task fail Steven Rostedt
2020-01-06 21:19 ` [for-linus][PATCH 7/7] tracing: Fix indentation issue Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox