Commit Graph

43 Commits

Author SHA1 Message Date
Jerome Marchand fd58ed9117 rtla: Remove procps-ng dependency
Bugzilla: https://bugzilla.redhat.com/2117497

commit dada03db9bb1984826e61cfcf1418ac73848324d
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri May 13 08:45:53 2022 +0200

    rtla: Remove procps-ng dependency

    Daniel Wagner reported to me that readproc.h got deprecated. Also,
    while the procps-ng library was available on Fedora, it was not available
    on RHEL, which is a piece of evidence that it was not that used.

    rtla uses procps-ng only to find the PID of the tracers' workload.

    I used the procps-ng library to avoid reinventing the wheel. But in this
    case, reinventing the wheel took me less time than the time we already
    took trying to work around problems.

    Implement a function that reads /proc/ entries, checking if:
            - the entry is a directory
            - the directory name is composed only of digits (PID)
            - the directory contains the comm file
            - the comm file contains a comm that matches the tracers'
              workload prefix.
            - then return true; otherwise, return false.

    And use it instead of procps-ng.

    Link: https://lkml.kernel.org/r/e8276e122ee9eb2c5a0ba8e673fb6488b924b825.1652423574.git.bristot@kernel.org

    Cc: John Kacur <jkacur@redhat.com>
    Cc: Steven Rostedt <rostedt@goodmis.org>
    Cc: Tao Zhou <tao.zhou@linux.dev>
    Fixes: b1696371d865 ("rtla: Helper functions for rtla")
    Reported-by: Daniel Wagner <dwagner@suse.de>
    Reviewed-by: Daniel Wagner <dwagner@suse.de>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand fef8721e04 rtla: Fix __set_sched_attr error message
Bugzilla: https://bugzilla.redhat.com/2117497

commit 941a53c39a151e9aceef153cdfaed0f166ba01b7
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Apr 29 18:28:13 2022 +0200

    rtla: Fix __set_sched_attr error message

    rtla's function __set_sched_attr() was borrowed from stalld, but I
    forgot to update the error message to something meaningful for rtla.

     Update the error message from:
            boost_with_deadline failed to boost pid PID: STRERROR
     to a proper one:
            Failed to set sched attributes to the pid PID: STRERROR

    Link: https://lkml.kernel.org/r/a2d19b2c53f6512aefd1ee7f8c1bd19d4fc8b99d.1651247710.git.bristot@kernel.org
    Link: https://lore.kernel.org/r/eeded730413e7feaa13f946924bcf2cbf7dd9561.1650617571.git.bristot@kernel.org/

    Fixes: b1696371d865 ("rtla: Helper functions for rtla")
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand 33262a7068 rtla: Minor grammar fix for rtla README
Bugzilla: https://bugzilla.redhat.com/2117497

commit 22d146f7c1e97f4870e4497c0202939a031f740c
Author: John Kacur <jkacur@redhat.com>
Date:   Fri Apr 29 18:28:12 2022 +0200

    rtla: Minor grammar fix for rtla README

    - Change to "The rtla meta-tool includes"
    - Remove an unnecessary "But, "
    - Adjust the formatting of the paragraph resulting from the changes.
    - Simplify the wording for the libraries and tools.

    Link: https://lkml.kernel.org/r/437f0accdde53713ab3cce46f3564be00487e031.1651247710.git.bristot@kernel.org
    Link: https://lore.kernel.org/r/20220408161012.10544-1-jkacur@redhat.com/

    Cc: Daniel Bristot de Oliveria <bristot@kernel.org>
    Fixes: 79ce8f43ac5a ("rtla: Real-Time Linux Analysis tool")
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: John Kacur <jkacur@redhat.com>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand 5988e56b12 rtla: Don't overwrite existing directory mode
Bugzilla: https://bugzilla.redhat.com/2117497

commit 39c3d84cb5b52792a7323a338334d8d65b2dbe3f
Author: John Kacur <jkacur@redhat.com>
Date:   Fri Apr 29 18:28:11 2022 +0200

    rtla: Don't overwrite existing directory mode

    The mode on /usr/bin is often 555 these days,
    but make install on rtla overwrites this with 755

    Fix this by preserving the current directory if it exists.

    Link: https://lkml.kernel.org/r/8c294a6961080a1970fd8b73f7bcf1e3984579e2.1651247710.git.bristot@kernel.org
    Link: https://lore.kernel.org/r/20220402043939.6962-1-jkacur@redhat.com

    Cc: Daniel Bristot de Oliveria <bristot@redhat.com>
    Fixes: 79ce8f43ac5a ("rtla: Real-Time Linux Analysis tool")
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: John Kacur <jkacur@redhat.com>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand dd8ca2b0e9 rtla: Avoid record NULL pointer dereference
Bugzilla: https://bugzilla.redhat.com/2117497

