2019-10-18 22:27:50

by Xing Zhengjun

[permalink] [raw]
Subject: [PATCH v2] tracing: fix "gfp_t" format for synthetic events

In the format of synthetic events, the "gfp_t" is shown as "signed:1",
but in fact the "gfp_t" is "unsigned", should be shown as "signed:0".

The issue can be reproduced by the following commands:

echo 'memlatency u64 lat; unsigned int order; gfp_t gfp_flags; int migratetype' > /sys/kernel/debug/tracing/synthetic_events
cat /sys/kernel/debug/tracing/events/synthetic/memlatency/format

name: memlatency
ID: 2233
format:
field:unsigned short common_type; offset:0; size:2; signed:0;
field:unsigned char common_flags; offset:2; size:1; signed:0;
field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
field:int common_pid; offset:4; size:4; signed:1;

field:u64 lat; offset:8; size:8; signed:0;
field:unsigned int order; offset:16; size:4; signed:0;
field:gfp_t gfp_flags; offset:24; size:4; signed:1;
field:int migratetype; offset:32; size:4; signed:1;

print fmt: "lat=%llu, order=%u, gfp_flags=%x, migratetype=%d", REC->lat, REC->order, REC->gfp_flags, REC->migratetype

Signed-off-by: Zhengjun Xing <[email protected]>
---
kernel/trace/trace_events_hist.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
index 57648c5aa679..7482a1466ebf 100644
--- a/kernel/trace/trace_events_hist.c
+++ b/kernel/trace/trace_events_hist.c
@@ -679,6 +679,8 @@ static bool synth_field_signed(char *type)
{
if (str_has_prefix(type, "u"))
return false;
+ if (strcmp(type, "gfp_t") == 0)
+ return false;

return true;
}
--
2.17.1


2019-10-19 08:28:15

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2] tracing: fix "gfp_t" format for synthetic events

On Fri, 18 Oct 2019 09:20:34 +0800
Zhengjun Xing <[email protected]> wrote:

> In the format of synthetic events, the "gfp_t" is shown as "signed:1",
> but in fact the "gfp_t" is "unsigned", should be shown as "signed:0".
>
> The issue can be reproduced by the following commands:
>
> echo 'memlatency u64 lat; unsigned int order; gfp_t gfp_flags; int migratetype' > /sys/kernel/debug/tracing/synthetic_events
> cat /sys/kernel/debug/tracing/events/synthetic/memlatency/format
>
> name: memlatency
> ID: 2233
> format:
> field:unsigned short common_type; offset:0; size:2; signed:0;
> field:unsigned char common_flags; offset:2; size:1; signed:0;
> field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
> field:int common_pid; offset:4; size:4; signed:1;
>
> field:u64 lat; offset:8; size:8; signed:0;
> field:unsigned int order; offset:16; size:4; signed:0;
> field:gfp_t gfp_flags; offset:24; size:4; signed:1;
> field:int migratetype; offset:32; size:4; signed:1;
>
> print fmt: "lat=%llu, order=%u, gfp_flags=%x, migratetype=%d", REC->lat, REC->order, REC->gfp_flags, REC->migratetype
>

Tom,

Can you give a Reviewed-by for this?

-- Steve

> Signed-off-by: Zhengjun Xing <[email protected]>
> ---
> kernel/trace/trace_events_hist.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 57648c5aa679..7482a1466ebf 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -679,6 +679,8 @@ static bool synth_field_signed(char *type)
> {
> if (str_has_prefix(type, "u"))
> return false;
> + if (strcmp(type, "gfp_t") == 0)
> + return false;
>
> return true;
> }

2019-10-19 08:29:58

by Tom Zanussi

[permalink] [raw]
Subject: Re: [PATCH v2] tracing: fix "gfp_t" format for synthetic events



On 10/17/2019 8:20 PM, Zhengjun Xing wrote:
> In the format of synthetic events, the "gfp_t" is shown as "signed:1",
> but in fact the "gfp_t" is "unsigned", should be shown as "signed:0".
>
> The issue can be reproduced by the following commands:
>
> echo 'memlatency u64 lat; unsigned int order; gfp_t gfp_flags; int migratetype' > /sys/kernel/debug/tracing/synthetic_events
> cat /sys/kernel/debug/tracing/events/synthetic/memlatency/format
>
> name: memlatency
> ID: 2233
> format:
> field:unsigned short common_type; offset:0; size:2; signed:0;
> field:unsigned char common_flags; offset:2; size:1; signed:0;
> field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
> field:int common_pid; offset:4; size:4; signed:1;
>
> field:u64 lat; offset:8; size:8; signed:0;
> field:unsigned int order; offset:16; size:4; signed:0;
> field:gfp_t gfp_flags; offset:24; size:4; signed:1;
> field:int migratetype; offset:32; size:4; signed:1;
>
> print fmt: "lat=%llu, order=%u, gfp_flags=%x, migratetype=%d", REC->lat, REC->order, REC->gfp_flags, REC->migratetype
>
> Signed-off-by: Zhengjun Xing <[email protected]>
> ---
> kernel/trace/trace_events_hist.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c
> index 57648c5aa679..7482a1466ebf 100644
> --- a/kernel/trace/trace_events_hist.c
> +++ b/kernel/trace/trace_events_hist.c
> @@ -679,6 +679,8 @@ static bool synth_field_signed(char *type)
> {
> if (str_has_prefix(type, "u"))
> return false;
> + if (strcmp(type, "gfp_t") == 0)
> + return false;
>
> return true;
> }
>

Reviewed-by: Tom Zanussi <[email protected]>

2019-10-19 08:30:48

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH v2] tracing: fix "gfp_t" format for synthetic events

On Fri, 18 Oct 2019 09:41:05 -0500
"Zanussi, Tom" <[email protected]> wrote:

> Reviewed-by: Tom Zanussi <[email protected]>

Thanks Zhengjun and Tom!

I'll apply this to my urgent branch and get it upstream (even though
it's a minor fix).

-- Steve