1. 28 Jul, 2023 20 commits
    • James Clark's avatar
      perf tools: Add a place to put kernel config fragments for test runs · 404e077a
      James Clark authored
      Defconfig doesn't give full coverage for a perf test run, so these can
      be merged with defconfig to do so. It's not complete yet, but is a
      starting point as a place to add to when a specific test needs something
      extra to run.
      Signed-off-by: default avatarJames Clark <james.clark@arm.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Aishwarya.TCV@arm.com
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230628105303.4053478-2-james.clark@arm.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      404e077a
    • Anup Sharma's avatar
      perf scripts python: Add command execution for gecko script · f9f72b2a
      Anup Sharma authored
      This will enable the execution of gecko.py script using record and
      report commands in 'perf script'.  And this will be also reflected at
      "perf script -l" command.
      
      For Example:
          perf script record gecko
          perf script report gecko
      
      Committer notes:
      
      As discussed on the perf tools office hours, I made -F 99 the default
      for the record script and removed the double -- on the report script so
      that the existing 'perf script' protocol for the combined operation:
      
          # perf script gecko
      
      Works, i.e. the record script pipes its stdout into the stdin of the
      report script, basically:
      
        /bin/sh /usr/libexec/perf-core/scripts/python/bin/gecko-record -F 99 -g -a -q -o - | \
        /bin/sh /usr/libexec/perf-core/scripts/python/bin/gecko-report -i -
      
      Testing it:
      
      The resulting JSON file needs to be uploaded to
      https://profiler.firefox.com, Anup already has code to start a local
      http server on the trace_begin handler of the gecko python script, start
      firefox and feed it the JSON.
      
      The example below only collects sample for the specified workload, so
      that we don't produce thousands of lines, to collect system wide
      samples, use instead:
      
        # perf script gecko -a sleep 0.5
      
        # nohup perf script gecko sleep 0.5
        {
          "meta": {
            "interval": 1,
            "processType": 0,
            "product": "x86_64 GNU/Linux",
            "stackwalk": 1,
            "debug": 0,
            "gcpoison": 0,
            "asyncstack": 1,
            "startTime": 274601692.636,
            "shutdownTime": null,
            "version": 24,
            "presymbolicated": true,
            "categories": [
              {
                "name": "User",
                "color": "yellow",
                "subcategories": [
                  "Other"
                ]
              },
              {
                "name": "Kernel",
                "color": "orange",
                "subcategories": [
                  "Other"
                ]
              }
            ],
            "markerSchema": []
          },
          "libs": [],
          "threads": [
            {
              "tid": 3344498,
              "pid": 3344498,
              "name": "sleep",
              "markers": {
                "schema": {
                  "name": 0,
                  "startTime": 1,
                  "endTime": 2,
                  "phase": 3,
                  "category": 4,
                  "data": 5
                },
                "data": []
              },
              "samples": {
                "schema": {
                  "stack": 0,
                  "time": 1,
                  "responsiveness": 2
                },
                "data": [
                  [
                    21,
                    274601692.636,
                    0
                  ],
                  [
                    23,
                    274601692.641,
                    0
                  ],
                  [
                    29,
                    274601692.643,
                    0
                  ],
                  [
                    42,
                    274601692.648,
                    0
                  ]
                ]
              },
              "frameTable": {
                "schema": {
                  "location": 0,
                  "relevantForJS": 1,
                  "innerWindowID": 2,
                  "implementation": 3,
                  "optimizations": 4,
                  "line": 5,
                  "column": 6,
                  "category": 7,
                  "subcategory": 8
                },
                "data": [
                  [
                    0,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    1,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    2,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    3,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    4,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    5,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    6,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    7,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    8,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    9,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    10,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    11,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    12,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    13,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    14,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    15,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    16,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    17,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    18,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    19,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    20,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    21,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    22,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    23,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    24,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    25,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    26,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    27,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    28,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    29,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    30,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    31,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    32,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    33,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    34,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    35,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    36,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    37,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ],
                  [
                    38,
                    false,
                    0,
                    null,
                    null,
                    null,
                    null,
                    1,
                    null
                  ]
                ]
              },
              "stackTable": {
                "schema": {
                  "prefix": 0,
                  "frame": 1
                },
                "data": [
                  [
                    null,
                    0
                  ],
                  [
                    0,
                    1
                  ],
                  [
                    1,
                    2
                  ],
                  [
                    2,
                    3
                  ],
                  [
                    3,
                    4
                  ],
                  [
                    4,
                    5
                  ],
                  [
                    5,
                    6
                  ],
                  [
                    6,
                    7
                  ],
                  [
                    7,
                    8
                  ],
                  [
                    8,
                    9
                  ],
                  [
                    9,
                    10
                  ],
                  [
                    10,
                    11
                  ],
                  [
                    11,
                    12
                  ],
                  [
                    12,
                    13
                  ],
                  [
                    13,
                    14
                  ],
                  [
                    14,
                    15
                  ],
                  [
                    15,
                    16
                  ],
                  [
                    16,
                    17
                  ],
                  [
                    17,
                    18
                  ],
                  [
                    18,
                    19
                  ],
                  [
                    19,
                    20
                  ],
                  [
                    20,
                    21
                  ],
                  [
                    20,
                    22
                  ],
                  [
                    22,
                    23
                  ],
                  [
                    11,
                    24
                  ],
                  [
                    24,
                    25
                  ],
                  [
                    25,
                    26
                  ],
                  [
                    26,
                    27
                  ],
                  [
                    27,
                    28
                  ],
                  [
                    28,
                    29
                  ],
                  [
                    9,
                    11
                  ],
                  [
                    30,
                    24
                  ],
                  [
                    31,
                    25
                  ],
                  [
                    32,
                    30
                  ],
                  [
                    33,
                    31
                  ],
                  [
                    34,
                    32
                  ],
                  [
                    35,
                    29
                  ],
                  [
                    36,
                    33
                  ],
                  [
                    37,
                    34
                  ],
                  [
                    38,
                    35
                  ],
                  [
                    39,
                    36
                  ],
                  [
                    40,
                    37
                  ],
                  [
                    41,
                    38
                  ]
                ]
              },
              "stringTable": [
                "__func__.0 (in [kernel.kallsyms].rodata)",
                "perf_trace_ext4_fc_track_inode (in [kernel.kallsyms])",
                "perf_trace_ext4_es_insert_delayed_block (in [kernel.kallsyms])",
                "ext4_es_show_pblock (in [kernel.kallsyms])",
                "perf_trace_ext4_ext_rm_leaf (in [kernel.kallsyms])",
                "devcgroup_access_write (in [kernel.kallsyms])",
                "devcgroup_update_access (in [kernel.kallsyms])",
                "propagate_exception (in [kernel.kallsyms])",
                "revalidate_active_exceptions (in [kernel.kallsyms])",
                "perf_trace_ext4_fc_commit_stop (in [kernel.kallsyms])",
                "perf_fetch_caller_regs (in [kernel.kallsyms])",
                "khugepaged (in [kernel.kallsyms])",
                "khugepaged_wait_work (in [kernel.kallsyms])",
                "freezable_schedule_timeout (in [kernel.kallsyms])",
                "freezer_count (in [kernel.kallsyms])",
                "try_to_freeze (in [kernel.kallsyms])",
                "try_to_freeze_unsafe (in [kernel.kallsyms])",
                "split_huge_pages_write (in [kernel.kallsyms])",
                "migrate_pages (in [kernel.kallsyms])",
                "unmap_and_move (in [kernel.kallsyms])",
                "__unmap_and_move (in [kernel.kallsyms])",
                "collect_events (in [kernel.kallsyms])",
                "uncore_down_prepare (in [kernel.kallsyms])",
                "perf_iommu_read (in [kernel.kallsyms])",
                "khugepaged_do_scan (in [kernel.kallsyms])",
                "khugepaged_scan_mm_slot (in [kernel.kallsyms])",
                "khugepaged_scan_file (in [kernel.kallsyms])",
                "need_resched (in [kernel.kallsyms])",
                "get_current (in [kernel.kallsyms])",
                "move_to_new_page (in [kernel.kallsyms])",
                "khugepaged_scan_pmd (in [kernel.kallsyms])",
                "trace_mm_khugepaged_scan_pmd (in [kernel.kallsyms])",
                "migrate_huge_page_move_mapping (in [kernel.kallsyms])",
                "do_huge_pmd_numa_page (in [kernel.kallsyms])",
                "pmd_pfn (in [kernel.kallsyms])",
                "protnone_mask (in [kernel.kallsyms])",
                "__pte_needs_invert (in [kernel.kallsyms])",
                "reclaim_high (in [kernel.kallsyms])",
                "memcg_memory_event (in [kernel.kallsyms])"
              ],
              "registerTime": 0,
              "unregisterTime": null,
              "processType": "default"
            }
          ],
          "processes": [],
          "pausedRanges": []
        }
        #
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/cbf03cda175ea3dd2c6cd87bd3f12d803446cb95.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f9f72b2a
    • Anup Sharma's avatar
      perf scripts python: Implement add sample function and thread processing · 2d889c6a
      Anup Sharma authored
      The stack has been created for storing func and dso from the callchain.
      The sample has been added to a specific thread. It first checks if the
      thread exists in the Thread class. Then it call _add_sample function
      which is responsible for appending a new entry to the samples list.
      
      Also callchain parsing and storing part is implemented. Moreover removed
      the comment from thread.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/5a112be85ccdcdcd611e343f6a7a7482d01f6299.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2d889c6a
    • Anup Sharma's avatar
      perf scripts python: Implement add sample function and thread processing · 258dfd41
      Anup Sharma authored
      The intern_stack function is responsible for retrieving
      or creating a stack_id based on the provided frame_id and prefix_id.
      It first generates a key using the frame_id and prefix_id values.
      If the stack corresponding to the key is found in the stackMap,
      it is returned. Otherwise, a new stack is created by appending
      the prefix_id and frame_id to the stackTable. The key
      and the index of the newly created stack are added to the
      stackMap for future reference.
      
      The _intern_frame function is responsible for retrieving or
      creating a frame_id based on the provided frame string. If the frame_id
      corresponding to the frameString is found in the frameMap, it is
      returned. Otherwise, a new frame is created by appending relevant
      information to the frameTable and adding the frameString to the string_id
      through _intern_string.
      
      The _intern_string function will gets a matching string, or saves the new
      string and returns a String ID.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Link: https://lore.kernel.org/r/4442f4b1ab4c7317cf940560a3a285fcdfbeeb08.1689961706.git.anupnewsmail@gmail.com
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: linux-kernel@vger.kernel.org
      Cc: linux-perf-users@vger.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      258dfd41
    • Anup Sharma's avatar
      perf scripts python: Add trace end processing and PRODUCT and CATEGORIES information · 833daec7
      Anup Sharma authored
      The final output will now be presented in JSON format following the Gecko
      profile structure. Additionally, the inclusion of PRODUCT allows easy retrieval
      of header information for UI.
      
      Furthermore, CATEGORIES have been introduced to enable customization of
      kernel and user colors using input arguments. To facilitate this functionality,
      an argparse-based parser has been implemented.
      
      Note: The implementation of threads will be addressed in subsequent commits
      for now I have commented it out.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/fa6d027e4134c48e8a2ea45dd8f6b21e6a3418e4.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      833daec7
    • Anup Sharma's avatar
      perf scripts python: Add classes and conversion functions · 5aacd7f0
      Anup Sharma authored
      This commit introduces new classes and conversion functions to
      facilitate the representation of Gecko profile information. The new
      classes Frame, Stack, Sample, and Thread are added to handle specific
      components of the profile data, also link to the origin docs has been
      commented out.
      
      Additionally, Inside the Thread class _to_json_dict() method has been
      created that converts the current thread data into the corresponding
      format expected by the GeckoThread JSON schema, as per the Gecko
      profile format specification.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/ab7b40bd32df7101a6f8b4a3aa41570b63b831ac.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5aacd7f0
    • Anup Sharma's avatar
      perf scripts python: Extact necessary information from process event · 0a02e44c
      Anup Sharma authored
      The script takes in a sample event dictionary(param_dict) and retrieves
      relevant data such as time stamp, PID, TID, and comm for each event.
      Also start time is defined as a global variable as it need to be passed
      to trace_end for gecko meta information field creation.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/19910fefcfe4be03cd5c2aa3fec11d3f86c0381b.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0a02e44c
    • Anup Sharma's avatar
      perf scripts python: Add initial script file with usage information · 1699d3ef
      Anup Sharma authored
      Added necessary modules, including the Perf-Trace-Util
      library, and defines the required functions and variables
      for using perf script python. The perf_trace_context and
      Core modules for tracing and processing events has been
      also imported. Added usage information.
      Signed-off-by: default avatarAnup Sharma <anupnewsmail@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/f2f1a62f1cc69f44a5414da46a26a4cf124d2744.1689961706.git.anupnewsmail@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1699d3ef
    • Xiu Jianfeng's avatar
      perf doc: Fix typo in perf.data-file-format.txt · 1e372014
      Xiu Jianfeng authored
      The 'it' should be 'is' here, fix it.
      Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ian Rogers <irogers@google.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230727105001.261420-1-xiujianfeng@huawei.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      1e372014
    • Namhyung Kim's avatar
      perf machine: Include data symbols in the kernel map · 69a87a32
      Namhyung Kim authored
      When 'perf record -d' is used, it needs data mmaps to symbolize global
      data.  But it missed to collect kernel data maps so it cannot symbolize
      them.  Instead of having a separate map, just increase the kernel map
      size to include the data section.
      
      Probably we can have a separate kernel map for data, but the current
      code assumes a single kernel map.  So it'd require more changes in other
      places and looks error-prone.  I decided not to go that way for now.
      
      Also it seems the kernel module size already includes the data section.
      
      For example, my system has the following.
      
        $ grep -e _stext -e _etext -e _edata /proc/kallsyms
        ffffffff99800000 T _stext
        ffffffff9a601ac8 T _etext
        ffffffff9b446a00 D _edata
      
      Size of the text section is (0x9a601ac8 - 0x99800000 = 0xe01ac8) and
      size including data section is (0x9b446a00 - 0x99800000 = 0x1c46a00).
      
      Before:
        $ perf record -d true
      
        $ perf report -D | grep MMAP | head -1
        0 0 0x460 [0x60]: PERF_RECORD_MMAP -1/0: [0xffffffff99800000(0xe01ac8) @ 0xffffffff99800000]: x [kernel.kallsyms]_text
                                                                     ^^^^^^^^
                                                                       here
      After:
        $ perf report -D | grep MMAP | head -1
        0 0 0x460 [0x60]: PERF_RECORD_MMAP -1/0: [0xffffffff99800000(0x1c46a00) @ 0xffffffff99800000]: x [kernel.kallsyms]_text
                                                                     ^^^^^^^^^
      
      Instead of just replacing it to _edata, try _edata first and then fall
      back to _etext just in case.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230725001929.368041-2-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      69a87a32
    • Namhyung Kim's avatar
      perf symbols: Add kallsyms__get_symbol_start() · f9dd531c
      Namhyung Kim authored
      The kallsyms__get_symbol_start() to get any symbol address from
      kallsyms.  The existing kallsyms__get_function_start() only allows text
      symbols so create this to allow data symbols too.
      Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
      Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20230725001929.368041-1-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      f9dd531c
    • Ian Rogers's avatar
      perf parse-events: Remove ABORT_ON · 4c11adff
      Ian Rogers authored
      Prefer informative messages rather than none with ABORT_ON. Document
      one failure mode and add an error message for another.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-14-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      4c11adff
    • Ian Rogers's avatar
      perf parse-events: Improve location for add pmu · 81a4e31f
      Ian Rogers authored
      Improve the location for add PMU for cases when PMUs aren't found.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-13-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      81a4e31f
    • Ian Rogers's avatar
      perf parse-events: Populate error column for BPF/tracepoint events · d81fa63b
      Ian Rogers authored
      Follow convention from parse_events_terms__num/str and pass the
      YYLTYPE for the location.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-12-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      d81fa63b
    • Ian Rogers's avatar
      perf parse-events: Additional error reporting · b30d4f0b
      Ian Rogers authored
      When no events or PMUs match report an error for event_pmu:
      
      Before:
      ```
      $ perf stat -e 'asdfasdf' -a sleep 1
      Run 'perf list' for a list of valid events
      
       Usage: perf stat [<options>] [<command>]
      
          -e, --event <event>   event selector. use 'perf list' to list available events
      ```
      
      After:
      ```
      $ perf stat -e 'asdfasdf' -a sleep 1
      event syntax error: 'asdfasdf'
                           \___ Bad event name
      
      Unabled to find PMU or event on a PMU of 'asdfasdf'
      Run 'perf list' for a list of valid events
      
       Usage: perf stat [<options>] [<command>]
      
          -e, --event <event>   event selector. use 'perf list' to list available events
      ```
      
      Fixes the inadvertent removal when hybrid parsing was modified.
      
      Fixes: 70c90e4a ("perf parse-events: Avoid scanning PMUs before parsing")
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-11-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b30d4f0b
    • Ian Rogers's avatar
      perf parse-events: Separate ENOMEM memory handling · b52cb995
      Ian Rogers authored
      Add PE_ABORT that will YYNOMEM or YYABORT accordingly.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-10-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      b52cb995
    • Ian Rogers's avatar
      perf parse-events: Move instances of YYABORT to YYNOMEM · 77cdd787
      Ian Rogers authored
      Migration to improve error reporting as YYABORT cases should carry
      event parsing errors.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-9-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      77cdd787
    • Ian Rogers's avatar
      perf parse-events: Separate YYABORT and YYNOMEM cases · a7a3252d
      Ian Rogers authored
      Split cases in event_pmu for greater accuracy.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-8-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a7a3252d
    • Ian Rogers's avatar
      perf parse-event: Add memory allocation test for name terms · 9462e4de
      Ian Rogers authored
      If the name memory allocation fails then propagate to the parser.
      
      Committer notes:
      
      Use $(BISON_FALLBACK_FLAGS) on the bison call so that we continue
      building with older bison versions, before 3.81, where YYNOMEM isn't
      present.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: bpf@vger.kernel.org
      Link: https://lore.kernel.org/r/20230627181030.95608-7-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9462e4de
    • Arnaldo Carvalho de Melo's avatar
      perf build: Define YYNOMEM as YYNOABORT for bison < 3.81 · 88cc47e2
      Arnaldo Carvalho de Melo authored
      YYNOMEM was introduced in bison 3.81, so define it as YYABORT for older
      versions, which should provide the previous perf behaviour.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      88cc47e2
  2. 26 Jul, 2023 5 commits
  3. 24 Jul, 2023 4 commits
    • Ian Rogers's avatar
      perf build: Add LTO build option · c126ac4a
      Ian Rogers authored
      Add an LTO build option, that sets the appropriate CFLAGS and CXXFLAGS
      values.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230724201247.748146-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c126ac4a
    • Ian Rogers's avatar
      perf test: Avoid weak symbol for arch_tests · 5cfb0cc0
      Ian Rogers authored
      GCC LTO will complain that the array length varies for the arch_tests
      weak symbol. Use extern/static and architecture determining #if to
      workaround this problem.
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Nick Desaulniers <ndesaulniers@google.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230724201247.748146-4-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      5cfb0cc0
    • Ian Rogers's avatar
      perf parse-events: Avoid use uninitialized warning · 0f97a3a0
      Ian Rogers authored
      With GCC LTO a potential use uninitialized is spotted:
      ```
      In function ‘parse_events_config_bpf’,
          inlined from ‘parse_events_load_bpf’ at util/parse-events.c:874:8:
      util/parse-events.c:792:37: error: ‘error_pos’ may be used uninitialized [-Werror=maybe-uninitialized]
        792 |                                 idx = term->err_term + error_pos;
            |                                     ^
      util/parse-events.c: In function ‘parse_events_load_bpf’:
      util/parse-events.c:765:13: note: ‘error_pos’ was declared here
        765 |         int error_pos;
            |             ^
      ```
      So initialize at declaration.
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230724201247.748146-3-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      0f97a3a0
    • Ian Rogers's avatar
      perf stat: Avoid uninitialized use of perf_stat_config · 91f88a0a
      Ian Rogers authored
      perf_event__read_stat_config will assign values based on number of
      tags and tag values. Initialize the structs to zero before they are
      assigned so that no uninitialized values can be seen.
      
      This potential error was reported by GCC with LTO enabled.
      Reviewed-by: default avatarNick Desaulniers <ndesaulniers@google.com>
      Signed-off-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Carsten Haitzler <carsten.haitzler@arm.com>
      Cc: Fangrui Song <maskray@google.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: James Clark <james.clark@arm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Nathan Chancellor <nathan@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@amd.com>
      Cc: Tom Rix <trix@redhat.com>
      Cc: Xing Zhengjun <zhengjun.xing@linux.intel.com>
      Cc: Yang Jihong <yangjihong1@huawei.com>
      Cc: bpf@vger.kernel.org
      Cc: llvm@lists.linux.dev
      Link: https://lore.kernel.org/r/20230724201247.748146-2-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      91f88a0a
  4. 20 Jul, 2023 11 commits
    • Lu Hongfei's avatar
      perf diff: Replaces some ',' as separator with the more usual ';' · 681f34d5
      Lu Hongfei authored
      When wrapping code, use ';' better than using ',' which is more in line
      with the coding habits of most engineers.
      Signed-off-by: default avatarLu Hongfei <luhongfei@vivo.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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: Peter Zijlstra <peterz@infradead.org>
      Cc: opensource.kernel@vivo.com
      Link: https://lore.kernel.org/r/20230706094635.1553-1-luhongfei@vivo.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      681f34d5
    • Arnaldo Carvalho de Melo's avatar
      perf bench uprobe trace_printk: Add entry attaching an BPF program that does a trace_printk · 7b47623b
      Arnaldo Carvalho de Melo authored
        [root@five ~]# perf bench uprobe all
        # Running uprobe/baseline benchmark...
        # Executed 1,000 usleep(1000) calls
             Total time: 1,053,963 usecs
      
         1,053.963 usecs/op
      
        # Running uprobe/empty benchmark...
        # Executed 1,000 usleep(1000) calls
             Total time: 1,056,293 usecs +2,330 to baseline
      
         1,056.293 usecs/op 2.330 usecs/op to baseline
      
        # Running uprobe/trace_printk benchmark...
        # Executed 1,000 usleep(1000) calls
             Total time: 1,056,977 usecs +3,014 to baseline +684 to previous
      
         1,056.977 usecs/op 3.014 usecs/op to baseline 0.684 usecs/op to previous
      
        [root@five ~]#
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andre Fredette <anfredet@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Dave Tucker <datucker@redhat.com>
      Cc: Derek Barbosa <debarbos@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719204910.539044-6-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7b47623b
    • Arnaldo Carvalho de Melo's avatar
      perf bench uprobe empty: Add entry attaching an empty BPF program · 6af5e4cf
      Arnaldo Carvalho de Melo authored
      Using libbpf and a BPF skel:
      
        # perf bench uprobe all
        # Running uprobe/baseline benchmark...
        # Executed 1,000 usleep(1000) calls
             Total time: 1,055,618 usecs
      
         1,055.618 usecs/op
        # Running uprobe/empty benchmark...
        # Executed 1,000 usleep(1000) calls
             Total time: 1,057,146 usecs +1,528 to baseline
      
         1,057.146 usecs/op
        #
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andre Fredette <anfredet@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Dave Tucker <datucker@redhat.com>
      Cc: Derek Barbosa <debarbos@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719204910.539044-5-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      6af5e4cf
    • Arnaldo Carvalho de Melo's avatar
      perf bench uprobe: Show diff to previous · 54d81102
      Arnaldo Carvalho de Melo authored
      Will be useful to show the incremental overhead as we do more stuff in
      the BPF program attached to the uprobes.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andre Fredette <anfredet@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Dave Tucker <datucker@redhat.com>
      Cc: Derek Barbosa <debarbos@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719204910.539044-4-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      54d81102
    • Arnaldo Carvalho de Melo's avatar
      perf bench uprobe: Print diff to baseline · dded6f61
      Arnaldo Carvalho de Melo authored
      This is just prep work to show the diff to the unmodified workload.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andre Fredette <anfredet@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Dave Tucker <datucker@redhat.com>
      Cc: Derek Barbosa <debarbos@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719204910.539044-3-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      dded6f61
    • Arnaldo Carvalho de Melo's avatar
      perf bench uprobe: Add benchmark to test uprobe overhead · 2df27071
      Arnaldo Carvalho de Melo authored
      This just adds the initial "workload", a call to libc's usleep(1000us)
      function:
      
        $ perf stat --null perf bench uprobe all
        # Running uprobe/baseline benchmark...
        # Executed 1000 usleep(1000) calls
             Total time: 1053533 usecs
      
         1053.533 usecs/op
      
         Performance counter stats for 'perf bench uprobe all':
      
               1.061042896 seconds time elapsed
      
               0.001079000 seconds user
               0.006499000 seconds sys
      
        $
      
      More entries will be added using a BPF skel to add various uprobes to
      the usleep() function.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andre Fredette <anfredet@redhat.com>
      Cc: Clark Williams <williams@redhat.com>
      Cc: Dave Tucker <datucker@redhat.com>
      Cc: Derek Barbosa <debarbos@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Masami Hiramatsu (Google) <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719204910.539044-2-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      2df27071
    • Arnaldo Carvalho de Melo's avatar
      MAINTAINERS: Add git information for perf-tools and perf-tools-next trees/branches · faa4e0da
      Arnaldo Carvalho de Melo authored
      Now the perf tools development is done on these trees/branches:
      
        git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools.git perf-tools
        git git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next.git perf-tools-next
      
      For a while I'll continue mirroring what is these to the same branches
      in my git tree.
      Suggested-by: default avatarJohn Garry <john.g.garry@oracle.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.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: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/lkml/CAP-5=fVGOP6-k=BTRd_bn=N0HVy+1ShpdW5rk5ND0ZGhm_fQkg@mail.gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      faa4e0da
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Free thread_trace->files table · fcca1faf
      Arnaldo Carvalho de Melo authored
      The fd->pathname table that is kept in 'struct thread_trace' and thus in
      thread->priv must be freed when a thread is deleted.
      
      This was also detected using -fsanitize=address.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719202951.534582-6-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fcca1faf
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Really free the evsel->priv area · 7962ef13
      Arnaldo Carvalho de Melo authored
      In 3cb4d5e0 ("perf trace: Free syscall tp fields in
      evsel->priv") it only was freeing if strcmp(evsel->tp_format->system,
      "syscalls") returned zero, while the corresponding initialization of
      evsel->priv was being performed if it was _not_ zero, i.e. if the tp
      system wasn't 'syscalls'.
      
      Just stop looking for that and free it if evsel->priv was set, which
      should be equivalent.
      
      Also use the pre-existing evsel_trace__delete() function.
      
      This resolves these leaks, detected with:
      
        $ make EXTRA_CFLAGS="-fsanitize=address" BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools-next -C tools/perf install-bin
      
        =================================================================
        ==481565==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 40 byte(s) in 1 object(s) allocated from:
            #0 0x7f7343cba097 in calloc (/lib64/libasan.so.8+0xba097)
            #1 0x987966 in zalloc (/home/acme/bin/perf+0x987966)
            #2 0x52f9b9 in evsel_trace__new /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:307
            #3 0x52f9b9 in evsel__syscall_tp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:333
            #4 0x52f9b9 in evsel__init_raw_syscall_tp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:458
            #5 0x52f9b9 in perf_evsel__raw_syscall_newtp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:480
            #6 0x540e8b in trace__add_syscall_newtp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3212
            #7 0x540e8b in trace__run /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3891
            #8 0x540e8b in cmd_trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:5156
            #9 0x5ef262 in run_builtin /home/acme/git/perf-tools-next/tools/perf/perf.c:323
            #10 0x4196da in handle_internal_command /home/acme/git/perf-tools-next/tools/perf/perf.c:377
            #11 0x4196da in run_argv /home/acme/git/perf-tools-next/tools/perf/perf.c:421
            #12 0x4196da in main /home/acme/git/perf-tools-next/tools/perf/perf.c:537
            #13 0x7f7342c4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
      
        Direct leak of 40 byte(s) in 1 object(s) allocated from:
            #0 0x7f7343cba097 in calloc (/lib64/libasan.so.8+0xba097)
            #1 0x987966 in zalloc (/home/acme/bin/perf+0x987966)
            #2 0x52f9b9 in evsel_trace__new /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:307
            #3 0x52f9b9 in evsel__syscall_tp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:333
            #4 0x52f9b9 in evsel__init_raw_syscall_tp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:458
            #5 0x52f9b9 in perf_evsel__raw_syscall_newtp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:480
            #6 0x540dd1 in trace__add_syscall_newtp /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3205
            #7 0x540dd1 in trace__run /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3891
            #8 0x540dd1 in cmd_trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:5156
            #9 0x5ef262 in run_builtin /home/acme/git/perf-tools-next/tools/perf/perf.c:323
            #10 0x4196da in handle_internal_command /home/acme/git/perf-tools-next/tools/perf/perf.c:377
            #11 0x4196da in run_argv /home/acme/git/perf-tools-next/tools/perf/perf.c:421
            #12 0x4196da in main /home/acme/git/perf-tools-next/tools/perf/perf.c:537
            #13 0x7f7342c4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
      
        SUMMARY: AddressSanitizer: 80 byte(s) leaked in 2 allocation(s).
        [root@quaco ~]#
      
      With this we plug all leaks with "perf trace sleep 1".
      
      Fixes: 3cb4d5e0 ("perf trace: Free syscall tp fields in evsel->priv")
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Riccardo Mancini <rickyman7@gmail.com>
      Link: https://lore.kernel.org/lkml/20230719202951.534582-5-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7962ef13
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Register a thread priv destructor · 9de251cb
      Arnaldo Carvalho de Melo authored
      To plug these leaks detected with:
      
        $ make EXTRA_CFLAGS="-fsanitize=address" BUILD_BPF_SKEL=1 CORESIGHT=1 O=/tmp/build/perf-tools-next -C tools/perf install-bin
      
        =================================================================
        ==473890==ERROR: LeakSanitizer: detected memory leaks
      
        Direct leak of 112 byte(s) in 1 object(s) allocated from:
          #0 0x7fdf19aba097 in calloc (/lib64/libasan.so.8+0xba097)
          #1 0x987836 in zalloc (/home/acme/bin/perf+0x987836)
          #2 0x5367ae in thread_trace__new /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:1289
          #3 0x5367ae in thread__trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:1307
          #4 0x5367ae in trace__sys_exit /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:2468
          #5 0x52bf34 in trace__handle_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3177
          #6 0x52bf34 in __trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3685
          #7 0x542927 in trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3712
          #8 0x542927 in trace__run /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:4055
          #9 0x542927 in cmd_trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:5141
          #10 0x5ef1a2 in run_builtin /home/acme/git/perf-tools-next/tools/perf/perf.c:323
          #11 0x4196da in handle_internal_command /home/acme/git/perf-tools-next/tools/perf/perf.c:377
          #12 0x4196da in run_argv /home/acme/git/perf-tools-next/tools/perf/perf.c:421
          #13 0x4196da in main /home/acme/git/perf-tools-next/tools/perf/perf.c:537
          #14 0x7fdf18a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
      
        Direct leak of 2048 byte(s) in 1 object(s) allocated from:
          #0 0x7f788fcba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af)
          #1 0x5337c0 in trace__sys_enter /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:2342
          #2 0x52bfb4 in trace__handle_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3191
          #3 0x52bfb4 in __trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3699
          #4 0x542883 in trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3726
          #5 0x542883 in trace__run /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:4069
          #6 0x542883 in cmd_trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:5155
          #7 0x5ef232 in run_builtin /home/acme/git/perf-tools-next/tools/perf/perf.c:323
          #8 0x4196da in handle_internal_command /home/acme/git/perf-tools-next/tools/perf/perf.c:377
          #9 0x4196da in run_argv /home/acme/git/perf-tools-next/tools/perf/perf.c:421
          #10 0x4196da in main /home/acme/git/perf-tools-next/tools/perf/perf.c:537
          #11 0x7f788ec4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
      
        Indirect leak of 48 byte(s) in 1 object(s) allocated from:
          #0 0x7fdf19aba6af in __interceptor_malloc (/lib64/libasan.so.8+0xba6af)
          #1 0x77b335 in intlist__new util/intlist.c:116
          #2 0x5367fd in thread_trace__new /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:1293
          #3 0x5367fd in thread__trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:1307
          #4 0x5367fd in trace__sys_exit /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:2468
          #5 0x52bf34 in trace__handle_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3177
          #6 0x52bf34 in __trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3685
          #7 0x542927 in trace__deliver_event /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:3712
          #8 0x542927 in trace__run /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:4055
          #9 0x542927 in cmd_trace /home/acme/git/perf-tools-next/tools/perf/builtin-trace.c:5141
          #10 0x5ef1a2 in run_builtin /home/acme/git/perf-tools-next/tools/perf/perf.c:323
          #11 0x4196da in handle_internal_command /home/acme/git/perf-tools-next/tools/perf/perf.c:377
          #12 0x4196da in run_argv /home/acme/git/perf-tools-next/tools/perf/perf.c:421
          #13 0x4196da in main /home/acme/git/perf-tools-next/tools/perf/perf.c:537
          #14 0x7fdf18a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/20230719202951.534582-4-acme@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9de251cb
    • Arnaldo Carvalho de Melo's avatar
      perf thread: Allow tools to register a thread->priv destructor · 04cb4fc4
      Arnaldo Carvalho de Melo authored
      So that when thread__delete() runs it can be called and free stuff tools
      stashed into thread->priv, like 'perf trace' does and will use this
      new facility to plug some leaks.
      
      Added an assert(thread__priv_destructor == NULL) as suggested in Ian's
      review.
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lore.kernel.org/lkml/CAP-5=fV3Er=Ek8=iE=bSGbEBmM56_PJffMWot1g_5Bh8B5hO7A@mail.gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      04cb4fc4