commit 2a6b52ed72c822b5ee146a6a00ea66614fe02653
Author: Wan Jiabing <wanjiabing@vivo.com>
Date:   Fri Apr 29 18:28:10 2022 +0200

    rtla: Avoid record NULL pointer dereference

    Fix the following null/deref_null.cocci errors:
    ./tools/tracing/rtla/src/osnoise_hist.c:870:31-36: ERROR: record is NULL but dereferenced.
    ./tools/tracing/rtla/src/osnoise_top.c:650:31-36: ERROR: record is NULL but dereferenced.
    ./tools/tracing/rtla/src/timerlat_hist.c:905:31-36: ERROR: record is NULL but dereferenced.
    ./tools/tracing/rtla/src/timerlat_top.c:700:31-36: ERROR: record is NULL but dereferenced.

    "record" is NULL before calling osnoise_init_trace_tool.
    Add a tag "out_free" to avoid dereferring a NULL pointer.

    Link: https://lkml.kernel.org/r/ae0e4500d383db0884eb2820286afe34ca303778.1651247710.git.bristot@kernel.org
    Link: https://lore.kernel.org/r/20220408151406.34823-1-wanjiabing@vivo.com/

    Cc: kael_w@yeah.net
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Fixes: 51d64c3a1819 ("rtla: Add -e/--event support")
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Wan Jiabing <wanjiabing@vivo.com>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand ab9d7038c7 rtla/osnoise: Fix error message when failing to enable trace instance
Bugzilla: https://bugzilla.redhat.com/2117497

commit 90f59ee41abf587ad4675a70434136c8707fdf4b
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 18 18:57:09 2022 +0100

    rtla/osnoise: Fix error message when failing to enable trace instance

    When a trace instance creation fails, tools are printing:

            Could not enable -> osnoiser <- tracer for tracing

    Print the actual (and correct) name of the tracer it fails to enable.

    Link: https://lkml.kernel.org/r/53ef0582605af91eca14b19dba9fc9febb95d4f9.1645206561.git.bristot@kernel.org

    Fixes: b1696371d865 ("rtla: Helper functions for rtla")
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand b8cf553dbd rtla/osnoise: Free params at the exit
Bugzilla: https://bugzilla.redhat.com/2117497

commit 316f710172461c501f9b73f3b2fc7ce8aa5b84a5
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 18 18:57:08 2022 +0100

    rtla/osnoise: Free params at the exit

    The variable that stores the parsed command line arguments are not
    being free()d at the rtla osnoise top exit path.

    Free params variable before exiting.

    Link: https://lkml.kernel.org/r/0be31d8259c7c53b98a39769d60cfeecd8421785.1645206561.git.bristot@kernel.org

    Fixes: 1eceb2fc2ca5 ("rtla/osnoise: Add osnoise top mode")
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:46:25 +01:00
Jerome Marchand ba2a3422e2 tools/rtla: Fix command symlinks
Bugzilla: https://bugzilla.redhat.com/2117497

commit ff5a55dcdb343e3db9b9fb08795b78544b032773
Author: Ben Hutchings <benh@debian.org>
Date:   Sat Jul 16 15:47:08 2022 +0200

    tools/rtla: Fix command symlinks

    "ln -s" stores the next argument directly as the symlink target, so
    it needs to be a relative path.  In this case, just "rtla".

    Link: https://lore.kernel.org/linux-trace-devel/YtLBXMI6Ui4HLIF1@decadent.org.uk

    Fixes: 0605bf009f18 ("rtla: Add osnoise tool")
    Fixes: a828cd18bc4a ("rtla: Add timerlat tool and timelart top mode")
    Signed-off-by: Ben Hutchings <benh@debian.org>
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand abbc70f2b1 rtla: Fix tracer name
Bugzilla: https://bugzilla.redhat.com/2117497

commit f1432cd24c240cedf78c0d026631e3b10052c8e1
Author: Alexandre Vicenzi <alexandre.vicenzi@suse.com>
Date:   Mon Aug 8 20:03:43 2022 +0200

    rtla: Fix tracer name

    The correct tracer name is timerlat and not timelat.

    Link: https://lore.kernel.org/linux-trace-devel/20220808180343.22262-1-alexandre.vicenzi@suse.com

    Signed-off-by: Alexandre Vicenzi <alexandre.vicenzi@suse.com>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand b7c6ff0243 rtla: Fix double free
Bugzilla: https://bugzilla.redhat.com/2117497

commit 4f753c3be52c1d930afc0fe3169baa605dbaf611
Author: Andreas Schwab <schwab@suse.de>
Date:   Mon Jul 25 17:12:18 2022 +0200

    rtla: Fix double free

    Avoid double free by making trace_instance_destroy indempotent.  When
    trace_instance_init fails, it calls trace_instance_destroy, but its only
    caller osnoise_destroy_tool calls it again.

    Link: https://lkml.kernel.org/r/mvmilnlkyzx.fsf_-_@suse.de

    Fixes: 0605bf009f18 ("rtla: Add osnoise tool")
    Signed-off-by: Andreas Schwab <schwab@suse.de>
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand fa3a542730 rtla: Fix Makefile when called from -C tools/
Bugzilla: https://bugzilla.redhat.com/2117497

