Skip to contentSkip to conversation

ftrace fixes

PATCH Superseded Sven Schnelle 4 participants 12 messages Dec 18, 2019 – Dec 21, 2019

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

Hi Steve,

here are a few other patches i made to fix some ftrace and ftrace test problems i've seen on s390.

Regards
Sven

#1 lore raw

PATCH 1/3 selftests/ftrace: fix glob selftest

test.d/ftrace/func-filter-glob.tc is failing on s390 because it has ARCH_INLINE_SPIN_LOCK and friends set to 'y'. So the usual __raw_spin_lock symbol isn't in the ftrace function list. Change '*aw*lock' to '*time*ns' which would hopefully match some of the ktime_() functions on all platforms.

---
 .../testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +1 -1
index 27a54a17da65..a5d61667cd56 100644
@@ -30,7 +30,7 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$'
 ftrace_filter_check 'schedule*' '^schedule.*$'
 
 # filter by *mid*end
-ftrace_filter_check '*aw*lock' '.*aw.*lock$'
+ftrace_filter_check '*time*ns' '.*time.*ns$'
 
 # filter by start*mid*
 ftrace_filter_check 'mutex*try*' '^mutex.*try.*'
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 1/3] selftests/ftrace: fix glob selftest

Quoted 5 lines · On Wed, 18 Dec 2019 08:44:25 +0100 Sven Schnelle <[email protected]> wrote:

test.d/ftrace/func-filter-glob.tc is failing on s390 because it has ARCH_INLINE_SPIN_LOCK and friends set to 'y'. So the usual __raw_spin_lock symbol isn't in the ftrace function list. Change '*aw*lock' to '*time*ns' which would hopefully match some of the ktime_() functions on all platforms.

This requires an ack from Masami, and this patch can go through Shuah's tree.

Also, any patches for the Linux kernel should be Cc'd to lkml. The linux-trace-devel is mostly for tracing tools, not kernel patches.

-- Steve

Quoted 19 lines
---
 .../testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +1 -1
index 27a54a17da65..a5d61667cd56 100644
@@ -30,7 +30,7 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$'
 ftrace_filter_check 'schedule*' '^schedule.*$'
 
 # filter by *mid*end
-ftrace_filter_check '*aw*lock' '.*aw.*lock$'
+ftrace_filter_check '*time*ns' '.*time.*ns$'
 
 # filter by start*mid*
 ftrace_filter_check 'mutex*try*' '^mutex.*try.*'
maintainer
#3 lore raw

Re: [PATCH 1/3] selftests/ftrace: fix glob selftest

Quoted 9 lines · On Thu, 19 Dec 2019 18:31:51 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Wed, 18 Dec 2019 08:44:25 +0100 Sven Schnelle <[email protected]> wrote:

test.d/ftrace/func-filter-glob.tc is failing on s390 because it has ARCH_INLINE_SPIN_LOCK and friends set to 'y'. So the usual __raw_spin_lock symbol isn't in the ftrace function list. Change '*aw*lock' to '*time*ns' which would hopefully match some of the ktime_() functions on all platforms.

Quoted 5 lines

This requires an ack from Masami, and this patch can go through Shuah's tree.

Also, any patches for the Linux kernel should be Cc'd to lkml. The linux-trace-devel is mostly for tracing tools, not kernel patches.

Thanks Steve to CC to me.
BTW, are there any reason why we use different symbols for different glob patterns?
I mean we can use 'schedul*', '*chedule' and '*sch*ule' as test glob patterns.

Thank you,

Quoted 23 lines

-- Steve

Quoted 19 lines
---
 .../testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/ftrace/test.d/ftrace/func-filter-glob.tc +1 -1
index 27a54a17da65..a5d61667cd56 100644
@@ -30,7 +30,7 @@ ftrace_filter_check '*schedule*' '^.*schedule.*$'
 ftrace_filter_check 'schedule*' '^schedule.*$'
 
 # filter by *mid*end
-ftrace_filter_check '*aw*lock' '.*aw.*lock$'
+ftrace_filter_check '*time*ns' '.*time.*ns$'
 
 # filter by start*mid*
 ftrace_filter_check 'mutex*try*' '^mutex.*try.*'
Signature · 1 line
Masami Hiramatsu <[email protected]>
#4 lore raw

Re: [PATCH 1/3] selftests/ftrace: fix glob selftest

Hi,

Quoted 15 lines · Masami Hiramatsu
Quoted 12 lines · On Thu, 19 Dec 2019 18:31:51 -0500 Steven Rostedt <[email protected]> wrote:
Quoted 5 lines · On Wed, 18 Dec 2019 08:44:25 +0100 Sven Schnelle <[email protected]> wrote:

test.d/ftrace/func-filter-glob.tc is failing on s390 because it has ARCH_INLINE_SPIN_LOCK and friends set to 'y'. So the usual __raw_spin_lock symbol isn't in the ftrace function list. Change '*aw*lock' to '*time*ns' which would hopefully match some of the ktime_() functions on all platforms.

