linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing
@ 2021-02-23  8:25 He Zhe
  2021-02-23  8:25 ` [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting He Zhe
  2021-02-23 15:28 ` [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing Will Deacon
  0 siblings, 2 replies; 4+ messages in thread
From: He Zhe @ 2021-02-23  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, mark.rutland, alexander.shishkin, jolsa,
	namhyung, linux-arm-kernel, linux-kernel

As stated in linux/errno.h, ENOTSUPP should never be seen by user programs.
When we set up uprobe with 32-bit perf and arm64 kernel, we would see the
following vague error without useful hint.

The sys_perf_event_open() syscall returned with 524 (INTERNAL ERROR:
strerror_r(524, [buf], 128)=22)

Use EOPNOTSUPP instead to indicate such cases.

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
 arch/arm64/kernel/probes/uprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c
index a412d8edbcd2..2c247634552b 100644
--- a/arch/arm64/kernel/probes/uprobes.c
+++ b/arch/arm64/kernel/probes/uprobes.c
@@ -38,7 +38,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm,
 
 	/* TODO: Currently we do not support AARCH32 instruction probing */
 	if (mm->context.flags & MMCF_AARCH32)
-		return -ENOTSUPP;
+		return -EOPNOTSUPP;
 	else if (!IS_ALIGNED(addr, AARCH64_INSN_SIZE))
 		return -EINVAL;
 
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting
  2021-02-23  8:25 [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing He Zhe
@ 2021-02-23  8:25 ` He Zhe
  2021-03-03  8:30   ` He Zhe
  2021-02-23 15:28 ` [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing Will Deacon
  1 sibling, 1 reply; 4+ messages in thread
From: He Zhe @ 2021-02-23  8:25 UTC (permalink / raw)
  To: catalin.marinas, will, mark.rutland, alexander.shishkin, jolsa,
	namhyung, linux-arm-kernel, linux-kernel

There may be multiple reasons for EOPNOTSUPP. Sometimes we cannot determine
which one it is.

For example, when we set up uprobe with 32-bit perf and arm64 kernel on
some hardware that does not support sampling/overflow-interrupts,
$ perf probe -x /lib/libc.so.6 malloc
$ perf record -e probe_libc:malloc -a ls

Before this patch:
probe_libc:malloc: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'

After this patch:
probe_libc:malloc: PMU Hardware may not support sampling/overflow-interrupts. Try 'perf stat'.
Some 64-bit architectures may not support 32-bit instruction probing.

Signed-off-by: He Zhe <zhe.he@windriver.com>
---
 tools/perf/util/evsel.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index 1bf76864c4f2..aa56511ddf60 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -2697,22 +2697,24 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
 		break;
 	case EOPNOTSUPP:
 		if (evsel->core.attr.aux_output)
-			return scnprintf(msg, size,
-	"%s: PMU Hardware doesn't support 'aux_output' feature",
+			printed += scnprintf(msg + printed, size,
+	"%s: PMU Hardware may not support 'aux_output' feature.\n",
 					 evsel__name(evsel));
 		if (evsel->core.attr.sample_period != 0)
-			return scnprintf(msg, size,
-	"%s: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'",
+			printed += scnprintf(msg + printed, size,
+	"%s: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'.\n",
 					 evsel__name(evsel));
 		if (evsel->core.attr.precise_ip)
-			return scnprintf(msg, size, "%s",
-	"\'precise\' request may not be supported. Try removing 'p' modifier.");
+			printed += scnprintf(msg + printed, size, "%s",
+	"\'precise\' request may not be supported. Try removing 'p' modifier.\n");
 #if defined(__i386__) || defined(__x86_64__)
 		if (evsel->core.attr.type == PERF_TYPE_HARDWARE)
-			return scnprintf(msg, size, "%s",
+			printed += scnprintf(msg + printed, size, "%s",
 	"No hardware sampling interrupt available.\n");
 #endif
-		break;
+		scnprintf(msg + printed, size, "%s",
+	"Some 64-bit architectures may not support 32-bit instruction uprobe.\n");
+		return;
 	case EBUSY:
 		if (find_process("oprofiled"))
 			return scnprintf(msg, size,
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing
  2021-02-23  8:25 [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing He Zhe
  2021-02-23  8:25 ` [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting He Zhe
@ 2021-02-23 15:28 ` Will Deacon
  1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2021-02-23 15:28 UTC (permalink / raw)
  To: catalin.marinas, linux-arm-kernel, He Zhe, jolsa,
	alexander.shishkin, linux-kernel, mark.rutland, namhyung
  Cc: kernel-team, Will Deacon

On Tue, 23 Feb 2021 16:25:34 +0800, He Zhe wrote:
> As stated in linux/errno.h, ENOTSUPP should never be seen by user programs.
> When we set up uprobe with 32-bit perf and arm64 kernel, we would see the
> following vague error without useful hint.
> 
> The sys_perf_event_open() syscall returned with 524 (INTERNAL ERROR:
> strerror_r(524, [buf], 128)=22)
> 
> [...]

Applied first patch only to arm64 (for-next/fixes), thanks!

[1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing
      https://git.kernel.org/arm64/c/d47422d953e2

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting
  2021-02-23  8:25 ` [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting He Zhe
@ 2021-03-03  8:30   ` He Zhe
  0 siblings, 0 replies; 4+ messages in thread
From: He Zhe @ 2021-03-03  8:30 UTC (permalink / raw)
  To: catalin.marinas, will, mark.rutland, alexander.shishkin, jolsa,
	namhyung, linux-arm-kernel, linux-kernel, Peter Zijlstra, mingo,
	acme

Oops, add some supporters from get_maintainer.pl

Zhe

On 2/23/21 4:25 PM, He Zhe wrote:
> There may be multiple reasons for EOPNOTSUPP. Sometimes we cannot determine
> which one it is.
>
> For example, when we set up uprobe with 32-bit perf and arm64 kernel on
> some hardware that does not support sampling/overflow-interrupts,
> $ perf probe -x /lib/libc.so.6 malloc
> $ perf record -e probe_libc:malloc -a ls
>
> Before this patch:
> probe_libc:malloc: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'
>
> After this patch:
> probe_libc:malloc: PMU Hardware may not support sampling/overflow-interrupts. Try 'perf stat'.
> Some 64-bit architectures may not support 32-bit instruction probing.
>
> Signed-off-by: He Zhe <zhe.he@windriver.com>
> ---
>  tools/perf/util/evsel.c | 18 ++++++++++--------
>  1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
> index 1bf76864c4f2..aa56511ddf60 100644
> --- a/tools/perf/util/evsel.c
> +++ b/tools/perf/util/evsel.c
> @@ -2697,22 +2697,24 @@ int evsel__open_strerror(struct evsel *evsel, struct target *target,
>  		break;
>  	case EOPNOTSUPP:
>  		if (evsel->core.attr.aux_output)
> -			return scnprintf(msg, size,
> -	"%s: PMU Hardware doesn't support 'aux_output' feature",
> +			printed += scnprintf(msg + printed, size,
> +	"%s: PMU Hardware may not support 'aux_output' feature.\n",
>  					 evsel__name(evsel));
>  		if (evsel->core.attr.sample_period != 0)
> -			return scnprintf(msg, size,
> -	"%s: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'",
> +			printed += scnprintf(msg + printed, size,
> +	"%s: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'.\n",
>  					 evsel__name(evsel));
>  		if (evsel->core.attr.precise_ip)
> -			return scnprintf(msg, size, "%s",
> -	"\'precise\' request may not be supported. Try removing 'p' modifier.");
> +			printed += scnprintf(msg + printed, size, "%s",
> +	"\'precise\' request may not be supported. Try removing 'p' modifier.\n");
>  #if defined(__i386__) || defined(__x86_64__)
>  		if (evsel->core.attr.type == PERF_TYPE_HARDWARE)
> -			return scnprintf(msg, size, "%s",
> +			printed += scnprintf(msg + printed, size, "%s",
>  	"No hardware sampling interrupt available.\n");
>  #endif
> -		break;
> +		scnprintf(msg + printed, size, "%s",
> +	"Some 64-bit architectures may not support 32-bit instruction uprobe.\n");
> +		return;
>  	case EBUSY:
>  		if (find_process("oprofiled"))
>  			return scnprintf(msg, size,


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-03 15:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-23  8:25 [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing He Zhe
2021-02-23  8:25 ` [PATCH 2/2] perf tools: Improve EOPNOTSUPP error reporting He Zhe
2021-03-03  8:30   ` He Zhe
2021-02-23 15:28 ` [PATCH 1/2] arm64: uprobe: Return EOPNOTSUPP for AARCH32 instruction probing Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).