commit c7d8a598c5b1e21a0957f5dec2ef4139d2d1a23a
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Jul 13 23:32:19 2022 +0200

    rtla: Fix Makefile when called from -C tools/

    Sedat Dilek reported an error on rtla Makefile when running:

        $ make -C tools/ clean
        [...]
        make[2]: Entering directory
        '/home/dileks/src/linux-kernel/git/tools/tracing/rtla'
        [...]
        '/home/dileks/src/linux-kernel/git/Documentation/tools/rtla'
        /bin/sh: 1: test: rtla-make[2]:: unexpected operator    <------ The problem
        rm: cannot remove '/home/dileks/src/linux-kernel/git': Is a directory
        make[2]: *** [Makefile:120: clean] Error 1
        make[2]: Leaving directory

    This occurred because the rtla calls kernel's Makefile to get the
    version in silence mode, e.g.,

        $ make -sC ../../.. kernelversion
        5.19.0-rc4

    But the -s is being ignored when rtla's makefile is called indirectly,
    so the output looks like this:

        $ make -C ../../.. kernelversion
        make: Entering directory '/root/linux'
        5.19.0-rc4
        make: Leaving directory '/root/linux'

    Using 'grep -v make' avoids this problem, e.g.,

        $ make -C ../../.. kernelversion | grep -v make
        5.19.0-rc4

    Thus, add | grep -v make.

    Link: https://lkml.kernel.org/r/870c02d4d97a921f02a31fa3b229fc549af61a20.1657747763.git.bristot@kernel.org

    Fixes: 8619e32825fd ("rtla: Follow kernel version")
    Reported-by: Sedat Dilek <sedat.dilek@gmail.com>
    Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand 0343de6a4c rtla/utils: Use calloc and check the potential memory allocation failure
Bugzilla: https://bugzilla.redhat.com/2117497

commit b5f37a0b6f667f5c72340ca9dcd7703f261cb981
Author: jianchunfu <jianchunfu@cmss.chinamobile.com>
Date:   Wed Jun 15 15:33:48 2022 +0800

    rtla/utils: Use calloc and check the potential memory allocation failure

    Replace malloc with calloc and add memory allocating check
    of mon_cpus before used.

    Link: https://lkml.kernel.org/r/20220615073348.6891-1-jianchunfu@cmss.chinamobile.com

    Fixes: 7d0dc9576dc3 ("rtla/timerlat: Add --dma-latency option")
    Signed-off-by: jianchunfu <jianchunfu@cmss.chinamobile.com>
    Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand 6c7e5cdaf6 rtla: Tools main loop cleanup
Bugzilla: https://bugzilla.redhat.com/2117497

commit 75016ca3acd0de79868ef5b0694195fe05288ade
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:40 2022 +0100

    rtla: Tools main loop cleanup

    I probably started using "do {} while();", but changed all but osnoise_top
    to "while(){};" leaving the ; behind.

    Cleanup the main loop code, making all tools use "while() {}"

    Changcheng Deng reported this problem, as reported by coccicheck:

    Fix the following coccicheck review:
    ./tools/tracing/rtla/src/timerlat_hist.c: 800: 2-3: Unneeded semicolon
    ./tools/tracing/rtla/src/osnoise_hist.c:  776: 2-3: Unneeded semicolon
    ./tools/tracing/rtla/src/timerlat_top.c:  596: 2-3: Unneeded semicolon

    Link: https://lkml.kernel.org/r/3c1642110aa87c396f5da4a037dabc72dbb9c601.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Reported-by: Changcheng Deng <deng.changcheng@zte.com.cn>
    Reported-by: Zeal Robot <zealci@zte.com.cn>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand ce24105080 rtla/timerlat: Add --dma-latency option
Bugzilla: https://bugzilla.redhat.com/2117497

commit 7d0dc9576dc3817c483b408715e506c3e9f37bed
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:39 2022 +0100

    rtla/timerlat: Add --dma-latency option

    Add the --dma-latency to set /dev/cpu_dma_latency to the
    specified value, this aims to avoid having exit from idle
    states latencies that could be influencing the analysis.

    Link: https://lkml.kernel.org/r/72ddb0d913459f13217086dadafad88a7c46dd28.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand f0c25cc1d6 rtla/osnoise: Fix osnoise hist stop tracing message
Bugzilla: https://bugzilla.redhat.com/2117497

commit 7d38c35167c58153e8b5bea839616d00e90564b9
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:38 2022 +0100

    rtla/osnoise: Fix osnoise hist stop tracing message

    rtla osnoise hist is printing the following message when hitting stop
    tracing:

      printf("rtla timelat hit stop tracing\n");

    which is obviosly wrong.

    s/timerlat/osnoise/ fixing the printf.

    Link: https://lkml.kernel.org/r/2b8f090556fe37b81d183b74ce271421f131c77b.1646247211.git.bristot@kernel.org

    Fixes: 829a6c0b5698 ("rtla/osnoise: Add the hist mode")
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:15 +01:00
Jerome Marchand 7a2dfbd32b rtla: Check for trace off also in the trace instance
Bugzilla: https://bugzilla.redhat.com/2117497

commit 28d2160cb1a18cca87a51345e7df47499447f5a4
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:37 2022 +0100

    rtla: Check for trace off also in the trace instance

    With the addition of --trigger option, it is also possible to stop
    the trace from the -t tracing instance using the traceoff trigger.

    Make rtla tools to check if the trace is stopped also in the trace
    instance, stopping the execution of the tool.

    Link: https://lkml.kernel.org/r/59fc7c6f23dddd5c8b7ef1782cf3da51ea2ce0f5.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 6eb1cb7b86 rtla/trace: Save event histogram output to a file
