Skip to content

Commit

Permalink
rtla: Add hwnoise tool
Browse files Browse the repository at this point in the history
The hwnoise tool is a special mode for the osnoise top tool.

hwnoise dispatches the osnoise tracer and displays a summary of the noise.
The difference is that it runs the tracer with the OSNOISE_IRQ_DISABLE
option set, thus only allowing only hardware-related noise, resulting in
a simplified output. hwnoise has the same features of osnoise.

An example of the tool's output:

 # rtla hwnoise -c 1-11 -T 1 -d 10m -q
                                           Hardware-related Noise
 duration:   0 00:10:00 | time is in us
 CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI
   1 torvalds#599       599000000          138    99.99997           3            3           4           74
   2 torvalds#599       599000000           85    99.99998           3            3           4           75
   3 torvalds#599       599000000           86    99.99998           4            3           6           75
   4 torvalds#599       599000000           81    99.99998           4            4           2           75
   5 torvalds#599       599000000           85    99.99998           2            2           2           75

Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Jonathan Corbet <corbet@lwn.net>
  • Loading branch information
Daniel Bristot de Oliveira authored and intel-lab-lkp committed Jan 10, 2023
1 parent 6f345b9 commit 5264871
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
2 changes: 2 additions & 0 deletions tools/tracing/rtla/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ install: doc_install
$(STRIP) $(DESTDIR)$(BINDIR)/rtla
@test ! -f $(DESTDIR)$(BINDIR)/osnoise || rm $(DESTDIR)$(BINDIR)/osnoise
ln -s rtla $(DESTDIR)$(BINDIR)/osnoise
@test ! -f $(DESTDIR)$(BINDIR)/hwnoise || rm $(DESTDIR)$(BINDIR)/hwnoise
ln -s rtla $(DESTDIR)$(BINDIR)/hwnoise
@test ! -f $(DESTDIR)$(BINDIR)/timerlat || rm $(DESTDIR)$(BINDIR)/timerlat
ln -s rtla $(DESTDIR)$(BINDIR)/timerlat

Expand Down
6 changes: 6 additions & 0 deletions tools/tracing/rtla/src/osnoise.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,3 +1072,9 @@ int osnoise_main(int argc, char *argv[])
osnoise_usage(1);
exit(1);
}

int hwnoise_main(int argc, char *argv[])
{
osnoise_top_main(argc, argv);
exit(0);
}
1 change: 1 addition & 0 deletions tools/tracing/rtla/src/osnoise.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,4 @@ struct osnoise_tool *osnoise_init_trace_tool(char *tracer);
int osnoise_hist_main(int argc, char *argv[]);
int osnoise_top_main(int argc, char **argv);
int osnoise_main(int argc, char **argv);
int hwnoise_main(int argc, char **argv);
59 changes: 53 additions & 6 deletions tools/tracing/rtla/src/osnoise_top.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

enum osnoise_mode {
MODE_OSNOISE = 0,
MODE_HWNOISE
};

