Skip to contentSkip to conversation

arm64: perf: Fix the userspace counter example link

PATCH In review TAKANO Mitsuhiro 3 participants 9 messages Nov 6 – Nov 11

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: perf: Fix the userspace counter example link

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but the file does not exist: no file of that name is in tools/perf/arch/arm64/tests/, and no commit in the history leading to this base has added one.

The userspace register access described in this section is covered by the "User space counter reading of instructions" and "User space counter reading of cycles" cases in tools/perf/tests/mmap-basic.c. That file is the only in-tree userspace test that walks the core PMUs, pins the test task to each PMU's CPUs, and selects the PMU by its type number when the kernel accepts the extended type.

perf test -v user runs the four cases in that file; the two reading cases ask for user access through config1.

Point the text and the link target at that file.

make htmldocs does not fetch external links, so a plain documentation build does not report it, but make linkcheckdocs does. I checked that the old link target returns 404 and the new one returns 200. No kernel was built.

The edit and this changelog were written with the help of an LLM assistant (Hermes Agent). I reviewed the diff and the reasoning, and I am responsible for the submission.

Fixes aa1005d15d2a ("Documentation: arm64: Document PMU counters access from userspace")
---
 Documentation/arch/arm64/perf.rst | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/arch/arm64/perf.rst +5 -5
index 997fd716b82f..236cb5da425a 100644
@@ -140,9 +140,9 @@ only be enabled when the tasks are pinned to a homogeneous subset of cores and
 the corresponding PMU instance is opened by specifying the 'type' attribute.
 The use of generic event types is not supported in this case.
 
-Have a look at `tools/perf/arch/arm64/tests/user-events.c`_ for an example. It
-can be run using the perf tool to check that the access to the registers works
-correctly from userspace:
+Have a look at `tools/perf/tests/mmap-basic.c`_ for an example. The two
+'User space counter reading' tests in it can be run using the perf tool to
+check that the access to the registers works correctly from userspace:
 
 .. code-block:: sh
 
@@ -160,8 +160,8 @@ userspace must treat the upper 32-bits read from the counter as UNKNOWN. The
 and should be used to mask the upper bits as needed.
 
 .. Links
-.. _tools/perf/arch/arm64/tests/user-events.c:
-   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c
+.. _tools/perf/tests/mmap-basic.c:
+   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/mmap-basic.c
 .. _tools/lib/perf/tests/test-evsel.c:
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c
 

base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee

Signature · 1 line
2.53.0
#1 lore raw
Sashiko has reviewed this patch and found no issues.
Quoted 23 lines

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but the file does not exist: no file of that name is in tools/perf/arch/arm64/tests/, and no commit in the history leading to this base has added one.

The userspace register access described in this section is covered by the "User space counter reading of instructions" and "User space counter reading of cycles" cases in tools/perf/tests/mmap-basic.c. That file is the only in-tree userspace test that walks the core PMUs, pins the test task to each PMU's CPUs, and selects the PMU by its type number when the kernel accepts the extended type.

perf test -v user runs the four cases in that file; the two reading cases ask for user access through config1.

Point the text and the link target at that file.

make htmldocs does not fetch external links, so a plain documentation build does not report it, but make linkcheckdocs does. I checked that the old link target returns 404 and the new one returns 200. No kernel was built.

Quoted 6 lines

The edit and this changelog were written with the help of an LLM assistant (Hermes Agent). I reviewed the diff and the reasoning, and I am responsible for the submission.

Fixes aa1005d15d2a ("Documentation: arm64: Document PMU counters access from userspace")

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to TAKANO Mitsuhiro
Quoted 38 lines · TAKANO Mitsuhiro

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but the file does not exist: no file of that name is in tools/perf/arch/arm64/tests/, and no commit in the history leading to this base has added one.

The userspace register access described in this section is covered by the "User space counter reading of instructions" and "User space counter reading of cycles" cases in tools/perf/tests/mmap-basic.c. That file is the only in-tree userspace test that walks the core PMUs, pins the test task to each PMU's CPUs, and selects the PMU by its type number when the kernel accepts the extended type.

perf test -v user runs the four cases in that file; the two reading cases ask for user access through config1.

Point the text and the link target at that file.