Bugzilla: https://bugzilla.redhat.com/2117497

commit 761916fd02c2525139aca957b8a53fda1d8b3616
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:36 2022 +0100

    rtla/trace: Save event histogram output to a file

    The hist: trigger generates a histogram in the file sys/event/hist.
    If the hist: trigger is used, automatically save the histogram output of
    the event sys:event in the sys_event_hist.txt file.

    Link: https://lkml.kernel.org/r/b5c906af31d4e022ffe87fb0848fac5c089087c8.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 63bcc2bbcf rtla: Add --filter support
Bugzilla: https://bugzilla.redhat.com/2117497

commit 44f3a37d1d3eb10770c7fec4eb89495d37957a26
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:35 2022 +0100

    rtla: Add --filter support

    Add --filter option. This option enables a trace event filtering of the
    previous -e sys:event argument.

    This option is available for all current tools.

    Link: https://lkml.kernel.org/r/509d70b6348d3e5bcbf1f07ab725ce08d063149a.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand da8874b831 rtla/trace: Add trace event filter helpers
Bugzilla: https://bugzilla.redhat.com/2117497

commit 5487b6ce267bbafd399f3642062d974832d3eddc
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:34 2022 +0100

    rtla/trace: Add trace event filter helpers

    Add a set of helper functions to allow rtla tools to filter events
    in the trace instance.

    Link: https://lkml.kernel.org/r/12623b1684684549d53b90f4bf66fae44584fd14.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 911635dbc1 rtla: Add --trigger support
Bugzilla: https://bugzilla.redhat.com/2117497

commit 1a754893653f73724d007c2cf95cf6c47d5114c4
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:33 2022 +0100

    rtla: Add --trigger support

    Add --trigger option. This option enables a trace event trigger to the
    previous -e sys:event argument, allowing some advanced tracing options.

    For instance, in a system with CPUs 2:23 isolated, it is possible to get
    a stack trace of thread wakeup targeting those CPUs while running
    osnoise with the following command line:

     # osnoise top -c 2-23 -a 50 -e sched:sched_wakeup --trigger="stacktrace if target_cpu >= 2"

    This option is available for all current tools.

    Link: https://lkml.kernel.org/r/07d2983d5f71261d4da89dbaf02efcad100ab8ee.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand a4ba45082a rtla/trace: Add trace event trigger helpers
Bugzilla: https://bugzilla.redhat.com/2117497

commit 336c92b26cf9aee6c5d5907ef49b90d2665e9d70
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:32 2022 +0100

    rtla/trace: Add trace event trigger helpers

    Add a set of helper functions to allow rtla tools to trigger event
    actions in the trace instance.

    Link: https://lkml.kernel.org/r/e0d31abe879a78a5600b64f904d0dfa8f76e4fbb.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand dcca6dc5e8 rtla: Add -e/--event support
Bugzilla: https://bugzilla.redhat.com/2117497

commit 51d64c3a181938da8fb56404524e15776e9c6bf8
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:31 2022 +0100

    rtla: Add -e/--event support

    Add -e/--event option. This option enables an event in the trace (-t)
    session. The argument can be a specific event, e.g., -e sched:sched_switch,
    or all events of a system group, e.g., -e sched. Multiple -e are allowed.
    It is only active when -t or -a are set.

    This option is available for all current tools.

    Link: https://lkml.kernel.org/r/6a3b753be9b1e811953995f7f21a86918ad13390.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 5f97c1419a rtla/trace: Add trace events helpers
Bugzilla: https://bugzilla.redhat.com/2117497

commit b5aa0be25c27a7f21d9a28f0e0057915552d3c1b
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:30 2022 +0100

    rtla/trace: Add trace events helpers

    Add a set of helper functions to allow the rtla tools to enable
    additional tracepoints in the trace instance.

    Link: https://lkml.kernel.org/r/932398b36c1bbaa22c7810d7a40ca9b8c5595b94.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand e6303ff076 rtla/timerlat: Add the automatic trace option
Bugzilla: https://bugzilla.redhat.com/2117497

commit 173a3b014827955cefdf972ae673d94b60e31cf8
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:29 2022 +0100

    rtla/timerlat: Add the automatic trace option

    Add the -a/--auto <arg in us> option. This option sets some commonly
    used options while debugging the system. It aims to help users produce
    reports in the field, reducing the number of arguments passed to the
    tool in the first approach to a problem.

    It is equivalent to setting osnoise/stop_tracing_total_us and print_stack
    with the argument, and saving the trace to timerlat_trace.txt file if the
    trace is stopped automatically.

    Link: https://lkml.kernel.org/r/92438f7ef132c731f538cebdf77850300afe04a5.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 1a06888e71 rtla/osnoise: Add the automatic trace option
Bugzilla: https://bugzilla.redhat.com/2117497

commit 2b622edd5eb5a12c1203fdb353c2ce0681672571
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:28 2022 +0100

    rtla/osnoise: Add the automatic trace option

    Add the -a/--auto <arg in us> option. This option sets some commonly
    used options while debugging the system. It aims to help users produce
    reports in the field, reducing the number of arguments passed to the
    tool in the first approach to a problem.

    It is equivalent to setting osnoise/stop_tracing_us with the argument,
    setting tracing_thresh to 1 us, and saving the trace to osnoise_trace.txt
    file if the trace is stopped automatically.

    Link: https://lkml.kernel.org/r/ef04c961b227eb93a83cd0b54bfca45e1a381b77.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 861044e13b rtla/osnoise: Add an option to set the threshold