This requires an ack from Masami, and this patch can go through Shuah's tree.

Quoted 8 lines
Quoted 2 lines

Also, any patches for the Linux kernel should be Cc'd to lkml. The linux-trace-devel is mostly for tracing tools, not kernel patches.

Thanks Steve to CC to me.
BTW, are there any reason why we use different symbols for different glob patterns?
I mean we can use 'schedul*', '*chedule' and '*sch*ule' as test glob patterns.

Don't know, but i don't see a reason why we should have different patterns. If there's an agreement that we prefer a common pattern i can update the patch and resend.

Regards
Sven

maintainer
#5 lore raw

Re: [PATCH 1/3] selftests/ftrace: fix glob selftest

Quoted 9 lines · On Fri, 20 Dec 2019 08:32:40 +0100 Sven Schnelle <[email protected]> wrote:
Quoted 5 lines

Thanks Steve to CC to me.
BTW, are there any reason why we use different symbols for different glob patterns?
I mean we can use 'schedul*', '*chedule' and '*sch*ule' as test glob patterns.

Don't know, but i don't see a reason why we should have different patterns. If there's an agreement that we prefer a common pattern i can update the patch and resend.

I think I liked trying other functions just to make sure that it was working to add a bit of churn to the mix (for the unlikely case that schedule has some fluke case).

We could just switch it all to use schedule, or we can change "aw" to "spin".

-- Steve

#6 lore raw

PATCH 2/3 samples/trace_printk: wait for IRQ work to finish

In reply to Sven Schnelle

trace_printk schedules work via irq_work_queue(), but doesn't wait until it was processed. The kprobe_module.tc testcase does:

:;: "Load module again, which means the event1 should be recorded";:
modprobe trace-printk
grep "event1:" trace

so the grep which checks the trace file might run before the irq work was processed. Fix this by adding a irq_work_sync().

---
 samples/trace_printk/trace-printk.c | 1 +
 1 file changed, 1 insertion(+)
samples/trace_printk/trace-printk.c +1 -0
index 7affc3b50b61..cfc159580263 100644
@@ -36,6 +36,7 @@ static int __init trace_printk_init(void)
 
 	/* Kick off printing in irq context */
 	irq_work_queue(&irqwork);
+	irq_work_sync(&irqwork);
 
 	trace_printk("This is a %s that will use trace_bprintk()\n",
 		     "static string");
Signature · 1 line
2.17.1
#7 lore raw

PATCH 3/3 ftrace: fix endianness bug in histogram trigger

In reply to Sven Schnelle

At least on PA-RISC and s390 synthetic histogram triggers are failing selftests because trace_event_raw_event_synth() always writes a 64 bit values, but the reader expects a field->size sized value. On little endian machines this doesn't hurt, but on big endian this makes the reader always read zero values.

---
 kernel/trace/trace_events_hist.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +20 -1
index f49d1a36d3ae..f62de5f43e79 100644
@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
 			strscpy(str_field, str_val, STR_VAR_LEN_MAX);
 			n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
 		} else {
-			entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
+			struct synth_field *field = event->fields[i];
+			u64 val = var_ref_vals[var_ref_idx + i];
+
+			switch (field->size) {
+			case 1:
+				*(u8 *)&entry->fields[n_u64] = (u8)val;
+				break;
+
+			case 2:
+				*(u16 *)&entry->fields[n_u64] = (u16)val;
+				break;
+
+			case 4:
+				*(u32 *)&entry->fields[n_u64] = (u32)val;
+				break;
+
+			default:
+				entry->fields[n_u64] = val;
+				break;
+			}
 			n_u64++;
 		}
 	}
Signature · 1 line
2.17.1
maintainer
#8 lore raw

Re: [PATCH 3/3] ftrace: fix endianness bug in histogram trigger

Quoted 5 lines · On Wed, 18 Dec 2019 08:44:27 +0100 Sven Schnelle <[email protected]> wrote:

At least on PA-RISC and s390 synthetic histogram triggers are failing selftests because trace_event_raw_event_synth() always writes a 64 bit values, but the reader expects a field->size sized value. On little endian machines this doesn't hurt, but on big endian this makes the reader always read zero values.

Does this fix make the other one obsolete?

https://lore.kernel.org/r/[email protected]

-- Steve

Quoted 38 lines
---
 kernel/trace/trace_events_hist.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +20 -1
index f49d1a36d3ae..f62de5f43e79 100644
@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
 			strscpy(str_field, str_val, STR_VAR_LEN_MAX);
 			n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
 		} else {
-			entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
+			struct synth_field *field = event->fields[i];
+			u64 val = var_ref_vals[var_ref_idx + i];
+
+			switch (field->size) {
+			case 1:
+				*(u8 *)&entry->fields[n_u64] = (u8)val;
+				break;
+
+			case 2:
+				*(u16 *)&entry->fields[n_u64] = (u16)val;
+				break;
+
+			case 4:
+				*(u32 *)&entry->fields[n_u64] = (u32)val;
+				break;
+
+			default:
+				entry->fields[n_u64] = val;
+				break;
+			}
 			n_u64++;
 		}
 	}
