lkml.org 
[lkml]   [2020]   [Jun]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 14/15] perf ftrace: add support for trace option tracing_thresh
    Date
    This adds an option '--graph-thresh' to setup trace duration threshold
    for funcgraph tracer.

    $ sudo ./perf ftrace -G --graph-thresh 100
    3) ! 184.060 us | } /* schedule */
    3) ! 185.600 us | } /* exit_to_usermode_loop */
    2) ! 225.989 us | } /* schedule_idle */
    2) # 4140.051 us | } /* do_idle */

    Signed-off-by: Changbin Du <changbin.du@gmail.com>
    ---
    tools/perf/Documentation/perf-ftrace.txt | 3 +++
    tools/perf/builtin-ftrace.c | 25 ++++++++++++++++++++++++
    2 files changed, 28 insertions(+)

    diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt
    index cc770fc0a1e8..64843d0cdc45 100644
    --- a/tools/perf/Documentation/perf-ftrace.txt
    +++ b/tools/perf/Documentation/perf-ftrace.txt
    @@ -116,6 +116,9 @@ OPTIONS
    --graph-verbose::
    Show process names, PIDs, timestamps for function_graph tracer.

    +--graph-thresh::
    + Setup trace duration threshold for funcgraph tracer.
    +
    SEE ALSO
    --------
    linkperf:perf-record[1], linkperf:perf-trace[1]
    diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c
    index e037fe7abd47..0f8716ea0da4 100644
    --- a/tools/perf/builtin-ftrace.c
    +++ b/tools/perf/builtin-ftrace.c
    @@ -46,6 +46,7 @@ struct perf_ftrace {
    bool graph_nosleep_time;
    bool graph_noirqs;
    bool graph_verbose;
    + unsigned graph_thresh;
    };

    struct filter_entry {
    @@ -229,6 +230,9 @@ static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused)
    if (write_tracing_file("max_graph_depth", "0") < 0)
    return -1;

    + if (write_tracing_file("tracing_thresh", "0") < 0)
    + return -1;
    +
    reset_tracing_filters();
    reset_tracing_options(ftrace);
    return 0;
    @@ -440,6 +444,20 @@ static int set_tracing_funcgraph_verbose(struct perf_ftrace *ftrace)
    return 0;
    }

    +static int set_tracing_thresh(struct perf_ftrace *ftrace)
    +{
    + int ret;
    +
    + if (ftrace->graph_thresh == 0)
    + return 0;
    +
    + ret = write_tracing_file_int("tracing_thresh", ftrace->graph_thresh);
    + if (ret < 0)
    + return ret;
    +
    + return 0;
    +}
    +
    static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
    {
    char *trace_file;
    @@ -539,6 +557,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv)
    goto out_reset;
    }

    + if (set_tracing_thresh(ftrace) < 0) {
    + pr_err("failed to set tracing thresh\n");
    + goto out_reset;
    + }
    +
    if (write_tracing_file("current_tracer", ftrace->tracer) < 0) {
    pr_err("failed to set current_tracer to %s\n", ftrace->tracer);
    goto out_reset;
    @@ -726,6 +749,8 @@ int cmd_ftrace(int argc, const char **argv)
    "ignore functions that happen inside interrupt for function_graph tracer"),
    OPT_BOOLEAN(0, "graph-verbose", &ftrace.graph_verbose,
    "show process names, PIDs, timestamps for function_graph tracer"),
    + OPT_UINTEGER(0, "graph-thresh", &ftrace.graph_thresh,
    + "only show functions of which the duration is greater than <n>µs"),
    OPT_END()
    };

    --
    2.25.1
    \
     
     \ /
      Last update: 2020-06-27 15:39    [W:3.982 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site