Skip to contentSkip to conversation

kernel/perf: correct return code of rb_alloc_aux() if !has_aux(ev)

PATCH In review Hendrik Brueckner 3 participants 3 messages Jun 20, 2017 – Jun 21, 2017

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

PATCH 1/1 kernel/perf: correct return code of rb_alloc_aux() if !has_aux(ev)

If the event for which an AUX area is about to be allocated, does not support setting up an AUX area, rb_alloc_aux() return -ENOTSUPP.

This error condition is being returned unfiltered to the user space, and, for example, the perf tools fails with:

failed to mmap with 524 (INTERNAL ERROR: strerror_r(524, 0x3fff497a1c8, 512)=22)

This error can be easily seen with "perf record -m 128,256 -e cpu-clock".

The 524 error code maps to -ENOTSUPP (in rb_alloc_aux()). The -ENOTSUPP error code shall be only used within the kernel. So the correct error code would then be -EOPNOTSUPP.

With this commit, the perf tool then reports:

failed to mmap with 95 (Operation not supported)

which is more clear.

Cc Pu Hou <[email protected]>
Cc Thomas-Mich Richter <[email protected]>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +1 -1
index 2831480..ee97196 100644
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 	int ret = -ENOMEM, max_order = 0;
 
 	if (!has_aux(event))
-		return -ENOTSUPP;
+		return -EOPNOTSUPP;
 
 	if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
 		/*
Signature · 1 line
1.8.3.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Hendrik Brueckner

If the event for which an AUX area is about to be allocated, does not support setting up an AUX area, rb_alloc_aux() return -ENOTSUPP.

This error condition is being returned unfiltered to the user space, and, for example, the perf tools fails with:

failed to mmap with 524 (INTERNAL ERROR: strerror_r(524, 0x3fff497a1c8, 512)=22)

This error can be easily seen with "perf record -m 128,256 -e cpu-clock".

The 524 error code maps to -ENOTSUPP (in rb_alloc_aux()). The -ENOTSUPP error code shall be only used within the kernel. So the correct error code would then be -EOPNOTSUPP.

Quoted 5 lines

With this commit, the perf tool then reports:

failed to mmap with 95 (Operation not supported)

which is more clear.

Curious as to why does the tool allow this.

Regards,
--
Alex

#2 lore raw

[tip:perf/urgent] perf/aux: Correct return code of rb_alloc_aux() if !has_aux(ev)

In reply to Hendrik Brueckner
perf/aux: Correct return code of rb_alloc_aux() if !has_aux(ev)
Commit-ID:  8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Gitweb:     http://git.kernel.org/tip/8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Author:     Hendrik Brueckner <[email protected]>
AuthorDate: Tue, 20 Jun 2017 12:26:39 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 21 Jun 2017 11:58:30 +0200

perf/aux: Correct return code of rb_alloc_aux() if !has_aux(ev)

If the event for which an AUX area is about to be allocated, does not support setting up an AUX area, rb_alloc_aux() return -ENOTSUPP.

This error condition is being returned unfiltered to the user space, and, for example, the perf tools fails with:

failed to mmap with 524 (INTERNAL ERROR: strerror_r(524, 0x3fff497a1c8, 512)=22)

This error can be easily seen with "perf record -m 128,256 -e cpu-clock".

The 524 error code maps to -ENOTSUPP (in rb_alloc_aux()). The -ENOTSUPP error code shall be only used within the kernel. So the correct error code would then be -EOPNOTSUPP.

With this commit, the perf tool then reports:

failed to mmap with 95 (Operation not supported)

which is more clear.

---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/ring_buffer.c +1 -1
index 2831480..ee97196 100644
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
 	int ret = -ENOMEM, max_order = 0;
 
 	if (!has_aux(event))
-		return -ENOTSUPP;
+		return -EOPNOTSUPP;
 
 	if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
 		/*