#9 lore raw

Re: [PATCH 3/3] ftrace: fix endianness bug in histogram trigger

Hi Steve,

Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Wed, 18 Dec 2019 08:44:27 +0100 Sven Schnelle <[email protected]> wrote:

At least on PA-RISC and s390 synthetic histogram triggers are failing selftests because trace_event_raw_event_synth() always writes a 64 bit values, but the reader expects a field->size sized value. On little endian machines this doesn't hurt, but on big endian this makes the reader always read zero values.

Quoted 3 lines

Does this fix make the other one obsolete?

https://lore.kernel.org/r/[email protected]

No, that's a completely different issue, so we need both.

Regards
Sven

maintainer
#10 lore raw

Re: [PATCH 3/3] ftrace: fix endianness bug in histogram trigger

In reply to Sven Schnelle
Quoted 5 lines · On Wed, 18 Dec 2019 08:44:27 +0100 Sven Schnelle <[email protected]> wrote:

At least on PA-RISC and s390 synthetic histogram triggers are failing selftests because trace_event_raw_event_synth() always writes a 64 bit values, but the reader expects a field->size sized value. On little endian machines this doesn't hurt, but on big endian this makes the reader always read zero values.

Tom,

Does this patch look fine to you?

Also, it was only sent to linux-trace-devel. You can see the original patch here:

https://lore.kernel.org/linux-trace-devel/[email protected]/

-- Steve

Quoted 38 lines
---
 kernel/trace/trace_events_hist.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +20 -1
index f49d1a36d3ae..f62de5f43e79 100644
@@ -911,7 +911,26 @@ static notrace void trace_event_raw_event_synth(void *__data,
 			strscpy(str_field, str_val, STR_VAR_LEN_MAX);
 			n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
 		} else {
-			entry->fields[n_u64] = var_ref_vals[var_ref_idx + i];
+			struct synth_field *field = event->fields[i];
+			u64 val = var_ref_vals[var_ref_idx + i];
+
+			switch (field->size) {
+			case 1:
+				*(u8 *)&entry->fields[n_u64] = (u8)val;
+				break;
+
+			case 2:
+				*(u16 *)&entry->fields[n_u64] = (u16)val;
+				break;
+
+			case 4:
+				*(u32 *)&entry->fields[n_u64] = (u32)val;
+				break;
+
+			default:
+				entry->fields[n_u64] = val;
+				break;
+			}
 			n_u64++;
 		}
 	}
Acked-by
#11 lore raw

Re: [PATCH 3/3] ftrace: fix endianness bug in histogram trigger

Hi Steve,

Quoted 13 lines · Steven Rostedt
Quoted 9 lines · On Wed, 18 Dec 2019 08:44:27 +0100 Sven Schnelle <[email protected]> wrote:

At least on PA-RISC and s390 synthetic histogram triggers are failing
selftests because trace_event_raw_event_synth() always writes a 64 bit
values, but the reader expects a field->size sized value. On little endian
machines this doesn't hurt, but on big endian this makes the reader always
read zero values.

Quoted 3 lines

Tom,

Does this patch look fine to you?

Yeah, it looks fine to me.

Quoted 58 lines

Also, it was only sent to linux-trace-devel. You can see the original patch here:

https://lore.kernel.org/linux-trace-devel/20191218074427.96184-4-sv
[email protected]/

-- Steve

Quoted 46 lines
---
 kernel/trace/trace_events_hist.c | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
kernel/trace/trace_events_hist.c +1 -1
index f49d1a36d3ae..f62de5f43e79 100644
@@ -911,7 +911,26 @@ static notrace void
 trace_event_raw_event_synth(void *__data,
 			strscpy(str_field, str_val,
 STR_VAR_LEN_MAX);
 			n_u64 += STR_VAR_LEN_MAX / sizeof(u64);
 		} else {
-			entry->fields[n_u64] =
 var_ref_vals[var_ref_idx + i];
+			struct synth_field *field = event-
Quoted 1 line

fields[i];

kernel/trace/trace_events_hist.c +5 -0
+			u64 val = var_ref_vals[var_ref_idx + i];
+
+			switch (field->size) {
+			case 1:
+				*(u8 *)&entry->fields[n_u64] =

(u8)val;

kernel/trace/trace_events_hist.c +4 -0
+				break;
+
+			case 2:
+				*(u16 *)&entry->fields[n_u64] =

(u16)val;

kernel/trace/trace_events_hist.c +4 -0
+				break;
+
+			case 4:
+				*(u32 *)&entry->fields[n_u64] =

(u32)val;

kernel/trace/trace_events_hist.c +6 -0
+				break;
+
+			default:
+				entry->fields[n_u64] = val;
+				break;
+			}
 			n_u64++;
 		}
 	}