make htmldocs does not fetch external links, so a plain documentation build does not report it, but make linkcheckdocs does. I checked that the old link target returns 404 and the new one returns 200. No kernel was built.

The edit and this changelog were written with the help of an LLM assistant (Hermes Agent). I reviewed the diff and the reasoning, and I am responsible for the submission.

Fixes aa1005d15d2a ("Documentation: arm64: Document PMU counters access from userspace")
---
  Documentation/arch/arm64/perf.rst | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/arch/arm64/perf.rst +0 -0
index 997fd716b82f..236cb5da425a 100644

Documentation/arch/arm64/perf.rst only be enabled when the tasks are pinned to a homogeneous subset of cores and · line 145

Quoted 9 lines
Documentation/arch/arm64/perf.rst +3 -3
@@ -140,9 +140,9 @@ only be enabled when the tasks are pinned to a homogeneous subset of cores and
  the corresponding PMU instance is opened by specifying the 'type' attribute.
  The use of generic event types is not supported in this case.
 
-Have a look at `tools/perf/arch/arm64/tests/user-events.c`_ for an example. It
-can be run using the perf tool to check that the access to the registers works
-correctly from userspace:
+Have a look at `tools/perf/tests/mmap-basic.c`_ for an example. The two
+'User space counter reading' tests in it can be run using the perf tool to
+check that the access to the registers works correctly from userspace:

The section above already says how to use it, and points to the libperf test as an example.

So this extra reference isn't necessary and is in the "About heterogeneous systems" anyway which doesn't make sense. Unless it's only to show how to call sched_setaffinity(), but that's not really in scope.

I would move the sentence about how to run the test into the "How to" block above and delete the sentence about user-events.c. mmap-basic.c is also a very confusing test IMO so isn't a good example. That saves one reference going stale again in the future.

Quoted 16 lines
Documentation/arch/arm64/perf.rst +2 -2
  .. code-block:: sh
 
@@ -160,8 +160,8 @@ userspace must treat the upper 32-bits read from the counter as UNKNOWN. The
  and should be used to mask the upper bits as needed.
 
  .. Links
-.. _tools/perf/arch/arm64/tests/user-events.c:
-   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c
+.. _tools/perf/tests/mmap-basic.c:
+   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/tests/mmap-basic.c
  .. _tools/lib/perf/tests/test-evsel.c:
     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c
 

base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee

#3 lore raw

You are right on all three points, and the middle one was worse than a style choice: I measured it after your message and "perf test -v user" does not run the cases in mmap-basic.c at all. It matches the tests whose name contains "user" and runs those; the mmap interface cases that file provides are 175.x, so the v1 changelog was wrong about what the command runs as well.

So v2 does what you suggested instead of pointing somewhere else:
the sentence that sends the reader to another file, and its link target, are both gone. The How-to section above already names test-evsel.c as the example, so the instruction for running an example moves there, next to the reference it belongs to:

make -C tools/lib/perf make-tests
tools/lib/perf/tests-static

I built that pair from a clean tree before writing it down, and the Makefile target produces both tests-static and tests-shared.

The section on heterogeneous systems keeps its text about the PMU type number; it just no longer ends with an example pointer that was to a file which does not exist.

#4 lore raw

PATCH v2 1/1 arm64: perf: Drop the example the userspace counter section points at

In reply to TAKANO Mitsuhiro

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but the file does not exist: no file of that name is in tools/perf/arch/arm64/tests/, and no commit in the history leading to this base has added one.

The section already describes how to use the libperf helpers and points at tools/lib/perf/tests/test-evsel.c as the example, so the sentence that sends the reader elsewhere is redundant. Remove it and the link target rather than pointing at another test, and move the instruction for running the example into the How-to section, next to the reference it belongs to.

v1 pointed the reference at tools/perf/tests/mmap-basic.c. The review said that file is a confusing example and that the section above already covers the how-to, which is what this version does.

---
 Documentation/arch/arm64/perf.rst | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
Documentation/arch/arm64/perf.rst +6 -11
index 997fd716b82f..5b9cc2aeb642 100644
@@ -131,7 +131,12 @@ changed.
 
 The userspace access is supported in libperf using the perf_evsel__mmap()
 and perf_evsel__read() functions. See `tools/lib/perf/tests/test-evsel.c`_ for