Bugzilla: https://bugzilla.redhat.com/2117497

commit d635316ae92291083ae7a36014e29ed7b306cb04
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:27 2022 +0100

    rtla/osnoise: Add an option to set the threshold

    Add the -T/--threshold option to set the minimum threshold to be
    considered a noise to osnoise top and hist commands. Also update
    the man pages.

    Link: https://lkml.kernel.org/r/031861200ffdb24a1df4aa72c458706889a20d5d.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 662d83b22f rtla/osnoise: Add support to adjust the tracing_thresh
Bugzilla: https://bugzilla.redhat.com/2117497

commit 61c57d578bd7ca2aff3652ed62d95e3f8fc6d16e
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Wed Mar 2 20:01:26 2022 +0100

    rtla/osnoise: Add support to adjust the tracing_thresh

    osnoise uses the tracing_thresh parameter to define the delta between
    two reads of the time to be considered a noise.

    Add support to get and set the tracing_thresh from osnoise tools.

    Link: https://lkml.kernel.org/r/715ad2a53fd40e41bab8c3f1214c1a94e12fb595.1646247211.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: Clark Williams <williams@redhat.com>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand f45fbaf802 rtla/hist: Make -E the short version of --entries
Bugzilla: https://bugzilla.redhat.com/2117497

commit dd48f316a1216fa10f9ba26852457794417d9bc6
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 18 18:57:07 2022 +0100

    rtla/hist: Make -E the short version of --entries

    Currently, --entries uses -e as the short version in the hist mode of
    timerlat and osnoise tools. But as -e is already used to enable events
    on trace sessions by other tools, thus let's keep it available for the
    same usage for all rtla tools.

    Make -E the short version of --entries for hist mode on all tools.

    Note: rtla was merged in this merge window, so rtla was not released yet.

    Link: https://lkml.kernel.org/r/5dbf0cbe7364d3a05e708926b41a097c59a02b1e.1645206561.git.bristot@kernel.org

    Cc: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand e8dfc1fbbd rtla: Fix segmentation fault when failing to enable -t
Bugzilla: https://bugzilla.redhat.com/2117497

commit 4bbf59a9db44c78dd3e5c72057548f7c1eb8d2ba
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Tue Feb 8 15:36:21 2022 +0100

    rtla: Fix segmentation fault when failing to enable -t

    rtla osnoise and timerlat are causing a segmentation fault when running
    with the --trace option on a kernel that does not support multiple
    instances. For example:

        [root@f34 rtla]# rtla osnoise top -t
        failed to enable the tracer osnoise
        Could not enable osnoiser tracer for tracing
        Failed to enable the trace instance
        Segmentation fault (core dumped)

    This error happens because the exit code of the tools is trying
    to destroy the trace instance that failed to be created.

    Make osnoise_destroy_tool() aware of possible NULL osnoise_tool *,
    and do not attempt to destroy it. This also simplifies the exit code.

    Link: https://lkml.kernel.org/r/5660a2b6bf66c2655842360f2d7f6b48db5dba23.1644327249.git.bristot@kernel.org

    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Fixes: 1eceb2fc2ca5 ("rtla/osnoise: Add osnoise top mode")
    Fixes: 829a6c0b5698 ("rtla/osnoise: Add the hist mode")
    Fixes: a828cd18bc4a ("rtla: Add timerlat tool and timelart top mode")
    Fixes: 1eeb6328e8b3 ("rtla/timerlat: Add timerlat hist mode")
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 139530dd29 rtla/trace: Error message fixup
Bugzilla: https://bugzilla.redhat.com/2117497

commit 1a6229096bb501495442ab47761d746c1ae791e1
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 4 17:24:04 2022 +0100

    rtla/trace: Error message fixup

    Use capital and change "tracer %s" to "%s tracer".

    No functional change.

    Link: https://lkml.kernel.org/r/361697d27431afefa64c67c323564205385c418d.1643990447.git.bristot@kernel.org

    Fixes: b1696371d865 ("rtla: Helper functions for rtla")
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 9aaf02d29b rtla/utils: Fix session duration parsing
Bugzilla: https://bugzilla.redhat.com/2117497

commit f35491b861290a2c8258b5f70f9bb5d5ed2a1c6f
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 4 17:24:03 2022 +0100

    rtla/utils: Fix session duration parsing

    Use gmtime to format the duration time. This avoids problems when the
    system uses local time different of Pisa's Local Time.

    Link: https://lkml.kernel.org/r/a2f0a37bc006c2561bb8ecd871cd70532b4a9f2d.1643990447.git.bristot@kernel.org

    Fixes: b1696371d865 ("rtla: Helper functions for rtla")
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:14 +01:00
Jerome Marchand 28cec40f35 rtla: Follow kernel version
Bugzilla: https://bugzilla.redhat.com/2117497

