mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [tip: perf/urgent] perf arch: Make the default get_cpuid() return compatible error
       [not found] <tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.org>
@ 2019-12-17 11:31 ` tip-bot2 for Arnaldo Carvalho de Melo
  2019-12-17 11:31 ` [tip: perf/urgent] perf top: Do not bail out when perf_env__read_cpuid() returns ENOSYS tip-bot2 for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot2 for Arnaldo Carvalho de Melo @ 2019-12-17 11:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Mark Rutland, John Garry, Jiri Olsa, Adrian Hunter, Namhyung Kim,
	Will Deacon, Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     05267c7eac12627fae3f25dfd203bfdb9941f9ca
Gitweb:        https://git.kernel.org/tip/05267c7eac12627fae3f25dfd203bfdb9941f9ca
Author:        Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate:    Wed, 11 Dec 2019 10:09:24 -03:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Wed, 11 Dec 2019 12:25:14 -03:00

perf arch: Make the default get_cpuid() return compatible error

Some of the functions calling get_cpuid() propagate back the error it
returns, and all are using errno (positive) values, make the weak
default get_cpuid() function return ENOSYS to be consistent and to allow
checking if this is an arch not providing this function or if a provided
one is having trouble getting the cpuid, to decide if the warning should
be provided to the user or just a debug message should be emitted.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: John Garry <john.garry@huawei.com> # arm64
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lkml.kernel.org/n/tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/header.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index becc2d1..4d39a75 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -850,7 +850,7 @@ int __weak strcmp_cpuid_str(const char *mapcpuid, const char *cpuid)
  */
 int __weak get_cpuid(char *buffer __maybe_unused, size_t sz __maybe_unused)
 {
-	return -1;
+	return ENOSYS; /* Not implemented */
 }
 
 static int write_cpuid(struct feat_fd *ff,

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

* [tip: perf/urgent] perf top: Do not bail out when perf_env__read_cpuid() returns ENOSYS
       [not found] <tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.org>
  2019-12-17 11:31 ` [tip: perf/urgent] perf arch: Make the default get_cpuid() return compatible error tip-bot2 for Arnaldo Carvalho de Melo
@ 2019-12-17 11:31 ` tip-bot2 for Arnaldo Carvalho de Melo
  1 sibling, 0 replies; 2+ messages in thread
From: tip-bot2 for Arnaldo Carvalho de Melo @ 2019-12-17 11:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: John Garry, Mark Rutland, Jiri Olsa, Adrian Hunter, Namhyung Kim,
	Will Deacon, Arnaldo Carvalho de Melo, x86, LKML

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     61208e6e1003b3fd8d2d1f2a72ec27be43955c0b
Gitweb:        https://git.kernel.org/tip/61208e6e1003b3fd8d2d1f2a72ec27be43955c0b
Author:        Arnaldo Carvalho de Melo <acme@redhat.com>
AuthorDate:    Wed, 11 Dec 2019 10:21:59 -03:00
Committer:     Arnaldo Carvalho de Melo <acme@redhat.com>
CommitterDate: Wed, 11 Dec 2019 12:26:25 -03:00

perf top: Do not bail out when perf_env__read_cpuid() returns ENOSYS

'perf top' stopped working on hw architectures that do not provide a
get_cpuid() implementation and thus fallback to the weak get_cpuid()
default function.

This is done because at annotation time we may need it in the arch
specific annotation init routine, but that is only being used by arches
that do provide a get_cpuid() implementation:

  $ find tools/  -name "*.[ch]" | xargs grep 'evlist->env'
  tools/perf/builtin-top.c:	top.evlist->env = &perf_env;
  tools/perf/util/evsel.c:		return evsel->evlist->env;
  tools/perf/util/s390-cpumsf.c:	sf->machine_type = s390_cpumsf_get_type(session->evlist->env->cpuid);
  tools/perf/util/header.c:	session->evlist->env = &header->env;
  tools/perf/util/sample-raw.c:	const char *arch_pf = perf_env__arch(evlist->env);
  $

  $ find tools/perf/arch  -name "*.[ch]" | xargs grep -w get_cpuid
  tools/perf/arch/x86/util/auxtrace.c:	ret = get_cpuid(buffer, sizeof(buffer));
  tools/perf/arch/x86/util/header.c:get_cpuid(char *buffer, size_t sz)
  tools/perf/arch/powerpc/util/header.c:get_cpuid(char *buffer, size_t sz)
  tools/perf/arch/s390/util/header.c: * Implementation of get_cpuid().
  tools/perf/arch/s390/util/header.c:int get_cpuid(char *buffer, size_t sz)
  tools/perf/arch/s390/util/header.c:	if (buf && get_cpuid(buf, 128))
  $

For 'report' or 'script', i.e. tools working on perf.data files, that is
setup while reading the header, its just top that needs to explicitely
read it at tool start.

Fixes: 608127f73779 ("perf top: Initialize perf_env->cpuid, needed by the per arch annotation init routine")
Reported-by: John Garry <john.garry@huawei.com>
Analysed-by: Jiri Olsa <jolsa@kernel.org>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Tested-by: John Garry <john.garry@huawei.com> # arm64
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Will Deacon <will@kernel.org>
Link: https://lkml.kernel.org/n/tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/builtin-top.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index dc80044..795e353 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1568,9 +1568,13 @@ int cmd_top(int argc, const char **argv)
 	 */
 	status = perf_env__read_cpuid(&perf_env);
 	if (status) {
-		pr_err("Couldn't read the cpuid for this machine: %s\n",
-		       str_error_r(errno, errbuf, sizeof(errbuf)));
-		goto out_delete_evlist;
+		/*
+		 * Some arches do not provide a get_cpuid(), so just use pr_debug, otherwise
+		 * warn the user explicitely.
+		 */
+		eprintf(status == ENOSYS ? 1 : 0, verbose,
+			"Couldn't read the cpuid for this machine: %s\n",
+			str_error_r(errno, errbuf, sizeof(errbuf)));
 	}
 	top.evlist->env = &perf_env;
 

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

end of thread, other threads:[~2019-12-17 11:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <tip-lxwjr0cd2eggzx04a780ffrv@git.kernel.org>
2019-12-17 11:31 ` [tip: perf/urgent] perf arch: Make the default get_cpuid() return compatible error tip-bot2 for Arnaldo Carvalho de Melo
2019-12-17 11:31 ` [tip: perf/urgent] perf top: Do not bail out when perf_env__read_cpuid() returns ENOSYS tip-bot2 for Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®