-an example.
+an example, which can be built and run from the source tree:
+
+.. code-block:: sh
+
+  make -C tools/lib/perf make-tests
+  tools/lib/perf/tests-static
 
 About heterogeneous systems
 ---------------------------
@@ -140,14 +145,6 @@ only be enabled when the tasks are pinned to a homogeneous subset of cores and
 the corresponding PMU instance is opened by specifying the 'type' attribute.
 The use of generic event types is not supported in this case.
 
-Have a look at `tools/perf/arch/arm64/tests/user-events.c`_ for an example. It
-can be run using the perf tool to check that the access to the registers works
-correctly from userspace:
-
-.. code-block:: sh
-
-  perf test -v user
-
 About chained events and counter sizes
 --------------------------------------
 The user can request either a 32-bit (config1:0 == 0) or 64-bit (config1:0 == 1)
@@ -160,8 +157,6 @@ userspace must treat the upper 32-bits read from the counter as UNKNOWN. The
 and should be used to mask the upper bits as needed.
 
 .. Links
-.. _tools/perf/arch/arm64/tests/user-events.c:
-   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c
 .. _tools/lib/perf/tests/test-evsel.c:
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c
 

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb

Signature · 1 line
2.53.0
#5 lore raw

Re: [PATCH v2] arm64: perf: Drop the example the userspace counter section points at

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] docs: arm64: perf: commit message includes v1 changelog and repetitive text --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] docs: arm64: perf: commit message includes v1 changelog and repetitive text
--

commit 4f292c888b9c6465b91000fd55cd46c1bc198a65
Author: TAKANO Mitsuhiro <[email protected]>

Quoted 14 lines

arm64: perf: Drop the example the userspace counter section points at

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but the file does not exist: no file of that name is in tools/perf/arch/arm64/tests/, and no commit in the history leading to this base has added one.

The section already describes how to use the libperf helpers and points at tools/lib/perf/tests/test-evsel.c as the example, so the sentence that sends the reader elsewhere is redundant. Remove it and the link target rather than pointing at another test, and move the instruction for running the example into the How-to section, next to the reference it belongs to.

Quoted 5 lines

v1 pointed the reference at tools/perf/tests/mmap-basic.c. The review said that file is a confusing example and that the section above already covers the how-to, which is what this version does.

[Severity: Low]
This isn't a bug, but the v1 review history in the third paragraph belongs below the --- separator line rather than in the permanent commit log, per Documentation/process/submitting-patches.rst.

Also, the first paragraph repeats that tools/perf/arch/arm64/tests/user-events.c is missing in three different ways ("the file does not exist", "no file of that name is in ...", and "no commit in the history ... has added one"), which could be trimmed for conciseness.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#6 lore raw

PATCH v3 1/1 arm64: perf: Drop the example the userspace counter section points at

In reply to TAKANO Mitsuhiro

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but that file is not in the tree and no commit in the history leading to this base has added one.

The section already describes how to use the libperf helpers and points at tools/lib/perf/tests/test-evsel.c as the example, so the sentence that sends the reader elsewhere is redundant. Remove it and the link target rather than pointing at another test, and move the instruction for running the example into the How-to section, next to the reference it belongs to.

---
v2: drop the reference instead of pointing it at another file, and move
the instruction for running the example into the How-to section.
v3: the v1 history moves here, so the commit log is the change alone; the
sentence about the missing file is stated once. Raised by Sashiko.

 Documentation/arch/arm64/perf.rst | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)
Documentation/arch/arm64/perf.rst +6 -11
index 997fd716b82f..5b9cc2aeb642 100644
@@ -131,7 +131,12 @@ changed.
 
 The userspace access is supported in libperf using the perf_evsel__mmap()
 and perf_evsel__read() functions. See `tools/lib/perf/tests/test-evsel.c`_ for
-an example.
+an example, which can be built and run from the source tree:
+
+.. code-block:: sh
+
+  make -C tools/lib/perf make-tests
+  tools/lib/perf/tests-static
 
 About heterogeneous systems
 ---------------------------
