Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tracing: Have show_event_trigger/filter format a bit more in columns

By doing:

# trace-cmd sqlhist -e -n futex_wait select TIMESTAMP_DELTA_USECS as lat from sys_enter_futex as start join sys_exit_futex as end on start.common_pid = end.common_pid

and

# trace-cmd start -e futex_wait -f 'lat > 100' -e page_pool_state_release -f 'pfn == 1'

The output of the show_event_trigger and show_event_filter files are well
aligned because of the inconsistent 'tab' spacing:

~# cat /sys/kernel/tracing/show_event_triggers
syscalls:sys_exit_futex hist:keys=common_pid:vals=hitcount:__lat_12046_2=common_timestamp.usecs-$__arg_12046_1:sort=hitcount:size=2048:clock=global:onmatch(syscalls.sys_enter_futex).trace(futex_wait,$__lat_12046_2) [active]
syscalls:sys_enter_futex hist:keys=common_pid:vals=hitcount:__arg_12046_1=common_timestamp.usecs:sort=hitcount:size=2048:clock=global [active]

~# cat /sys/kernel/tracing/show_event_filters
synthetic:futex_wait (lat > 100)
page_pool:page_pool_state_release (pfn == 1)

This makes it not so easy to read. Instead, force the spacing to be at
least 32 bytes from the beginning (one space if the system:event is longer
than 30 bytes):

~# cat /sys/kernel/tracing/show_event_triggers
syscalls:sys_exit_futex hist:keys=common_pid:vals=hitcount:__lat_8125_2=common_timestamp.usecs-$__arg_8125_1:sort=hitcount:size=2048:clock=global:onmatch(syscalls.sys_enter_futex).trace(futex_wait,$__lat_8125_2) [active]
syscalls:sys_enter_futex hist:keys=common_pid:vals=hitcount:__arg_8125_1=common_timestamp.usecs:sort=hitcount:size=2048:clock=global [active]

~# cat /sys/kernel/tracing/show_event_filters
synthetic:futex_wait (lat > 100)
page_pool:page_pool_state_release (pfn == 1)

Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Link: https://patch.msgid.link/20260112153408.18373e73@gandalf.local.home
Reviewed-by: Aaron Tomlin <atomlin@atomlin.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

+22 -4
+22 -4
kernel/trace/trace_events.c
··· 1662 1662 mutex_unlock(&event_mutex); 1663 1663 } 1664 1664 1665 + static int get_call_len(struct trace_event_call *call) 1666 + { 1667 + int len; 1668 + 1669 + /* Get the length of "<system>:<event>" */ 1670 + len = strlen(call->class->system) + 1; 1671 + len += strlen(trace_event_name(call)); 1672 + 1673 + /* Set the index to 32 bytes to separate event from data */ 1674 + return len >= 32 ? 1 : 32 - len; 1675 + } 1676 + 1665 1677 /** 1666 1678 * t_show_filters - seq_file callback to display active event filters 1667 1679 * @m: The seq_file interface for formatted output ··· 1688 1676 struct trace_event_file *file = v; 1689 1677 struct trace_event_call *call = file->event_call; 1690 1678 struct event_filter *filter; 1679 + int len; 1691 1680 1692 1681 guard(rcu)(); 1693 1682 filter = rcu_dereference(file->filter); 1694 1683 if (!filter || !filter->filter_string) 1695 1684 return 0; 1696 1685 1697 - seq_printf(m, "%s:%s\t%s\n", call->class->system, 1698 - trace_event_name(call), filter->filter_string); 1686 + len = get_call_len(call); 1687 + 1688 + seq_printf(m, "%s:%s%*.s%s\n", call->class->system, 1689 + trace_event_name(call), len, "", filter->filter_string); 1699 1690 1700 1691 return 0; 1701 1692 } ··· 1717 1702 struct trace_event_file *file = v; 1718 1703 struct trace_event_call *call = file->event_call; 1719 1704 struct event_trigger_data *data; 1705 + int len; 1720 1706 1721 1707 /* 1722 1708 * The event_mutex is held by t_start(), protecting the ··· 1726 1710 if (list_empty(&file->triggers)) 1727 1711 return 0; 1728 1712 1713 + len = get_call_len(call); 1714 + 1729 1715 list_for_each_entry_rcu(data, &file->triggers, list) { 1730 - seq_printf(m, "%s:%s\t", call->class->system, 1731 - trace_event_name(call)); 1716 + seq_printf(m, "%s:%s%*.s", call->class->system, 1717 + trace_event_name(call), len, ""); 1732 1718 1733 1719 data->cmd_ops->print(m, data); 1734 1720 }