summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHongfu Li <lihongfu@kylinos.cn>2026-07-13 17:36:26 +0800
committerNamhyung Kim <namhyung@kernel.org>2026-07-15 11:16:41 -0700
commitd30f2d869b6a2e985351867424037eb7bcb57386 (patch)
treeafb93c4bbc4788fa42f8eb1d3db5ed244022873e
parentea46211d7e9a2210b62c40e56b2d6540c0b4b083 (diff)
downloadlinux-d30f2d869b6a2e985351867424037eb7bcb57386.tar.gz
linux-d30f2d869b6a2e985351867424037eb7bcb57386.zip
perf doc: Fix mmap failure checks in topdown example
Use MAP_FAILED instead of NULL to detect mmap errors, and fix the slots_p variable name typo in the sample code. Signed-off-by: Hongfu Li <lihongfu@kylinos.cn> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
-rw-r--r--tools/perf/Documentation/topdown.txt4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/perf/Documentation/topdown.txt b/tools/perf/Documentation/topdown.txt
index 5c17fff694ee..fd4214f9a7b0 100644
--- a/tools/perf/Documentation/topdown.txt
+++ b/tools/perf/Documentation/topdown.txt
@@ -87,7 +87,7 @@ if (slots_fd < 0)
/* Memory mapping the fd permits _rdpmc calls from userspace */
void *slots_p = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, slots_fd, 0);
-if (!slot_p)
+if (slots_p == MAP_FAILED)
.... error ...
/*
@@ -107,7 +107,7 @@ if (metrics_fd < 0)
/* Memory mapping the fd permits _rdpmc calls from userspace */
void *metrics_p = mmap(0, getpagesize(), PROT_READ, MAP_SHARED, metrics_fd, 0);
-if (!metrics_p)
+if (metrics_p == MAP_FAILED)
... error ...
Note: the file descriptors returned by the perf_event_open calls must be memory