commit 8619e32825fd0af82d243e585b9aa6917b99a975
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Feb 4 17:24:02 2022 +0100

    rtla: Follow kernel version

    To avoid having commits with new version, it is just easier to follow
    kernel version.

    Link: https://lkml.kernel.org/r/9c2df0d1de65cea96c7d731fe64781a2bb90c5b3.1643990447.git.bristot@kernel.org

    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-kernel@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand 8b4b15aafd rtla: Add Documentation
Bugzilla: https://bugzilla.redhat.com/2117497

commit d40d48e1f1f25abe755521e33a67f5d2b8b9443c
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:27 2021 +0100

    rtla: Add Documentation

    Adds the basis for rtla documentation. This patch also
    includes the rtla(1) man page.

    As suggested by Jonathan Corbet, we are placing these man
    pages at Documentation/tools/rtla, using rst format. It
    is not linked to the official documentation, though.

    The Makefile is based on bpftool's Documentation one.

    Link: https://lkml.kernel.org/r/5f510f3e962fc0cd531c43f5a815544dd720c3f2.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Suggested-by: Steven Rostedt <rostedt@goodmis.org>
    Suggested-by: Jonathan Corbet <corbet@lwn.net>
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand d41638d4c0 rtla/timerlat: Add timerlat hist mode
Bugzilla: https://bugzilla.redhat.com/2117497

commit 1eeb6328e8b3a917ba0be4965f272147dbd4cf55
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:26 2021 +0100

    rtla/timerlat: Add timerlat hist mode

    The rtla hist hist mode displays a histogram of each tracer event
    occurrence, both for IRQ and timer latencies. The tool also allows
    many configurations of the timerlat tracer and the collection of
    the tracer output.

    Here is one example of the rtla timerlat hist mode output:
      ---------- %< ----------
     [root@alien ~]# rtla timerlat hist -c 0-3 -d 1M
     # RTLA timerlat histogram
     # Time unit is microseconds (us)
     # Duration:   0 00:01:00
     Index   IRQ-000   Thr-000   IRQ-001   Thr-001   IRQ-002   Thr-002   IRQ-003   Thr-003
     0         58572         0     59373         0     58691         0     58895         0
     1          1422     57021       628     57241      1310     56160      1102     56805
     2             6      2931         0      2695         0      3567         4      3031
     3             1        40         0        53         0       260         0       142
     4             0         7         0         5         0         6         0        17
     5             0         2         0         5         0         7         0         4
     6             0         0         0         2         0         1         0         1
     8             0         0         0         0         0         0         0         1
     over:         0         0         0         0         0         0         0         0
     count:    60001     60001     60001     60001     60001     60001     60001     60001
     min:          0         1         0         1         0         1         0         1
     avg:          0         1         0         1         0         1         0         1
     max:          3         5         1         6         1         6         2         8
      ---------- >% ----------

    Running
     - rtla timerlat hist --help
    provides information about the available options.

    Link: https://lkml.kernel.org/r/7049ed3c46b7d6aceab18ffe7770003dfc4ddceb.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand d2911f4ec5 rtla: Add timerlat tool and timelart top mode
Bugzilla: https://bugzilla.redhat.com/2117497

commit a828cd18bc4ad72ff6d64c0dd23dc814a6741fed
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:25 2021 +0100

    rtla: Add timerlat tool and timelart top mode

    The rtla timerlat tool is an interface for the timerlat tracer.
    The timerlat tracer dispatches a kernel thread per-cpu. These threads set a
    periodic timer to wake themselves up and go back to sleep. After the
    wakeup, they collect and generate useful information for the debugging of
    operating system timer latency.

    The timerlat tracer outputs information in two ways. It periodically
    prints the timer latency at the timer IRQ handler and the Thread handler.
    It also provides information for each noise via the osnoise tracepoints.

    The rtla timerlat top mode displays a summary of the periodic output from
    the timerlat tracer.

    Here is one example of the rtla timerlat tool output:
     ---------- %< ----------
    [root@alien ~]# rtla timerlat top -c 0-3 -d 1m
                                         Timer Latency
      0 00:01:00   |          IRQ Timer Latency (us)        |         Thread Timer Latency (us)
    CPU COUNT      |      cur       min       avg       max |      cur       min       avg       max
      0 #60001     |        0         0         0         3 |        1         1         1         6
      1 #60001     |        0         0         0         3 |        2         1         1         5
      2 #60001     |        0         0         1         6 |        1         1         2         7
      3 #60001     |        0         0         0         7 |        1         1         1        11
     ---------- >% ----------

    Running:
      # rtla timerlat --help
      # rtla timerlat top --help
    provides information about the available options.

    Link: https://lkml.kernel.org/r/e95032e20c2b88c962195bf7693bb53c9ebcced8.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand 93a7e94a59 rtla/osnoise: Add the hist mode
Bugzilla: https://bugzilla.redhat.com/2117497

