1. 26 Jul, 2022 6 commits
    • Yang Jihong's avatar
      perf kwork: Implement 'report' subcommand · f98919ec
      Yang Jihong authored
      Implements framework of 'perf kwork report', which is used to report
      time properties such as run time and frequency:
      
      Test cases:
      
        # perf kwork
      
         Usage: perf kwork [<options>] {record|report}
      
            -D, --dump-raw-trace  dump raw trace in ASCII
            -f, --force           don't complain, do it
            -k, --kwork <kwork>   list of kwork to profile (irq, softirq, workqueue, etc)
            -v, --verbose         be more verbose (show symbol address, etc)
      
        # perf kwork report -h
      
         Usage: perf kwork report [<options>]
      
            -C, --cpu <cpu>       list of cpus to profile
            -i, --input <file>    input file name
            -n, --name <name>     event name to profile
            -s, --sort <key[,key2...]>
                                  sort by key(s): runtime, max, count
            -S, --with-summary    Show summary with statistics
                --time <str>      Time span for analysis (start,stop)
      
        # perf kwork report
      
          Kwork Name                     | Cpu  | Total Runtime | Count     | Max runtime   | Max runtime start   | Max runtime end     |
         --------------------------------------------------------------------------------------------------------------------------------
         --------------------------------------------------------------------------------------------------------------------------------
      
        # perf kwork report -S
      
          Kwork Name                     | Cpu  | Total Runtime | Count     | Max runtime   | Max runtime start   | Max runtime end     |
         --------------------------------------------------------------------------------------------------------------------------------
         --------------------------------------------------------------------------------------------------------------------------------
          Total count            :         0
          Total runtime   (msec) :     0.000 (0.000% load average)
          Total time span (msec) :     0.000
         --------------------------------------------------------------------------------------------------------------------------------
      
        # perf kwork report -C 0,100
        Requested CPU 100 too large. Consider raising MAX_NR_CPUS
        Invalid cpu bitmap
      
        # perf kwork report -s runtime1
          Error: Unknown --sort key: `runtime1'
      
         Usage: perf kwork report [<options>]
      
            -C, --cpu <cpu>       list of cpus to profile
            -i, --input <file>    input file name
            -n, --name <name>     event name to profile
            -s, --sort <key[,key2...]>
                                  sort by key(s): runtime, max, count
            -S, --with-summary    Show summary with statistics
                --time <str>      Time span for analysis (start,stop)
      
        # perf kwork report -i perf_no_exist.data
        failed to open perf_no_exist.data: No such file or directory
      
        # perf kwork report --time 00FFF,
        Invalid time span
      
      Since there are no report supported events, the output is empty.
      
      Briefly describe the data structure:
      
      1. "class" indicates event type. For example, irq and softiq correspond
      to different types.
      
      2. "cluster" refers to a specific event corresponding to a type. For
      example, RCU and TIMER in softirq correspond to different clusters,
      which contains three types of events: raise, entry, and exit.
      
      3. "atom" includes time of each sample and sample of the previous phase.
      (For example, exit corresponds to entry, which is used for timehist.)
      
      Committer notes:
      
      - Add {} for multiline if blocks.
      
      - report_print_work() should either return that ret variable that
        accounts how many bytes were printed or stop accounting and be void.
        Do the former for now to avoid this:
      
      builtin-kwork.c:534:6: error: variable 'ret' set but not used [-Werror,-Wunused-but-set-variable]
              int ret = 0;
                  ^
      1 error generated.
      
        When building with:
      
        ⬢[acme@toolbox perf]$ clang --version
        clang version 13.0.0 (https://github.com/llvm/llvm-project e8991caea8690ec2d17b0b7e1c29bf0da6609076)
      
      Also:
      
        -       if ((dst_type >= 0) && (dst_type < KWORK_TRACE_MAX)) {
        +       if (dst_type < KWORK_TRACE_MAX) {
      
      Several versions of clang and at least this gcc:
      
         3    51.40 alpine:3.9                    : FAIL gcc version 8.3.0 (Alpine 8.3.0)
          builtin-kwork.c:411:16: error: comparison of unsigned enum expression >= 0 is
                always true [-Werror,-Wtautological-compare]
                  if ((dst_type >= 0) && (dst_type < KWORK_TRACE_MAX)) {
      
      As the first entry in a enum is zero.
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-7-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f98919ec
    • Yang Jihong's avatar
      tools lib: Add list_last_entry_or_null() · e432947e
      Yang Jihong authored
      Add list_last_entry_or_null() to get the last element from a list,
      returns NULL if the list is empty.
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-6-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e432947e
    • Yang Jihong's avatar
      perf kwork: Add workqueue kwork record support · 97179d9d
      Yang Jihong authored
      Record workqueue events workqueue:workqueue_activate_work,
      workqueue:workqueue_execute_start & workqueue:workqueue_execute_end
      
      Tese cases:
      Record all events:
      
        # perf kwork record -o perf_kwork.date -- sleep 1
        [ perf record: Woken up 0 times to write data ]
        [ perf record: Captured and wrote 0.857 MB perf_kwork.date ]
        #
        # perf evlist -i perf_kwork.date
        irq:irq_handler_entry
        irq:irq_handler_exit
        irq:softirq_raise
        irq:softirq_entry
        irq:softirq_exit
        workqueue:workqueue_activate_work
        workqueue:workqueue_execute_start
        workqueue:workqueue_execute_end
        dummy:HG
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      
      Record workqueue events:
      
        # perf kwork -k workqueue record -o perf_kwork.date -- sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.081 MB perf_kwork.date ]
        #
        # perf evlist -i perf_kwork.date
        workqueue:workqueue_activate_work
        workqueue:workqueue_execute_start
        workqueue:workqueue_execute_end
        dummy:HG
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      
      Committer testing:
      
        # perf kwork record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 3.430 MB perf.data (24130 samples) ]
        # perf evlist -v
        irq:irq_handler_entry: type: 2, size: 128, config: 0x97, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:irq_handler_exit: type: 2, size: 128, config: 0x96, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_raise: type: 2, size: 128, config: 0x93, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_entry: type: 2, size: 128, config: 0x95, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_exit: type: 2, size: 128, config: 0x94, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        workqueue:workqueue_activate_work: type: 2, size: 128, config: 0x106, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        workqueue:workqueue_execute_start: type: 2, size: 128, config: 0x105, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        workqueue:workqueue_execute_end: type: 2, size: 128, config: 0x104, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        dummy:HG: type: 1, size: 128, config: 0x9, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|RAW|IDENTIFIER, read_format: ID, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
        # perf script | grep workqueue | head
                 swapper     0 [018] 26035.043289: workqueue:workqueue_activate_work: work struct 0xffff8b8ffeeae368
         kworker/18:2-ev 70440 [018] 26035.043293: workqueue:workqueue_execute_start: work struct 0xffff8b8ffeeae368: function free_work
         kworker/18:2-ev 70440 [018] 26035.043301:   workqueue:workqueue_execute_end: work struct 0xffff8b8ffeeae368: function free_work
                 swapper     0 [021] 26035.044704: workqueue:workqueue_activate_work: work struct 0xffff8b8ffef6e368
         kworker/21:0-ev 4080535 [021] 26035.044709: workqueue:workqueue_execute_start: work struct 0xffff8b8ffef6e368: function free_work
         kworker/21:0-ev 4080535 [021] 26035.044716:   workqueue:workqueue_execute_end: work struct 0xffff8b8ffef6e368: function free_work
                 swapper     0 [018] 26035.045230: workqueue:workqueue_activate_work: work struct 0xffff8b8ffeeae368
         kworker/18:2-ev 70440 [018] 26035.045232: workqueue:workqueue_execute_start: work struct 0xffff8b8ffeeae368: function free_work
         kworker/18:2-ev 70440 [018] 26035.045235:   workqueue:workqueue_execute_end: work struct 0xffff8b8ffeeae368: function free_work
                 swapper     0 [001] 26035.052046: workqueue:workqueue_activate_work: work struct 0xffff8b8108901590
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-5-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      97179d9d
    • Yang Jihong's avatar
      perf kwork: Add softirq kwork record support · e6439321
      Yang Jihong authored
      Record softirq events irq:softirq_raise, irq:softirq_entry &
      irq:softirq_exit.
      
      Test cases:
      Record all events:
      
        # perf kwork record -o perf_kwork.date -- sleep 1
        [ perf record: Woken up 0 times to write data ]
        [ perf record: Captured and wrote 0.897 MB perf_kwork.date ]
        #
        # perf evlist -i perf_kwork.date
        irq:irq_handler_entry
        irq:irq_handler_exit
        irq:softirq_raise
        irq:softirq_entry
        irq:softirq_exit
        dummy:HG
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      
      Record softirq events:
      
        # perf kwork -k softirq record -o perf_kwork.date -- sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.141 MB perf_kwork.date ]
        #
        # perf evlist -i perf_kwork.date
        irq:softirq_raise
        irq:softirq_entry
        irq:softirq_exit
        dummy:HG
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
      
      Committer testing:
      
        # perf kwork record sleep 1
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 3.078 MB perf.data (17433 samples) ]
        # perf evlist -v
        irq:irq_handler_entry: type: 2, size: 128, config: 0x97, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:irq_handler_exit: type: 2, size: 128, config: 0x96, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_raise: type: 2, size: 128, config: 0x93, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_entry: type: 2, size: 128, config: 0x95, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        irq:softirq_exit: type: 2, size: 128, config: 0x94, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|PERIOD|RAW|IDENTIFIER, read_format: ID, disabled: 1, inherit: 1, sample_id_all: 1, exclude_guest: 1
        dummy:HG: type: 1, size: 128, config: 0x9, { sample_period, sample_freq }: 1, sample_type: IP|TID|TIME|CPU|RAW|IDENTIFIER, read_format: ID, inherit: 1, mmap: 1, comm: 1, task: 1, sample_id_all: 1, mmap2: 1, comm_exec: 1, ksymbol: 1, bpf_event: 1
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
        # perf script | head
            migration/12    73 [012] 25884.940992:     irq:softirq_raise: vec=9 [action=RCU]
            migration/12    73 [012] 25884.940994:     irq:softirq_entry: vec=9 [action=RCU]
            migration/12    73 [012] 25884.940995:      irq:softirq_exit: vec=9 [action=RCU]
                 swapper     0 [004] 25884.940995:     irq:softirq_raise: vec=9 [action=RCU]
                 swapper     0 [004] 25884.940998:     irq:softirq_entry: vec=9 [action=RCU]
                 swapper     0 [004] 25884.940999:      irq:softirq_exit: vec=9 [action=RCU]
                     cc1 71212 [021] 25884.941990:     irq:softirq_raise: vec=9 [action=RCU]
                 swapper     0 [004] 25884.941991:     irq:softirq_raise: vec=9 [action=RCU]
                     cc1 71212 [021] 25884.941992:     irq:softirq_raise: vec=7 [action=SCHED]
               perf-exec 71208 [013] 25884.941992:     irq:softirq_raise: vec=9 [action=RCU]
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-4-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      e6439321
    • Yang Jihong's avatar
      perf kwork: Add irq kwork record support · 4f8ae962
      Yang Jihong authored
      Record interrupt events irq:irq_handler_entry & irq_handler_exit
      
      Test cases:
      
       # perf kwork record -o perf_kwork.date -- sleep 1
        [ perf record: Woken up 0 times to write data ]
        [ perf record: Captured and wrote 0.556 MB perf_kwork.date ]
        #
        # perf evlist -i perf_kwork.date
        irq:irq_handler_entry
        irq:irq_handler_exit
        dummy:HG
        # Tip: use 'perf evlist --trace-fields' to show fields for tracepoint events
        #
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-3-yangjihong1@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4f8ae962
    • Yang Jihong's avatar
      perf kwork: New tool to trace time properties of kernel work (such as softirq, and workqueue) · 0f70d8e9
      Yang Jihong authored
      The 'perf kwork' tool is used to trace time properties of kernel work
      (such as irq, softirq, and workqueue), including runtime, latency, and
      timehist, using the infrastructure in the perf tools to allow tracing
      extra targets.
      
      This is the first commit to reuse the 'perf record' framework code to
      implement a simple record function, kwork is not supported currently.
      
      Test cases:
      
        # perf
      
         usage: perf [--version] [--help] [OPTIONS] COMMAND [ARGS]
      
         The most commonly used perf commands are:
        <SNIP>
           iostat          Show I/O performance metrics
           kallsyms        Searches running kernel for symbols
           kmem            Tool to trace/measure kernel memory properties
           kvm             Tool to trace/measure kvm guest os
           kwork           Tool to trace/measure kernel work properties (latencies)
           list            List all symbolic event types
           lock            Analyze lock events
           mem             Profile memory accesses
           record          Run a command and record its profile into perf.data
        <SNIP>
         See 'perf help COMMAND' for more information on a specific command.
      
        # perf kwork
      
         Usage: perf kwork [<options>] {record}
      
            -D, --dump-raw-trace  dump raw trace in ASCII
            -f, --force           don't complain, do it
            -k, --kwork <kwork>   list of kwork to profile
            -v, --verbose         be more verbose (show symbol address, etc)
      
        # perf kwork record -- sleep 1
        [ perf record: Woken up 0 times to write data ]
        [ perf record: Captured and wrote 1.787 MB perf.data ]
      Signed-off-by: default avatarYang Jihong <yangjihong1@huawei.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Paul Clarke <pc@us.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220709015033.38326-2-yangjihong1@huawei.com
      [ Add {} for multiline if blocks ]
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f70d8e9
  2. 25 Jul, 2022 9 commits
    • Arnaldo Carvalho de Melo's avatar
      perf data: Add missing unistd.h header needed for pid_t · ade53539
      Arnaldo Carvalho de Melo authored
      Noticed when processing 'perf kwork' that includes util/data.h without,
      by luck, having included unistd.h indirectly to get the pid_t typedef.
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      ade53539
    • Namhyung Kim's avatar
      perf lock: Support -t option for 'contention' subcommand · 1ab55323
      Namhyung Kim authored
      Like perf lock report, it can report lock contention stat of each task.
      
        $ perf lock contention -t
         contended   total wait     max wait     avg wait          pid   comm
      
                 5    945.20 us    902.08 us    189.04 us       316167   EventManager_De
                33     98.17 us      6.78 us      2.97 us       766063   kworker/0:1-get
                 7     92.47 us     61.26 us     13.21 us       316170   EventManager_De
                14     76.31 us     12.87 us      5.45 us        12949   timedcall
                24     76.15 us     12.27 us      3.17 us       767992   sched-pipe
                15     75.62 us     11.93 us      5.04 us        15127   switchto-defaul
                24     71.84 us      5.59 us      2.99 us       629168   kworker/u513:2-
                17     67.41 us      7.94 us      3.96 us        13504   coroner-
                 1     59.56 us     59.56 us     59.56 us       316165   EventManager_De
                14     56.21 us      6.89 us      4.01 us            0   swapper
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20220725183124.368304-6-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1ab55323
    • Namhyung Kim's avatar
      perf lock: Add -k and -F options to 'contention' subcommand · 79079f21
      Namhyung Kim authored
      Like perf lock report, add -k/--key and -F/--field options to control
      output formatting and sorting.  Note that it has slightly different
      default options as some fields are not available and to optimize the
      screen space.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20220725183124.368304-5-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      79079f21
    • Namhyung Kim's avatar
      perf lock: Add 'contention' subcommand · 528b9cab
      Namhyung Kim authored
      The 'perf lock contention' processes the lock contention events and
      displays the result like perf lock report.  Right now, there's not
      much difference between the two but the lock contention specific
      features will come soon.
      
        $ perf lock contention
         contended   total wait     max wait     avg wait         type   caller
      
               238      1.41 ms     29.20 us      5.94 us     spinlock   update_blocked_averages+0x4c
                 1    902.08 us    902.08 us    902.08 us      rwsem:R   do_user_addr_fault+0x1dd
                81    330.30 us     17.24 us      4.08 us     spinlock   _nohz_idle_balance+0x172
                 2     89.54 us     61.26 us     44.77 us     spinlock   do_anonymous_page+0x16d
                24     78.36 us     12.27 us      3.27 us        mutex   pipe_read+0x56
                 2     71.58 us     59.56 us     35.79 us     spinlock   __handle_mm_fault+0x6aa
                 6     25.68 us      6.89 us      4.28 us     spinlock   do_idle+0x28d
                 1     18.46 us     18.46 us     18.46 us      rtmutex   exec_fw_cmd+0x21b
                 3     15.25 us      6.26 us      5.08 us     spinlock   tick_do_update_jiffies64+0x2c
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20220725183124.368304-4-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      528b9cab
    • Namhyung Kim's avatar
      perf lock: Add lock aggregation enum · f9c695a2
      Namhyung Kim authored
      Introduce the aggr_mode variable to prepare a later code change.
      
      The default is LOCK_AGGR_ADDR which aggregates the result for the lock
      instances.
      
      When -t/--threads option is given, it'd be set to LOCK_AGGR_TASK.  The
      LOCK_AGGR_CALLER is for the contention analysis and it'd aggregate the
      stat by comparing the callstacks.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20220725183124.368304-3-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f9c695a2
    • Namhyung Kim's avatar
      perf lock: Add flags field in the lock_stat · fb87158b
      Namhyung Kim authored
      For lock contention tracepoint analysis, it needs to keep the flags.
      As nr_readlock and nr_trylock fields are not used for it, let's make
      it a union.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Cc: Boqun Feng <boqun.feng@gmail.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Waiman Long <longman@redhat.com>
      Cc: Will Deacon <will@kernel.org>
      Link: https://lore.kernel.org/r/20220725183124.368304-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fb87158b
    • Ian Rogers's avatar
      perf test: Add test for #system_tsc_freq in metrics · 6923397c
      Ian Rogers authored
      The value should be non-zero on Intel while zero on everything else.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220718164312.3994191-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6923397c
    • Ian Rogers's avatar
      perf tsc: Add cpuinfo fall back for arch_get_tsc_freq() · 1276ade6
      Ian Rogers authored
      The CPUID method of arch_get_tsc_freq fails for older Intel processors,
      such as Skylake. Compute using /proc/cpuinfo.
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220718164312.3994191-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1276ade6
    • Kan Liang's avatar
      perf tsc: Add arch TSC frequency information · bc2373a5
      Kan Liang authored
      The TSC frequency information is required for the event metrics with the
      literal, system_tsc_freq. For the newer Intel platform, the TSC
      frequency information can be retrieved from the CPUID leaf 0x15.  If the
      TSC frequency information isn't present the /proc/cpuinfo approach is
      used.
      
      Refactor cpuid() for this use. Note, the previous stack pushing/popping
      approach was broken on x86-64 that has stack red zones that would be
      clobbered.
      
      Committer testing:
      
      Before:
      
        $ perf record sleep 0.0001
        [ perf record: Woken up 1 times to write data ]
        $ perf report --header-only |& grep cpuid
        # cpuid : AuthenticAMD,25,33,0
        $
      
      After the patch:
      
        $ perf record sleep 0.0001
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.002 MB perf.data (8 samples) ]
        $ perf report --header-only |& grep cpuid
        # cpuid : AuthenticAMD,25,33,0
        $
      Signed-off-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Caleb Biggers <caleb.biggers@intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kshipra Bopardikar <kshipra.bopardikar@intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Perry Taylor <perry.taylor@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Link: https://lore.kernel.org/r/20220718164312.3994191-2-irogers@google.comSigned-off-by: default avatarIan Rogers <irogers@google.com>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      bc2373a5
  3. 21 Jul, 2022 2 commits
  4. 20 Jul, 2022 23 commits