1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
Commit graph

4 commits

Author SHA1 Message Date
Ian Rogers
d78e20c081 perf script python: Improve physical mem type resolution
Previously system RAM and persistent memory were hard code matched,
change so that the label of the memory region is just read from
/proc/iomem. This avoids frequent N/A samples.

Change the /proc/iomem reading, event processing and output so that
nested entries appear and their counts count toward their parent. As
labels may be repeated, include the memory ranges in the output to make
it clear why, for example, "System RAM" appears twice.

Before:

  Event: mem_inst_retired.all_loads:P
  Memory type                                    count  percentage
  ----------------------------------------  ----------  ----------
  System RAM                                      9460        96.5%
  N/A                                              998         3.5%

After:

  Event: mem_inst_retired.all_loads:P
  Memory type                                    count  percentage
  ----------------------------------------  ----------  ----------
  100000000-105f7fffff : System RAM              36741        96.5
    841400000-8416599ff : Kernel data               89         0.2
    840800000-8412a6fff : Kernel rodata             60         0.2
    841ebe000-8423fffff : Kernel bss                34         0.1
  0-fff : Reserved                                1345         3.5
  100000-89dd9fff : System RAM                       2         0.0

Before:

  Event: mem_inst_retired.any:P
  Memory type                                    count  percentage
  ----------------------------------------  -----------  -----------
  System RAM                                      9460        90.5%
  N/A                                              998         9.5%

After:

  Event: mem_inst_retired.any:P
  Memory type                                    count  percentage
  ----------------------------------------  ----------  ----------
  100000000-105f7fffff : System RAM               9460        90.5
    841400000-8416599ff : Kernel data               45         0.4
    840800000-8412a6fff : Kernel rodata             19         0.2
    841ebe000-8423fffff : Kernel bss                12         0.1
  0-fff : Reserved                                 998         9.5

The code has been updated to python 3 with type hints and resolving
issues reported by mypy and pylint. Tabs are swapped to spaces as
preferred in PEP8, because most lines of code were modified (of this
small file) and this makes pylint significantly less noisy.

Committer testing:

  root@number:/tmp# grep -m1 "model name" /proc/cpuinfo
  model name    : Intel(R) Core(TM) i7-14700K
  root@number:/tmp#
  root@number:/tmp# perf script mem-phys-addr -a find /
  /bin
  /lib
  /lib64
  /sbin
  Warning:
  744 out of order events recorded.
  Event: cpu_core/mem_inst_retired.all_loads/P
  Memory type                                    count  percentage
  ----------------------------------------  ----------  ----------
  100000000-8bfbfffff : System RAM              364561        76.5
    621400000-6223a6fff : Kernel rodata          10474         2.2
    622400000-62283d4bf : Kernel data             4828         1.0
    623304000-6237fffff : Kernel bss              1063         0.2
    620000000-6213fffff : Kernel code               98         0.0
  0-fff : Reserved                              111480        23.4
  100000-2b0ca017 : System RAM                     337         0.1
  2fbad000-30d92fff : System RAM                    44         0.0
  2c79d000-2fbabfff : System RAM                    30         0.0
  30d94000-316d5fff : System RAM                    16         0.0
  2b131a58-2c71dfff : System RAM                     7         0.0
  root@number:/tmp#

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Kan Liang <kan.liang@linux.intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.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/r/20241119180130.19160-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-12-09 17:51:53 -03:00
Tony Jones
b504d7f687 perf script python: Remove mixed indentation
Remove mixed indentation in Python scripts.  Revert to either all tabs
(most common form) or all spaces (4 or 8) depending on what was the
intent of the original commit.  This is necessary to complete Python3
support as it will flag an error if it encounters mixed indentation.

Signed-off-by: Tony Jones <tonyj@suse.de>
Link: http://lkml.kernel.org/r/20190302011903.2416-2-tonyj@suse.de
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-03-06 18:09:14 -03:00
Tony Jones
e4d053ddb4 perf script python: Add Python3 support to mem-phys-addr.py
Support both Python2 and Python3 in the mem-phys-addr.py script

There may be differences in the ordering of output lines due to
differences in dictionary ordering etc.  However the format within lines
should be unchanged.

The use of 'from __future__' implies the minimum supported Python2 version
is now v2.6

Signed-off-by: Tony Jones <tonyj@suse.de>
Link: http://lkml.kernel.org/r/20190222230619.17887-8-tonyj@suse.de
Signed-off-by: Seeteena Thoufeek <s1seetee@linux.vnet.ibm.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2019-02-25 17:16:51 -03:00
Kan Liang
41013f0c09 perf script python: Add script to profile and resolve physical mem type
There could be different types of memory in the system. E.g normal
System Memory, Persistent Memory. To understand how the workload maps to
those memories, it's important to know the I/O statistics of them.  Perf
can collect physical addresses, but those are raw data.  It still needs
extra work to resolve the physical addresses.  Provide a script to
facilitate the physical addresses resolving and I/O statistics.

Profile with MEM_INST_RETIRED.ALL_LOADS or MEM_UOPS_RETIRED.ALL_LOADS
event if any of them is available.

Look up the /proc/iomem and resolve the physical address.  Provide
memory type summary.

Here is an example output:

  # perf script report mem-phys-addr
  Event: mem_inst_retired.all_loads:P
  Memory type                                    count   percentage
  ----------------------------------------  -----------  -----------
  System RAM                                        74        53.2%
  Persistent Memory                                 55        39.6%
  N/A

  ---

Changes since V2:
 - Apply the new license rules.
 - Add comments for globals

Changes since V1:
 - Do not mix DLA and Load Latency. Do not compare the loads and stores.
   Only profile the loads.
 - Use event name to replace the RAW event

Signed-off-by: Kan Liang <Kan.liang@intel.com>
Reviewed-by: Andi Kleen <ak@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Philippe Ombredanne <pombredanne@nexb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lkml.kernel.org/r/1515099595-34770-1-git-send-email-kan.liang@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2018-01-12 11:06:57 -03:00