commit 829a6c0b5698c7d51aa2bcd16963fcd9de295476
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:24 2021 +0100

    rtla/osnoise: Add the hist mode

    The rtla osnoise hist tool collects all osnoise:sample_threshold
    occurrence in a histogram, displaying the results in a user-friendly
    way. The tool also allows many configurations of the osnoise tracer
    and the collection of the tracer output.

    Here is one example of the rtla osnoise hist tool output:
      ---------- %< ----------
     [root@f34 ~]# rtla osnoise hist --bucket-size 10 --entries 100 -c 0-8 -d 1M -r 9000 -P F:1
     # RTLA osnoise histogram
     # Time unit is microseconds (us)
     # Duration:   0 00:01:00
     Index   CPU-000   CPU-001   CPU-002   CPU-003   CPU-004   CPU-005   CPU-006   CPU-007   CPU-008
     0           430       434       352       455       440       463       467       436       484
     10           88        88        92       141       120       100       126       166       100
     20           19         7        12        22         8         8        13        13        16
     30            6         0         2         0         1         2         2         1         0
     50            0         0         0         0         0         0         1         0         0
     over:         0         0         0         0         0         0         0         0         0
     count:      543       529       458       618       569       573       609       616       600
     min:          0         0         0         0         0         0         0         0         0
     avg:          0         0         0         0         0         0         0         0         0
     max:         30        20        30        20        30        30        50        30        20
      ---------- >% ----------

    Running
     - rtla osnoise hist --help

    provides information about the available options.

    Link: https://lkml.kernel.org/r/c68060544de89b8b62510ed91c7369f162eb465b.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand 53fe4fb75b rtla/osnoise: Add osnoise top mode
Bugzilla: https://bugzilla.redhat.com/2117497

commit 1eceb2fc2ca549a170d7ee7cd1fde2daeda646ac
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:23 2021 +0100

    rtla/osnoise: Add osnoise top mode

    The rtla osnoise tool is an interface for the osnoise tracer. The
    osnoise tracer dispatches a kernel thread per-cpu. These threads read
    the time in a loop while with preemption, softirqs and IRQs enabled,
    thus allowing all the sources of osnoise during its execution. The
    osnoise threads take note of the entry and exit point of any source
    of interferences, increasing a per-cpu interference counter. The
    osnoise tracer also saves an interference counter for each source
    of interference.

    The rtla osnoise top mode displays information about the periodic
    summary from the osnoise tracer.

    One example of rtla osnoise top output is:

    [root@alien ~]# rtla osnoise top -c 0-3 -d 1m -q -r 900000 -P F:1
                                             Operating System Noise
    duration:   0 00:01:00 | time is in us
    CPU Period       Runtime        Noise  % CPU Aval   Max Noise   Max Single          HW          NMI          IRQ      Softirq       Thread
      0 #58         52200000         1031    99.99802          91           60           0            0        52285            0          101
      1 #59         53100000            5    99.99999           5            5           0            9        53122            0           18
      2 #59         53100000            7    99.99998           7            7           0            8        53115            0           18
      3 #59         53100000         8274    99.98441         277           23           0            9        53778            0          660

    "rtla osnoise top --help" works and provide information about the
    available options.

    Link: https://lkml.kernel.org/r/0d796993abf587ae5a170bb8415c49368d4999e1.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand ffbf42e768 rtla: Add osnoise tool
Bugzilla: https://bugzilla.redhat.com/2117497

commit 0605bf009f18d558758df9edef59698bf1389b28
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:22 2021 +0100

    rtla: Add osnoise tool

    The osnoise tool is the interface for the osnoise tracer. The osnoise
    tool will have multiple "modes" with different outputs. At this point,
    no mode is included.

    The osnoise.c includes the osnoise_context abstraction. It serves to
    read-save-change-restore the default values from tracing/osnoise/
    directory. When the context is deleted, the default values are restored.

    It also includes some other helper functions for managing osnoise
    tracer sessions.

    With these bits and pieces in place, we can start adding some
    functionality to rtla.

    Link: https://lkml.kernel.org/r/2d44c21ff561f503b4c7b1813892761818118460.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand 16e275a187 rtla: Helper functions for rtla
Bugzilla: https://bugzilla.redhat.com/2117497

commit b1696371d865fa28bd20adb13d1820ef031f2ee2
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:21 2021 +0100

    rtla: Helper functions for rtla

    This is a set of utils and tracer helper functions. They are used by
    rtla mostly to parse config, display data and some trace operations that
    are not part of libtracefs (because they are only useful it for this
    case).

    Link: https://lkml.kernel.org/r/a94c128aba9e6e66d502b7094f2e8c7ac95b12e5.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Jerome Marchand 4c41e6ebc7 rtla: Real-Time Linux Analysis tool
Bugzilla: https://bugzilla.redhat.com/2117497

commit 79ce8f43ac5ac16d6d63729e858da42b0460d87b
Author: Daniel Bristot de Oliveira <bristot@kernel.org>
Date:   Fri Dec 10 19:11:20 2021 +0100

    rtla: Real-Time Linux Analysis tool

    The rtla is a meta-tool that includes a set of commands that aims
    to analyze the real-time properties of Linux. But instead of testing
    Linux as a black box, rtla leverages kernel tracing capabilities to
    provide precise information about the properties and root causes of
    unexpected results.

    rtla --help works and provide information about the available options.

    This is just the "main" and the Makefile, no function yet.

    Link: https://lkml.kernel.org/r/bf9118ed43a09e6c054c9a491cbe7411ad1acd89.1639158831.git.bristot@kernel.org

    Cc: Tao Zhou <tao.zhou@linux.dev>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Tom Zanussi <zanussi@kernel.org>
    Cc: Masami Hiramatsu <mhiramat@kernel.org>
    Cc: Juri Lelli <juri.lelli@redhat.com>
    Cc: Clark Williams <williams@redhat.com>
    Cc: John Kacur <jkacur@redhat.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Cc: Daniel Bristot de Oliveira <bristot@kernel.org>
    Cc: linux-rt-users@vger.kernel.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Daniel Bristot de Oliveira <bristot@kernel.org>
    Signed-off-by: Steven Rostedt <rostedt@goodmis.org>

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-11-08 17:42:13 +01:00
Xu Wang 421d9d1bea tools/latency-collector: Remove unneeded semicolon
Fix semicolon.cocci warning:
tools/tracing/latency/latency-collector.c:1021:2-3: Unneeded semicolon

Link: https://lkml.kernel.org/r/20210308022459.59881-1-vulab@iscas.ac.cn

Reviewed-by: Viktor Rosendahl <Viktor.Rosendahl@bmw.de>
Signed-off-by: Xu Wang <vulab@iscas.ac.cn>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2021-03-18 12:58:26 -04:00
Colin Ian King c1d96fa61e tracing/tools: fix a couple of spelling mistakes
There is a spelling mistake in the -g help option, I believe
it should be "graph".  There is also a spelling mistake in a
warning message. Fix both mistakes.

Link: https://lkml.kernel.org/r/20210225165248.22050-2-Viktor.Rosendahl@bmw.de

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Viktor Rosendahl <Viktor.Rosendahl@bmw.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2021-02-25 12:54:16 -05:00
Viktor Rosendahl e23db805da tracing/tools: Add the latency-collector to tools directory
This is a tool that is intended to work around the fact that the
preemptoff, irqsoff, and preemptirqsoff tracers only work in
overwrite mode. The idea is to act randomly in such a way that we
do not systematically lose any latencies, so that if enough testing
is done, all latencies will be captured. If the same burst of
latencies is repeated, then sooner or later we will have captured all
the latencies.

It also works with the wakeup_dl, wakeup_rt, and wakeup tracers.
However, in that case it is probably not useful to use the random
sleep functionality.

The reason why it may be desirable to catch all latencies with a long
test campaign is that for some organizations, it's necessary to test
the kernel in the field and not practical for developers to work
iteratively with field testers. Because of cost and project schedules
it is not possible to start a new test campaign every time a latency
problem has been fixed.

It uses inotify to detect changes to /sys/kernel/tracing/trace.
When a latency is detected, it will either sleep or print
immediately, depending on a function that act as an unfair coin
toss.

If immediate print is chosen, it means that we open
/sys/kernel/tracing/trace and thereby cause a blackout period
that will hide any subsequent latencies.

If sleep is chosen, it means that we wait before opening
/sys/kernel/tracing/trace, by default for 1000 ms, to see if
there is another latency during this period. If there is, then we will
lose the previous latency. The coin will be tossed again with a
different probability, and we will either print the new latency, or
possibly a subsequent one.

The probability for the unfair coin toss is chosen so that there
is equal probability to obtain any of the latencies in a burst.
However, this assumes that we make an assumption of how many
latencies there can be. By default  the program assumes that there
are no more than 2 latencies in a burst, the probability of immediate
printout will be:

1/2 and 1

Thus, the probability of getting each of the two latencies will be 1/2.

If we ever find that there is more than one latency in a series,
meaning that we reach the probability of 1, then the table will be
expanded to:

1/3, 1/2, and 1

Thus, we assume that there are no more than three latencies and each
with a probability of 1/3 of being captured. If the probability of 1
is reached in the new table, that is we see more than two closely
occurring latencies, then the table will again be extended, and so
on.

On my systems, it seems like this scheme works fairly well, as
long as the latencies we trace are long enough, 300 us seems to be
enough. This userspace program receive the inotify event at the end
of a latency, and it has time until the end of the next latency
to react, that is to open /sys/kernel/tracing/trace. Thus,
if we trace latencies that are >300 us, then we have at least 300 us
to react.

The minimum latency will of course not be 300 us on all systems, it
will depend on the hardware, kernel version, workload and
configuration.

Example usage:

In one shell, give the following command:
sudo latency-collector -rvv -t preemptirqsoff -s 2000 -a 3

This will trace latencies > 2000us with the preemptirqsoff tracer,
using random sleep with maximum verbosity, with a probability
table initialized to a size of 3.

In another shell, generate a few bursts of latencies:

root@host:~# modprobe preemptirq_delay_test delay=3000 test_mode=alternate
burst_size=3
root@host:~# echo 1 > /sys/kernel/preemptirq_delay_test/trigger
root@host:~# echo 1 > /sys/kernel/preemptirq_delay_test/trigger
root@host:~# echo 1 > /sys/kernel/preemptirq_delay_test/trigger
root@host:~# echo 1 > /sys/kernel/preemptirq_delay_test/trigger

If all goes well, you should be getting stack traces that shows
all the different latencies, i.e. you should see all the three
functions preemptirqtest_0, preemptirqtest_1, preemptirqtest_2 in the
stack traces.

Link: https://lkml.kernel.org/r/20210212134421.172750-2-Viktor.Rosendahl@bmw.de

Signed-off-by: Viktor Rosendahl <Viktor.Rosendahl@bmw.de>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
2021-02-12 11:52:59 -05:00