@@ -140,14 +145,6 @@ only be enabled when the tasks are pinned to a homogeneous subset of cores and
 the corresponding PMU instance is opened by specifying the 'type' attribute.
 The use of generic event types is not supported in this case.
 
-Have a look at `tools/perf/arch/arm64/tests/user-events.c`_ for an example. It
-can be run using the perf tool to check that the access to the registers works
-correctly from userspace:
-
-.. code-block:: sh
-
-  perf test -v user
-
 About chained events and counter sizes
 --------------------------------------
 The user can request either a 32-bit (config1:0 == 0) or 64-bit (config1:0 == 1)
@@ -160,8 +157,6 @@ userspace must treat the upper 32-bits read from the counter as UNKNOWN. The
 and should be used to mask the upper bits as needed.
 
 .. Links
-.. _tools/perf/arch/arm64/tests/user-events.c:
-   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c
 .. _tools/lib/perf/tests/test-evsel.c:
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c
 

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb

Signature · 1 line
2.53.0
#7 lore raw

Re: [PATCH v3] arm64: perf: Drop the example the userspace counter section points at

Sashiko has reviewed this patch and found no issues.
Quoted 5 lines

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but that file is not in the tree and no commit in the history leading to this base has added one.

Quoted 7 lines

The section already describes how to use the libperf helpers and points at tools/lib/perf/tests/test-evsel.c as the example, so the sentence that sends the reader elsewhere is redundant. Remove it and the link target rather than pointing at another test, and move the instruction for running the example into the How-to section, next to the reference it belongs to.

Sashiko has reviewed this patch and found no issues.

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Reviewed-by on v3 1/1
#8 lore raw

Re: [PATCH v3] arm64: perf: Drop the example the userspace counter section points at

In reply to TAKANO Mitsuhiro
Quoted 64 lines · TAKANO Mitsuhiro

Documentation/arch/arm64/perf.rst points at tools/perf/arch/arm64/tests/user-events.c, in the text and in the link target, but that file is not in the tree and no commit in the history leading to this base has added one.

The section already describes how to use the libperf helpers and points at tools/lib/perf/tests/test-evsel.c as the example, so the sentence that sends the reader elsewhere is redundant. Remove it and the link target rather than pointing at another test, and move the instruction for running the example into the How-to section, next to the reference it belongs to.

---
v2: drop the reference instead of pointing it at another file, and move
the instruction for running the example into the How-to section.
v3: the v1 history moves here, so the commit log is the change alone; the
sentence about the missing file is stated once. Raised by Sashiko.

  Documentation/arch/arm64/perf.rst | 17 ++++++-----------
  1 file changed, 6 insertions(+), 11 deletions(-)
Documentation/arch/arm64/perf.rst +6 -11
index 997fd716b82f..5b9cc2aeb642 100644
@@ -131,7 +131,12 @@ changed.
 
  The userspace access is supported in libperf using the perf_evsel__mmap()
  and perf_evsel__read() functions. See `tools/lib/perf/tests/test-evsel.c`_ for
-an example.
+an example, which can be built and run from the source tree:
+
+.. code-block:: sh
+
+  make -C tools/lib/perf make-tests
+  tools/lib/perf/tests-static
 
  About heterogeneous systems
  ---------------------------
@@ -140,14 +145,6 @@ only be enabled when the tasks are pinned to a homogeneous subset of cores and
  the corresponding PMU instance is opened by specifying the 'type' attribute.
  The use of generic event types is not supported in this case.
 
-Have a look at `tools/perf/arch/arm64/tests/user-events.c`_ for an example. It
-can be run using the perf tool to check that the access to the registers works
-correctly from userspace:
-
-.. code-block:: sh
-
-  perf test -v user
-
  About chained events and counter sizes
  --------------------------------------
  The user can request either a 32-bit (config1:0 == 0) or 64-bit (config1:0 == 1)
@@ -160,8 +157,6 @@ userspace must treat the upper 32-bits read from the counter as UNKNOWN. The
  and should be used to mask the upper bits as needed.
 
  .. Links
-.. _tools/perf/arch/arm64/tests/user-events.c:
-   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/arch/arm64/tests/user-events.c
  .. _tools/lib/perf/tests/test-evsel.c:
     https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/lib/perf/tests/test-evsel.c
 
Quoted 1 line

base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb