rtla: Updates for 6.13
Steven Rostedt
maintainercover rtla: Updates for 6.13
git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace.gittools/for-next
Head SHA1: 76b3102148135945b013797fac9b206273f0f777
Andrew Kreimer (1):
rv: Fix a typo
Ba Jing (2):
tools/rv: Correct the grammatical errors in the comments tools/rv: Correct the grammatical errors in the comments
Eder Zulian (1):
rtla: use the definition for stdout fd when calling isatty()
Gabriele Monaco (1):
rtla: Fix consistency in getopt_long for timerlat_hist
Jan Stancek (2):
tools/rtla: drop __NR_sched_getattr
tools/rtla: fix collision with glibc sched_attr/sched_set_attr
Tomas Glozar (2):
rtla/timerlat: Make timerlat_top_cpu->*_count unsigned long long
rtla/timerlat: Make timerlat_hist_cpu->*_count unsigned long long----
kernel/trace/rv/rv.c | 2 +- tools/tracing/rtla/src/osnoise_top.c | 2 +- tools/tracing/rtla/src/timerlat_hist.c | 20 +++++++++---------- tools/tracing/rtla/src/timerlat_top.c | 10 +++++----- tools/tracing/rtla/src/utils.c | 36 +++++++++++++++------------------- tools/tracing/rtla/src/utils.h | 2 ++ tools/verification/rv/src/in_kernel.c | 4 ++-- tools/verification/rv/src/trace.c | 2 +- 8 files changed, 38 insertions(+), 40 deletions(-)
Steven Rostedt
maintainerPATCH 1/9 rtla: use the definition for stdout fd when calling isatty()
From: Eder Zulian <[email protected]>
Use the STDOUT_FILENO definition when testing whether the standard output file descriptor refers to a terminal (for better redability).
--- tools/tracing/rtla/src/osnoise_top.c | 2 +- tools/tracing/rtla/src/timerlat_top.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/osnoise_top.c +1 -1
@@ -627,7 +627,7 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *pauto_house_keeping (¶ms->monitored_cpus); } -if (isatty (1 ) && !params->quiet) +if (isatty (STDOUT_FILENO ) && !params->quiet) params->pretty_output =1 ;return 0 ;
tools/tracing/rtla/src/timerlat_top.c +1 -1
@@ -850,7 +850,7 @@ timerlat_top_apply_config(struct osnoise_tool *top, struct timerlat_top_params * } } -if (isatty (1 ) && !params->quiet) +if (isatty (STDOUT_FILENO ) && !params->quiet) params->pretty_output =1 ;return 0 ;
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 2/9 tools/rv: Correct the grammatical errors in the comments
In reply to Steven RostedtFrom: Ba Jing <[email protected]>
The form of "print" should be consistent with "parses".
--- tools/verification/rv/src/in_kernel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tools/verification/rv/src/in_kernel.c +2 -2
@@ -332,7 +332,7 @@ static void ikm_print_header(struct trace_seq *s)* ikm_event_handler - callback to handle event events * * Called any time a rv:"monitor"_event events is generated. -* It parses and print event. +* It parses and prints event. */ static int ikm_event_handler(struct trace_seq *s, struct tep_record *record,
@@ -384,7 +384,7 @@ ikm_event_handler(struct trace_seq *s, struct tep_record *record,* ikm_error_handler - callback to handle error events * * Called any time a rv:"monitor"_errors events is generated. -* It parses and print event. +* It parses and prints event. */ static int ikm_error_handler(struct trace_seq *s, struct tep_record *record,
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 3/9 tools/rv: Correct the grammatical errors in the comments[2]
In reply to Steven RostedtFrom: Ba Jing <[email protected]>
The word "trace" begins with a consonant sound,
so "a" should be used instead of "an".
--- tools/verification/rv/src/trace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/verification/rv/src/trace.c +1 -1
@@ -81,7 +81,7 @@ void trace_instance_destroy(struct trace_instance *trace) }/** -* trace_instance_init - create an trace instance +* trace_instance_init - create a trace instance * * It is more than the tracefs instance, as it contains other * things required for the tracing, such as the local events and
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 4/9 Fix a typo
In reply to Steven RostedtFrom: Andrew Kreimer <[email protected]>
Fix a typo in comments.
--- kernel/trace/rv/rv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/trace/rv/rv.c +1 -1
@@ -41,7 +41,7 @@* per-task monitor, and so on), and the helper functions that glue the * monitor to the system via trace. Generally, a monitor includes some form * of trace output as a reaction for event parsing and exceptions, -* as depicted bellow: +* as depicted below: * * Linux +----- RV Monitor ----------------------------------+ Formal * Realm | | Realm
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 5/9 rtla: Fix consistency in getopt_long for timerlat_hist
In reply to Steven RostedtFrom: Gabriele Monaco <[email protected]>
Commit e9a4062e1527 ("rtla: Add --trace-buffer-size option") adds a new long option to rtla utilities, but among all affected files, timerlat_hist misses a trailing : in the corresponding short option inside the getopt string (e.g. \3:). This patch propagates the :.
Although this change is not functionally required, it improves consistency and slightly reduces the likelihood a future change would introduce a problem.
--- tools/tracing/rtla/src/timerlat_hist.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/tracing/rtla/src/timerlat_hist.c +1 -1
@@ -778,7 +778,7 @@ static struct timerlat_hist_params/* getopt_long stores the option index here. */ int option_index =0 ; - c =getopt_long (argc, argv,"a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3" , + c =getopt_long (argc, argv,"a:c:C::b:d:e:E:DhH:i:knp:P:s:t::T:uU0123456:7:8:9\1\2:\3:" , long_options, &option_index);/* detect the end of the options. */
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 6/9 tools/rtla: drop __NR_sched_getattr
In reply to Steven RostedtFrom: Jan Stancek <[email protected]>
It's not used since commit 084ce16df0f0 ("tools/rtla:
Remove unused sched_getattr() function").
--- tools/tracing/rtla/src/utils.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-)
tools/tracing/rtla/src/utils.c +14 -18
@@ -211,24 +211,20 @@ long parse_ns_duration(char *val)/* * This is a set of helper functions to use SCHED_DEADLINE. */ -#ifdef __x86_64__ -# define __NR_sched_setattr 314 -# define __NR_sched_getattr 315 -#elif __i386__ -# define __NR_sched_setattr 351 -# define __NR_sched_getattr 352 -#elif __arm__ -# define __NR_sched_setattr 380 -# define __NR_sched_getattr 381 -#elif __aarch64__ || __riscv -# define __NR_sched_setattr 274 -# define __NR_sched_getattr 275 -#elif __powerpc__ -# define __NR_sched_setattr 355 -# define __NR_sched_getattr 356 -#elif __s390x__ -# define __NR_sched_setattr 345 -# define __NR_sched_getattr 346 +#ifndef __NR_sched_setattr +# ifdef __x86_64__ +# define __NR_sched_setattr 314 +# elif __i386__ +# define __NR_sched_setattr 351 +# elif __arm__ +# define __NR_sched_setattr 380 +# elif __aarch64__ || __riscv +# define __NR_sched_setattr 274 +# elif __powerpc__ +# define __NR_sched_setattr 355 +# elif __s390x__ +# define __NR_sched_setattr 345 +# endif #endif #define SCHED_DEADLINE 6
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 7/9 tools/rtla: fix collision with glibc sched_attr/sched_set_attr
In reply to Steven RostedtFrom: Jan Stancek <[email protected]>
glibc commit 21571ca0d703 ("Linux: Add the sched_setattr and sched_getattr functions") now also provides 'struct sched_attr' and sched_setattr() which collide with the ones from rtla.
In file included from src/trace.c:11:
src/utils.h:49:8: error: redefinition of ‘struct sched_attr’
49 | struct sched_attr {
| ^~~~~~~~~~
In file included from /usr/include/bits/sched.h:60,
from /usr/include/sched.h:43,
from /usr/include/tracefs/tracefs.h:10,
from src/trace.c:4:
/usr/include/linux/sched/types.h:98:8: note: originally defined here
98 | struct sched_attr {
| ^~~~~~~~~~Define 'struct sched_attr' conditionally, similar to what strace did:
https://lore.kernel.org/all/[email protected]/
and rename rtla's version of sched_setattr() to avoid collision.
--- tools/tracing/rtla/src/utils.c | 4 ++-- tools/tracing/rtla/src/utils.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-)
tools/tracing/rtla/src/utils.c +2 -2
@@ -229,7 +229,7 @@ long parse_ns_duration(char *val)#define SCHED_DEADLINE 6 -static inline int sched_setattr (pid_t pid,const struct sched_attr *attr, +static inline int syscall_sched_setattr (pid_t pid,const struct sched_attr *attr,unsigned int flags) {return syscall (__NR_sched_setattr, pid, attr, flags); }
@@ -239,7 +239,7 @@ int __set_sched_attr(int pid, struct sched_attr *attr)int flags =0 ;int retval; - retval =sched_setattr (pid, attr, flags); + retval =syscall_sched_setattr (pid, attr, flags);if (retval <0 ) {err_msg ("Failed to set sched attributes to the pid %d: %s\n" , pid,strerror (errno));
tools/tracing/rtla/src/utils.h +2 -0
@@ -46,6 +46,7 @@ update_sum(unsigned long long *a, unsigned long long *b) *a += *b; } +#ifndef SCHED_ATTR_SIZE_VER0 struct sched_attr { uint32_t size; uint32_t sched_policy;
@@ -56,6 +57,7 @@ struct sched_attr {uint64_t sched_deadline; uint64_t sched_period; }; +#endif /* SCHED_ATTR_SIZE_VER0 */ int parse_prio (char *arg,struct sched_attr *sched_param);int parse_cpu_set (char *cpu_list,cpu_set_t *set);
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 8/9 rtla/timerlat: Make timerlat_top_cpu->*_count unsigned long long
In reply to Steven RostedtFrom: Tomas Glozar <[email protected]>
Most fields of struct timerlat_top_cpu are unsigned long long, but the fields {irq,thread,user}_count are int (32-bit signed).
This leads to overflow when tracing on a large number of CPUs for a long enough time:
$ rtla timerlat top -a20 -c 1-127 -d 12h ... 0 12:00:00 | IRQ Timer Latency (us) | Thread Timer Latency (us) CPU COUNT | cur min avg max | cur min avg max 1 #43200096 | 0 0 1 2 | 3 2 6 12 ... 127 #43200096 | 0 0 1 2 | 3 2 5 11 ALL #119144 e4 | 0 5 4 | 2 28 16
The average latency should be 0-1 for IRQ and 5-6 for thread, but is reported as 5 and 28, about 4 to 5 times more, due to the count overflowing when summed over all CPUs: 43200096 * 127 = 5486412192, however, 1191444898 (= 5486412192 mod MAX_INT) is reported instead, as seen on the last line of the output, and the averages are thus ~4.6 times higher than they should be (5486412192 / 1191444898 = ~4.6).
Fix the issue by changing {irq,thread,user}_count fields to unsigned long long, similarly to other fields in struct timerlat_top_cpu and to the count variable in timerlat_top_print_sum.
--- tools/tracing/rtla/src/timerlat_top.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
tools/tracing/rtla/src/timerlat_top.c +4 -4
@@ -54,9 +54,9 @@ struct timerlat_top_params { };struct timerlat_top_cpu { -int irq_count; -int thread_count; -int user_count; +unsigned long long irq_count; +unsigned long long thread_count; +unsigned long long user_count;unsigned long long cur_irq;unsigned long long min_irq;
@@ -280,7 +280,7 @@ static void timerlat_top_print(struct osnoise_tool *top, int cpu)/* * Unless trace is being lost, IRQ counter is always the max. */ -trace_seq_printf (s,"%3d #%-9d |" , cpu, cpu_data->irq_count); +trace_seq_printf (s,"%3d #%-9llu |" , cpu, cpu_data->irq_count);if (!cpu_data->irq_count) {trace_seq_printf (s,"%s %s %s %s |" , no_value, no_value, no_value, no_value);
Signature · 1 line
2.45.2
Steven Rostedt
maintainerPATCH 9/9 rtla/timerlat: Make timerlat_hist_cpu->*_count unsigned long long
In reply to Steven RostedtFrom: Tomas Glozar <[email protected]>
Do the same fix as in previous commit also for timerlat-hist.
--- tools/tracing/rtla/src/timerlat_hist.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tools/tracing/rtla/src/timerlat_hist.c +9 -9
@@ -62,9 +62,9 @@ struct timerlat_hist_cpu {int *thread;int *user; -int irq_count; -int thread_count; -int user_count; +unsigned long long irq_count; +unsigned long long thread_count; +unsigned long long user_count;unsigned long long min_irq;unsigned long long sum_irq;
@@ -304,15 +304,15 @@ timerlat_print_summary(struct timerlat_hist_params *params,continue ;if (!params->no_irq) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].irq_count);if (!params->no_thread) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].thread_count);if (params->user_hist) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , data->hist[cpu].user_count); }trace_seq_printf (trace->seq,"\n" );
@@ -488,15 +488,15 @@ timerlat_print_stats_all(struct timerlat_hist_params *params,trace_seq_printf (trace->seq,"count:" );if (!params->no_irq) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.irq_count);if (!params->no_thread) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.thread_count);if (params->user_hist) -trace_seq_printf (trace->seq,"%9d " , +trace_seq_printf (trace->seq,"%9llu " , sum.user_count);trace_seq_printf (trace->seq,"\n" );
Signature · 1 line
2.45.2