btrfs: tracepoints: fix btrfs_trigger_flush symbolic string for flags

When tracepoints use __print_symbolic to print textual representation of
a value that comes from an ENUM each enum value needs to be exported
to user space so that user space tools can convert the binary value
data to the trings as user space does not know what those enums are
about.

Doing a trace-cmd record && trace-cmd report currently results in:

kworker/u8:1-61    [000]    66.299527:
	btrfs_flush_space:    5302ee13-c65e-45bb-98ef-8fe3835bd943:
	state=3(0x3) flags=4(METADATA) num_bytes=2621440 ret=0

I.e state is not translated to its symbolic counterpart. With this patch
applied the output is:

fio-370   [002]    56.762402: btrfs_trigger_flush:  d04cd7ac-38e2-452f-a7f5-8157529fd5f0:
	preempt: flush=3(BTRFS_RESERVE_FLUSH_ALL) flags=4(METADATA) bytes=655360

See also 190f0b76ca ("mm: tracing: Export enums in tracepoints to user
space").

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Nikolay Borisov 2020-06-19 15:24:46 +03:00 committed by David Sterba
parent 3502a8c0dc
commit 45e31869cc

View File

@ -1042,11 +1042,33 @@ TRACE_EVENT(btrfs_space_reservation,
__entry->bytes) __entry->bytes)
); );
#define show_flush_action(action) \ #define FLUSH_ACTIONS \
__print_symbolic(action, \ EM( BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH") \
{ BTRFS_RESERVE_NO_FLUSH, "BTRFS_RESERVE_NO_FLUSH"}, \ EM( BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT") \
{ BTRFS_RESERVE_FLUSH_LIMIT, "BTRFS_RESERVE_FLUSH_LIMIT"}, \ EM( BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL") \
{ BTRFS_RESERVE_FLUSH_ALL, "BTRFS_RESERVE_FLUSH_ALL"}) EMe(BTRFS_RESERVE_FLUSH_ALL_STEAL, "BTRFS_RESERVE_FLUSH_ALL_STEAL")
/*
* First define the enums in the above macros to be exported to userspace via
* TRACE_DEFINE_ENUM().
*/
#undef EM
#undef EMe
#define EM(a, b) TRACE_DEFINE_ENUM(a);
#define EMe(a, b) TRACE_DEFINE_ENUM(a);
FLUSH_ACTIONS
/*
* Now redefine the EM and EMe macros to map the enums to the strings that will
* be printed in the output
*/
#undef EM
#undef EMe
#define EM(a, b) {a, b},
#define EMe(a, b) {a, b}
TRACE_EVENT(btrfs_trigger_flush, TRACE_EVENT(btrfs_trigger_flush,
@ -1071,7 +1093,7 @@ TRACE_EVENT(btrfs_trigger_flush,
TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu", TP_printk_btrfs("%s: flush=%d(%s) flags=%llu(%s) bytes=%llu",
__get_str(reason), __entry->flush, __get_str(reason), __entry->flush,
show_flush_action(__entry->flush), __print_symbolic(__entry->flush, FLUSH_ACTIONS),
__entry->flags, __entry->flags,
__print_flags((unsigned long)__entry->flags, "|", __print_flags((unsigned long)__entry->flags, "|",
BTRFS_GROUP_FLAGS), BTRFS_GROUP_FLAGS),