/*
Expand Down Expand Up @@ -148,15 +149,23 @@ osnoise_top_handler(struct trace_seq *s, struct tep_record *record,
*/
static void osnoise_top_header(struct osnoise_tool *top)
{
struct osnoise_top_params *params = top->params;
struct trace_seq *s = top->trace.seq;
char duration[26];

get_duration(top->start_time, duration, sizeof(duration));

trace_seq_printf(s, "\033[2;37;40m");
trace_seq_printf(s, " Operating System Noise");
trace_seq_printf(s, " ");
trace_seq_printf(s, " ");
trace_seq_printf(s, " ");

if (params->mode == MODE_OSNOISE) {
trace_seq_printf(s, "Operating System Noise");
trace_seq_printf(s, " ");
} else if (params->mode == MODE_HWNOISE) {
trace_seq_printf(s, "Hardware-related Noise");
}

trace_seq_printf(s, " ");
trace_seq_printf(s, "\033[0;0;0m");
trace_seq_printf(s, "\n");

Expand All @@ -167,7 +176,14 @@ static void osnoise_top_header(struct osnoise_tool *top)
trace_seq_printf(s, " Noise ");
trace_seq_printf(s, " %% CPU Aval ");
trace_seq_printf(s, " Max Noise Max Single ");
trace_seq_printf(s, " HW NMI IRQ Softirq Thread");
trace_seq_printf(s, " HW NMI");

if (params->mode == MODE_HWNOISE)
goto eol;

trace_seq_printf(s, " IRQ Softirq Thread");

eol:
trace_seq_printf(s, "\033[0;0;0m");
trace_seq_printf(s, "\n");
}
Expand All @@ -186,6 +202,7 @@ static void clear_terminal(struct trace_seq *seq)
*/
static void osnoise_top_print(struct osnoise_tool *tool, int cpu)
{
struct osnoise_top_params *params = tool->params;
struct trace_seq *s = tool->trace.seq;
struct osnoise_top_cpu *cpu_data;
struct osnoise_top_data *data;
Expand All @@ -210,6 +227,12 @@ static void osnoise_top_print(struct osnoise_tool *tool, int cpu)

trace_seq_printf(s, "%12llu ", cpu_data->hw_count);
trace_seq_printf(s, "%12llu ", cpu_data->nmi_count);

if (params->mode == MODE_HWNOISE) {
trace_seq_printf(s, "\n");
return;
}

trace_seq_printf(s, "%12llu ", cpu_data->irq_count);
trace_seq_printf(s, "%12llu ", cpu_data->softirq_count);
trace_seq_printf(s, "%12llu\n", cpu_data->thread_count);
Expand Down Expand Up @@ -251,7 +274,7 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
int i;

static const char * const msg[] = {
" usage: rtla osnoise [top] [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-h] [-q] [-D] [-d s] [-a us] [-p us] [-r us] [-s us] [-S us] \\",
" [-T us] [-t[=file]] [-e sys[:event]] [--filter <filter>] [--trigger <trigger>] \\",
" [-c cpu-list] [-P priority]",
"",
Expand Down Expand Up @@ -282,9 +305,22 @@ static void osnoise_top_usage(struct osnoise_top_params *params, char *usage)
if (usage)
fprintf(stderr, "%s\n", usage);

fprintf(stderr, "rtla osnoise top: a per-cpu summary of the OS noise (version %s)\n",
if (params->mode == MODE_OSNOISE) {
fprintf(stderr,
"rtla osnoise top: a per-cpu summary of the OS noise (version %s)\n",
VERSION);

fprintf(stderr, " usage: rtla osnoise [top]");
}

if (params->mode == MODE_HWNOISE) {
fprintf(stderr,
"rtla hwnoise: a summary of hardware-related noise (version %s)\n",
VERSION);

fprintf(stderr, " usage: rtla hwnoise");
}

for (i = 0; msg[i]; i++)
fprintf(stderr, "%s\n", msg[i]);
exit(1);
Expand All @@ -304,6 +340,9 @@ struct osnoise_top_params *osnoise_top_parse_args(int argc, char **argv)
if (!params)
exit(1);

if (strcmp(argv[0], "hwnoise") == 0)
params->mode = MODE_HWNOISE;

while (1) {
static struct option long_options[] = {
{"auto", required_argument, 0, 'a'},
Expand Down Expand Up @@ -500,6 +539,14 @@ osnoise_top_apply_config(struct osnoise_tool *tool, struct osnoise_top_params *p
}
}

if (params->mode == MODE_HWNOISE) {
retval = osnoise_set_irq_disable(tool->context, 1);
if (retval) {
err_msg("Failed to set OSNOISE_IRQ_DISABLE option\n");
goto out_err;
}
}

return 0;

out_err:
Expand Down
4 changes: 4 additions & 0 deletions tools/tracing/rtla/src/rtla.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ static void rtla_usage(int err)
"",
" commands:",
" osnoise - gives information about the operating system noise (osnoise)",
" hwnoise - gives information about hardware-related noise",
" timerlat - measures the timer irq and thread latency",
"",
NULL,
Expand All @@ -47,6 +48,9 @@ int run_command(int argc, char **argv, int start_position)
if (strcmp(argv[start_position], "osnoise") == 0) {
osnoise_main(argc-start_position, &argv[start_position]);
goto ran;
} else if (strcmp(argv[start_position], "hwnoise") == 0) {
hwnoise_main(argc-start_position, &argv[start_position]);
goto ran;
} else if (strcmp(argv[start_position], "timerlat") == 0) {
timerlat_main(argc-start_position, &argv[start_position]);
goto ran;
Expand Down

0 comments on commit 5264871

Please sign in to comment.