All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings
@ 2018-01-16  9:46 Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 1/5] tools include arch: Grab a copy of errno.h for arch's supported by perf Hendrik Brueckner
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390

Introduce an interface to perf to resolve errno codes to their names.
This is used by perf trace to display the errno name, for example, ENOENT,
for an system call.  The previous implementation used the errno_to_name()
function from the audit library.

With this change, a table of errno code and names are created for each
architecture on which perf is supported (others can be easily added if
necessary).  The errno_to_name() function from the audit library is
replaced with an arch-specific one, arch_errno_to_name().

The benefit is that perf trace does not longer have a direct dependency
for the audit library and the perf trace output can be displayed across
architectures.  For example, collect trace output on s390 and display it
on x86.

The audit library dependency can be further reduced and completely removed
for architectures that support system call tables in perf (see last commit).

See also discussion on
https://www.spinics.net/lists/linux-perf-users/msg04782.html

Please note that this patch set is bases on the perf/core branch.


Hendrik Brueckner (5):
  tools include arch: Grab a copy of errno.h for arch's supported by
    perf
  tools include asm-generic: Grab errno.h and errno-base.h
  perf util: Introduce architecture specific errno/name mapping
  perf trace: Obtain errno values by using arch_errno_to_name()
  perf trace: Remove audit-libs dependency if syscall tables are present

 tools/arch/alpha/include/uapi/asm/errno.h   | 128 +++++++++++++++++++++++++++
 tools/arch/mips/include/asm/errno.h         |  17 ++++
 tools/arch/mips/include/uapi/asm/errno.h    | 130 ++++++++++++++++++++++++++++
 tools/arch/parisc/include/uapi/asm/errno.h  | 128 +++++++++++++++++++++++++++
 tools/arch/powerpc/include/uapi/asm/errno.h |  10 +++
 tools/arch/sparc/include/uapi/asm/errno.h   | 118 +++++++++++++++++++++++++
 tools/arch/x86/include/uapi/asm/errno.h     |   1 +
 tools/include/uapi/asm-generic/errno-base.h |  40 +++++++++
 tools/include/uapi/asm-generic/errno.h      | 123 ++++++++++++++++++++++++++
 tools/perf/.gitignore                       |   1 +
 tools/perf/Makefile.config                  |  12 ++-
 tools/perf/Makefile.perf                    |   9 +-
 tools/perf/builtin-help.c                   |   2 +-
 tools/perf/builtin-trace.c                  |  14 ++-
 tools/perf/check-headers.sh                 |   9 ++
 tools/perf/perf.c                           |   4 +-
 tools/perf/util/Build                       |   1 +
 tools/perf/util/errno-names.h               |   7 ++
 tools/perf/util/generate-cmdlist.sh         |   2 +-
 tools/perf/util/generate-errno-names.sh     | 101 +++++++++++++++++++++
 20 files changed, 845 insertions(+), 12 deletions(-)
 create mode 100644 tools/arch/alpha/include/uapi/asm/errno.h
 create mode 100644 tools/arch/mips/include/asm/errno.h
 create mode 100644 tools/arch/mips/include/uapi/asm/errno.h
 create mode 100644 tools/arch/parisc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/powerpc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/sparc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/x86/include/uapi/asm/errno.h
 create mode 100644 tools/include/uapi/asm-generic/errno-base.h
 create mode 100644 tools/include/uapi/asm-generic/errno.h
 create mode 100644 tools/perf/util/errno-names.h
 create mode 100755 tools/perf/util/generate-errno-names.sh

-- 
1.8.3.1

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

* [PATCH 1/5] tools include arch: Grab a copy of errno.h for arch's supported by perf
  2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
@ 2018-01-16  9:46 ` Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 2/5] tools include asm-generic: Grab errno.h and errno-base.h Hendrik Brueckner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

For each arch in tools/perf/arch, grab a copy of errno.h.

This is a pre-req to generate an architecture specific mapping of
errno numbers to their names.  This errno mapping can be used by
perf trace to support cross-architecture trace reports and to get
rid of the audit-libs dependency.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
 tools/arch/alpha/include/uapi/asm/errno.h   | 128 +++++++++++++++++++++++++++
 tools/arch/mips/include/asm/errno.h         |  17 ++++
 tools/arch/mips/include/uapi/asm/errno.h    | 130 ++++++++++++++++++++++++++++
 tools/arch/parisc/include/uapi/asm/errno.h  | 128 +++++++++++++++++++++++++++
 tools/arch/powerpc/include/uapi/asm/errno.h |  10 +++
 tools/arch/sparc/include/uapi/asm/errno.h   | 118 +++++++++++++++++++++++++
 tools/arch/x86/include/uapi/asm/errno.h     |   1 +
 tools/perf/check-headers.sh                 |   7 ++
 8 files changed, 539 insertions(+)
 create mode 100644 tools/arch/alpha/include/uapi/asm/errno.h
 create mode 100644 tools/arch/mips/include/asm/errno.h
 create mode 100644 tools/arch/mips/include/uapi/asm/errno.h
 create mode 100644 tools/arch/parisc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/powerpc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/sparc/include/uapi/asm/errno.h
 create mode 100644 tools/arch/x86/include/uapi/asm/errno.h

diff --git a/tools/arch/alpha/include/uapi/asm/errno.h b/tools/arch/alpha/include/uapi/asm/errno.h
new file mode 100644
index 0000000..3d265f6
--- /dev/null
+++ b/tools/arch/alpha/include/uapi/asm/errno.h
@@ -0,0 +1,128 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ALPHA_ERRNO_H
+#define _ALPHA_ERRNO_H
+
+#include <asm-generic/errno-base.h>
+
+#undef	EAGAIN			/* 11 in errno-base.h */
+
+#define	EDEADLK		11	/* Resource deadlock would occur */
+
+#define	EAGAIN		35	/* Try again */
+#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
+#define	EINPROGRESS	36	/* Operation now in progress */
+#define	EALREADY	37	/* Operation already in progress */
+#define	ENOTSOCK	38	/* Socket operation on non-socket */
+#define	EDESTADDRREQ	39	/* Destination address required */
+#define	EMSGSIZE	40	/* Message too long */
+#define	EPROTOTYPE	41	/* Protocol wrong type for socket */
+#define	ENOPROTOOPT	42	/* Protocol not available */
+#define	EPROTONOSUPPORT	43	/* Protocol not supported */
+#define	ESOCKTNOSUPPORT	44	/* Socket type not supported */
+#define	EOPNOTSUPP	45	/* Operation not supported on transport endpoint */
+#define	EPFNOSUPPORT	46	/* Protocol family not supported */
+#define	EAFNOSUPPORT	47	/* Address family not supported by protocol */
+#define	EADDRINUSE	48	/* Address already in use */
+#define	EADDRNOTAVAIL	49	/* Cannot assign requested address */
+#define	ENETDOWN	50	/* Network is down */
+#define	ENETUNREACH	51	/* Network is unreachable */
+#define	ENETRESET	52	/* Network dropped connection because of reset */
+#define	ECONNABORTED	53	/* Software caused connection abort */
+#define	ECONNRESET	54	/* Connection reset by peer */
+#define	ENOBUFS		55	/* No buffer space available */
+#define	EISCONN		56	/* Transport endpoint is already connected */
+#define	ENOTCONN	57	/* Transport endpoint is not connected */
+#define	ESHUTDOWN	58	/* Cannot send after transport endpoint shutdown */
+#define	ETOOMANYREFS	59	/* Too many references: cannot splice */
+#define	ETIMEDOUT	60	/* Connection timed out */
+#define	ECONNREFUSED	61	/* Connection refused */
+#define	ELOOP		62	/* Too many symbolic links encountered */
+#define	ENAMETOOLONG	63	/* File name too long */
+#define	EHOSTDOWN	64	/* Host is down */
+#define	EHOSTUNREACH	65	/* No route to host */
+#define	ENOTEMPTY	66	/* Directory not empty */
+
+#define	EUSERS		68	/* Too many users */
+#define	EDQUOT		69	/* Quota exceeded */
+#define	ESTALE		70	/* Stale file handle */
+#define	EREMOTE		71	/* Object is remote */
+
+#define	ENOLCK		77	/* No record locks available */
+#define	ENOSYS		78	/* Function not implemented */
+
+#define	ENOMSG		80	/* No message of desired type */
+#define	EIDRM		81	/* Identifier removed */
+#define	ENOSR		82	/* Out of streams resources */
+#define	ETIME		83	/* Timer expired */
+#define	EBADMSG		84	/* Not a data message */
+#define	EPROTO		85	/* Protocol error */
+#define	ENODATA		86	/* No data available */
+#define	ENOSTR		87	/* Device not a stream */
+
+#define	ENOPKG		92	/* Package not installed */
+
+#define	EILSEQ		116	/* Illegal byte sequence */
+
+/* The following are just random noise.. */
+#define	ECHRNG		88	/* Channel number out of range */
+#define	EL2NSYNC	89	/* Level 2 not synchronized */
+#define	EL3HLT		90	/* Level 3 halted */
+#define	EL3RST		91	/* Level 3 reset */
+
+#define	ELNRNG		93	/* Link number out of range */
+#define	EUNATCH		94	/* Protocol driver not attached */
+#define	ENOCSI		95	/* No CSI structure available */
+#define	EL2HLT		96	/* Level 2 halted */
+#define	EBADE		97	/* Invalid exchange */
+#define	EBADR		98	/* Invalid request descriptor */
+#define	EXFULL		99	/* Exchange full */
+#define	ENOANO		100	/* No anode */
+#define	EBADRQC		101	/* Invalid request code */
+#define	EBADSLT		102	/* Invalid slot */
+
+#define	EDEADLOCK	EDEADLK
+
+#define	EBFONT		104	/* Bad font file format */
+#define	ENONET		105	/* Machine is not on the network */
+#define	ENOLINK		106	/* Link has been severed */
+#define	EADV		107	/* Advertise error */
+#define	ESRMNT		108	/* Srmount error */
+#define	ECOMM		109	/* Communication error on send */
+#define	EMULTIHOP	110	/* Multihop attempted */
+#define	EDOTDOT		111	/* RFS specific error */
+#define	EOVERFLOW	112	/* Value too large for defined data type */
+#define	ENOTUNIQ	113	/* Name not unique on network */
+#define	EBADFD		114	/* File descriptor in bad state */
+#define	EREMCHG		115	/* Remote address changed */
+
+#define	EUCLEAN		117	/* Structure needs cleaning */
+#define	ENOTNAM		118	/* Not a XENIX named type file */
+#define	ENAVAIL		119	/* No XENIX semaphores available */
+#define	EISNAM		120	/* Is a named type file */
+#define	EREMOTEIO	121	/* Remote I/O error */
+
+#define	ELIBACC		122	/* Can not access a needed shared library */
+#define	ELIBBAD		123	/* Accessing a corrupted shared library */
+#define	ELIBSCN		124	/* .lib section in a.out corrupted */
+#define	ELIBMAX		125	/* Attempting to link in too many shared libraries */
+#define	ELIBEXEC	126	/* Cannot exec a shared library directly */
+#define	ERESTART	127	/* Interrupted system call should be restarted */
+#define	ESTRPIPE	128	/* Streams pipe error */
+
+#define ENOMEDIUM	129	/* No medium found */
+#define EMEDIUMTYPE	130	/* Wrong medium type */
+#define	ECANCELED	131	/* Operation Cancelled */
+#define	ENOKEY		132	/* Required key not available */
+#define	EKEYEXPIRED	133	/* Key has expired */
+#define	EKEYREVOKED	134	/* Key has been revoked */
+#define	EKEYREJECTED	135	/* Key was rejected by service */
+
+/* for robust mutexes */
+#define	EOWNERDEAD	136	/* Owner died */
+#define	ENOTRECOVERABLE	137	/* State not recoverable */
+
+#define	ERFKILL		138	/* Operation not possible due to RF-kill */
+
+#define EHWPOISON	139	/* Memory page has hardware error */
+
+#endif
diff --git a/tools/arch/mips/include/asm/errno.h b/tools/arch/mips/include/asm/errno.h
new file mode 100644
index 0000000..21d91cd
--- /dev/null
+++ b/tools/arch/mips/include/asm/errno.h
@@ -0,0 +1,17 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle
+ */
+#ifndef _ASM_ERRNO_H
+#define _ASM_ERRNO_H
+
+#include <uapi/asm/errno.h>
+
+
+/* The biggest error number defined here or in <linux/errno.h>. */
+#define EMAXERRNO	1133
+
+#endif /* _ASM_ERRNO_H */
diff --git a/tools/arch/mips/include/uapi/asm/errno.h b/tools/arch/mips/include/uapi/asm/errno.h
new file mode 100644
index 0000000..2fb714e
--- /dev/null
+++ b/tools/arch/mips/include/uapi/asm/errno.h
@@ -0,0 +1,130 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle
+ */
+#ifndef _UAPI_ASM_ERRNO_H
+#define _UAPI_ASM_ERRNO_H
+
+/*
+ * These error numbers are intended to be MIPS ABI compatible
+ */
+
+#include <asm-generic/errno-base.h>
+
+#define ENOMSG		35	/* No message of desired type */
+#define EIDRM		36	/* Identifier removed */
+#define ECHRNG		37	/* Channel number out of range */
+#define EL2NSYNC	38	/* Level 2 not synchronized */
+#define EL3HLT		39	/* Level 3 halted */
+#define EL3RST		40	/* Level 3 reset */
+#define ELNRNG		41	/* Link number out of range */
+#define EUNATCH		42	/* Protocol driver not attached */
+#define ENOCSI		43	/* No CSI structure available */
+#define EL2HLT		44	/* Level 2 halted */
+#define EDEADLK		45	/* Resource deadlock would occur */
+#define ENOLCK		46	/* No record locks available */
+#define EBADE		50	/* Invalid exchange */
+#define EBADR		51	/* Invalid request descriptor */
+#define EXFULL		52	/* Exchange full */
+#define ENOANO		53	/* No anode */
+#define EBADRQC		54	/* Invalid request code */
+#define EBADSLT		55	/* Invalid slot */
+#define EDEADLOCK	56	/* File locking deadlock error */
+#define EBFONT		59	/* Bad font file format */
+#define ENOSTR		60	/* Device not a stream */
+#define ENODATA		61	/* No data available */
+#define ETIME		62	/* Timer expired */
+#define ENOSR		63	/* Out of streams resources */
+#define ENONET		64	/* Machine is not on the network */
+#define ENOPKG		65	/* Package not installed */
+#define EREMOTE		66	/* Object is remote */
+#define ENOLINK		67	/* Link has been severed */
+#define EADV		68	/* Advertise error */
+#define ESRMNT		69	/* Srmount error */
+#define ECOMM		70	/* Communication error on send */
+#define EPROTO		71	/* Protocol error */
+#define EDOTDOT		73	/* RFS specific error */
+#define EMULTIHOP	74	/* Multihop attempted */
+#define EBADMSG		77	/* Not a data message */
+#define ENAMETOOLONG	78	/* File name too long */
+#define EOVERFLOW	79	/* Value too large for defined data type */
+#define ENOTUNIQ	80	/* Name not unique on network */
+#define EBADFD		81	/* File descriptor in bad state */
+#define EREMCHG		82	/* Remote address changed */
+#define ELIBACC		83	/* Can not access a needed shared library */
+#define ELIBBAD		84	/* Accessing a corrupted shared library */
+#define ELIBSCN		85	/* .lib section in a.out corrupted */
+#define ELIBMAX		86	/* Attempting to link in too many shared libraries */
+#define ELIBEXEC	87	/* Cannot exec a shared library directly */
+#define EILSEQ		88	/* Illegal byte sequence */
+#define ENOSYS		89	/* Function not implemented */
+#define ELOOP		90	/* Too many symbolic links encountered */
+#define ERESTART	91	/* Interrupted system call should be restarted */
+#define ESTRPIPE	92	/* Streams pipe error */
+#define ENOTEMPTY	93	/* Directory not empty */
+#define EUSERS		94	/* Too many users */
+#define ENOTSOCK	95	/* Socket operation on non-socket */
+#define EDESTADDRREQ	96	/* Destination address required */
+#define EMSGSIZE	97	/* Message too long */
+#define EPROTOTYPE	98	/* Protocol wrong type for socket */
+#define ENOPROTOOPT	99	/* Protocol not available */
+#define EPROTONOSUPPORT 120	/* Protocol not supported */
+#define ESOCKTNOSUPPORT 121	/* Socket type not supported */
+#define EOPNOTSUPP	122	/* Operation not supported on transport endpoint */
+#define EPFNOSUPPORT	123	/* Protocol family not supported */
+#define EAFNOSUPPORT	124	/* Address family not supported by protocol */
+#define EADDRINUSE	125	/* Address already in use */
+#define EADDRNOTAVAIL	126	/* Cannot assign requested address */
+#define ENETDOWN	127	/* Network is down */
+#define ENETUNREACH	128	/* Network is unreachable */
+#define ENETRESET	129	/* Network dropped connection because of reset */
+#define ECONNABORTED	130	/* Software caused connection abort */
+#define ECONNRESET	131	/* Connection reset by peer */
+#define ENOBUFS		132	/* No buffer space available */
+#define EISCONN		133	/* Transport endpoint is already connected */
+#define ENOTCONN	134	/* Transport endpoint is not connected */
+#define EUCLEAN		135	/* Structure needs cleaning */
+#define ENOTNAM		137	/* Not a XENIX named type file */
+#define ENAVAIL		138	/* No XENIX semaphores available */
+#define EISNAM		139	/* Is a named type file */
+#define EREMOTEIO	140	/* Remote I/O error */
+#define EINIT		141	/* Reserved */
+#define EREMDEV		142	/* Error 142 */
+#define ESHUTDOWN	143	/* Cannot send after transport endpoint shutdown */
+#define ETOOMANYREFS	144	/* Too many references: cannot splice */
+#define ETIMEDOUT	145	/* Connection timed out */
+#define ECONNREFUSED	146	/* Connection refused */
+#define EHOSTDOWN	147	/* Host is down */
+#define EHOSTUNREACH	148	/* No route to host */
+#define EWOULDBLOCK	EAGAIN	/* Operation would block */
+#define EALREADY	149	/* Operation already in progress */
+#define EINPROGRESS	150	/* Operation now in progress */
+#define ESTALE		151	/* Stale file handle */
+#define ECANCELED	158	/* AIO operation canceled */
+
+/*
+ * These error are Linux extensions.
+ */
+#define ENOMEDIUM	159	/* No medium found */
+#define EMEDIUMTYPE	160	/* Wrong medium type */
+#define ENOKEY		161	/* Required key not available */
+#define EKEYEXPIRED	162	/* Key has expired */
+#define EKEYREVOKED	163	/* Key has been revoked */
+#define EKEYREJECTED	164	/* Key was rejected by service */
+
+/* for robust mutexes */
+#define EOWNERDEAD	165	/* Owner died */
+#define ENOTRECOVERABLE 166	/* State not recoverable */
+
+#define ERFKILL		167	/* Operation not possible due to RF-kill */
+
+#define EHWPOISON	168	/* Memory page has hardware error */
+
+#define EDQUOT		1133	/* Quota exceeded */
+
+
+#endif /* _UAPI_ASM_ERRNO_H */
diff --git a/tools/arch/parisc/include/uapi/asm/errno.h b/tools/arch/parisc/include/uapi/asm/errno.h
new file mode 100644
index 0000000..fc0df35
--- /dev/null
+++ b/tools/arch/parisc/include/uapi/asm/errno.h
@@ -0,0 +1,128 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _PARISC_ERRNO_H
+#define _PARISC_ERRNO_H
+
+#include <asm-generic/errno-base.h>
+
+#define	ENOMSG		35	/* No message of desired type */
+#define	EIDRM		36	/* Identifier removed */
+#define	ECHRNG		37	/* Channel number out of range */
+#define	EL2NSYNC	38	/* Level 2 not synchronized */
+#define	EL3HLT		39	/* Level 3 halted */
+#define	EL3RST		40	/* Level 3 reset */
+#define	ELNRNG		41	/* Link number out of range */
+#define	EUNATCH		42	/* Protocol driver not attached */
+#define	ENOCSI		43	/* No CSI structure available */
+#define	EL2HLT		44	/* Level 2 halted */
+#define	EDEADLK		45	/* Resource deadlock would occur */
+#define	EDEADLOCK	EDEADLK
+#define	ENOLCK		46	/* No record locks available */
+#define	EILSEQ		47	/* Illegal byte sequence */
+
+#define	ENONET		50	/* Machine is not on the network */
+#define	ENODATA		51	/* No data available */
+#define	ETIME		52	/* Timer expired */
+#define	ENOSR		53	/* Out of streams resources */
+#define	ENOSTR		54	/* Device not a stream */
+#define	ENOPKG		55	/* Package not installed */
+
+#define	ENOLINK		57	/* Link has been severed */
+#define	EADV		58	/* Advertise error */
+#define	ESRMNT		59	/* Srmount error */
+#define	ECOMM		60	/* Communication error on send */
+#define	EPROTO		61	/* Protocol error */
+
+#define	EMULTIHOP	64	/* Multihop attempted */
+
+#define	EDOTDOT		66	/* RFS specific error */
+#define	EBADMSG		67	/* Not a data message */
+#define	EUSERS		68	/* Too many users */
+#define	EDQUOT		69	/* Quota exceeded */
+#define	ESTALE		70	/* Stale file handle */
+#define	EREMOTE		71	/* Object is remote */
+#define	EOVERFLOW	72	/* Value too large for defined data type */
+
+/* these errnos are defined by Linux but not HPUX. */
+
+#define	EBADE		160	/* Invalid exchange */
+#define	EBADR		161	/* Invalid request descriptor */
+#define	EXFULL		162	/* Exchange full */
+#define	ENOANO		163	/* No anode */
+#define	EBADRQC		164	/* Invalid request code */
+#define	EBADSLT		165	/* Invalid slot */
+#define	EBFONT		166	/* Bad font file format */
+#define	ENOTUNIQ	167	/* Name not unique on network */
+#define	EBADFD		168	/* File descriptor in bad state */
+#define	EREMCHG		169	/* Remote address changed */
+#define	ELIBACC		170	/* Can not access a needed shared library */
+#define	ELIBBAD		171	/* Accessing a corrupted shared library */
+#define	ELIBSCN		172	/* .lib section in a.out corrupted */
+#define	ELIBMAX		173	/* Attempting to link in too many shared libraries */
+#define	ELIBEXEC	174	/* Cannot exec a shared library directly */
+#define	ERESTART	175	/* Interrupted system call should be restarted */
+#define	ESTRPIPE	176	/* Streams pipe error */
+#define	EUCLEAN		177	/* Structure needs cleaning */
+#define	ENOTNAM		178	/* Not a XENIX named type file */
+#define	ENAVAIL		179	/* No XENIX semaphores available */
+#define	EISNAM		180	/* Is a named type file */
+#define	EREMOTEIO	181	/* Remote I/O error */
+#define	ENOMEDIUM	182	/* No medium found */
+#define	EMEDIUMTYPE	183	/* Wrong medium type */
+#define	ENOKEY		184	/* Required key not available */
+#define	EKEYEXPIRED	185	/* Key has expired */
+#define	EKEYREVOKED	186	/* Key has been revoked */
+#define	EKEYREJECTED	187	/* Key was rejected by service */
+
+/* We now return you to your regularly scheduled HPUX. */
+
+#define ENOSYM		215	/* symbol does not exist in executable */
+#define	ENOTSOCK	216	/* Socket operation on non-socket */
+#define	EDESTADDRREQ	217	/* Destination address required */
+#define	EMSGSIZE	218	/* Message too long */
+#define	EPROTOTYPE	219	/* Protocol wrong type for socket */
+#define	ENOPROTOOPT	220	/* Protocol not available */
+#define	EPROTONOSUPPORT	221	/* Protocol not supported */
+#define	ESOCKTNOSUPPORT	222	/* Socket type not supported */
+#define	EOPNOTSUPP	223	/* Operation not supported on transport endpoint */
+#define	EPFNOSUPPORT	224	/* Protocol family not supported */
+#define	EAFNOSUPPORT	225	/* Address family not supported by protocol */
+#define	EADDRINUSE	226	/* Address already in use */
+#define	EADDRNOTAVAIL	227	/* Cannot assign requested address */
+#define	ENETDOWN	228	/* Network is down */
+#define	ENETUNREACH	229	/* Network is unreachable */
+#define	ENETRESET	230	/* Network dropped connection because of reset */
+#define	ECONNABORTED	231	/* Software caused connection abort */
+#define	ECONNRESET	232	/* Connection reset by peer */
+#define	ENOBUFS		233	/* No buffer space available */
+#define	EISCONN		234	/* Transport endpoint is already connected */
+#define	ENOTCONN	235	/* Transport endpoint is not connected */
+#define	ESHUTDOWN	236	/* Cannot send after transport endpoint shutdown */
+#define	ETOOMANYREFS	237	/* Too many references: cannot splice */
+#define	ETIMEDOUT	238	/* Connection timed out */
+#define	ECONNREFUSED	239	/* Connection refused */
+#define	EREFUSED	ECONNREFUSED	/* for HP's NFS apparently */
+#define	EREMOTERELEASE	240	/* Remote peer released connection */
+#define	EHOSTDOWN	241	/* Host is down */
+#define	EHOSTUNREACH	242	/* No route to host */
+
+#define	EALREADY	244	/* Operation already in progress */
+#define	EINPROGRESS	245	/* Operation now in progress */
+#define	EWOULDBLOCK	EAGAIN	/* Operation would block (Not HPUX compliant) */
+#define	ENOTEMPTY	247	/* Directory not empty */
+#define	ENAMETOOLONG	248	/* File name too long */
+#define	ELOOP		249	/* Too many symbolic links encountered */
+#define	ENOSYS		251	/* Function not implemented */
+
+#define ENOTSUP		252	/* Function not implemented (POSIX.4 / HPUX) */
+#define ECANCELLED	253	/* aio request was canceled before complete (POSIX.4 / HPUX) */
+#define ECANCELED	ECANCELLED	/* SuSv3 and Solaris wants one 'L' */
+
+/* for robust mutexes */
+#define EOWNERDEAD	254	/* Owner died */
+#define ENOTRECOVERABLE	255	/* State not recoverable */
+
+#define	ERFKILL		256	/* Operation not possible due to RF-kill */
+
+#define EHWPOISON	257	/* Memory page has hardware error */
+
+#endif
diff --git a/tools/arch/powerpc/include/uapi/asm/errno.h b/tools/arch/powerpc/include/uapi/asm/errno.h
new file mode 100644
index 0000000..cc79856
--- /dev/null
+++ b/tools/arch/powerpc/include/uapi/asm/errno.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_POWERPC_ERRNO_H
+#define _ASM_POWERPC_ERRNO_H
+
+#include <asm-generic/errno.h>
+
+#undef	EDEADLOCK
+#define	EDEADLOCK	58	/* File locking deadlock error */
+
+#endif	/* _ASM_POWERPC_ERRNO_H */
diff --git a/tools/arch/sparc/include/uapi/asm/errno.h b/tools/arch/sparc/include/uapi/asm/errno.h
new file mode 100644
index 0000000..81a732b
--- /dev/null
+++ b/tools/arch/sparc/include/uapi/asm/errno.h
@@ -0,0 +1,118 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _SPARC_ERRNO_H
+#define _SPARC_ERRNO_H
+
+/* These match the SunOS error numbering scheme. */
+
+#include <asm-generic/errno-base.h>
+
+#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
+#define	EINPROGRESS	36	/* Operation now in progress */
+#define	EALREADY	37	/* Operation already in progress */
+#define	ENOTSOCK	38	/* Socket operation on non-socket */
+#define	EDESTADDRREQ	39	/* Destination address required */
+#define	EMSGSIZE	40	/* Message too long */
+#define	EPROTOTYPE	41	/* Protocol wrong type for socket */
+#define	ENOPROTOOPT	42	/* Protocol not available */
+#define	EPROTONOSUPPORT	43	/* Protocol not supported */
+#define	ESOCKTNOSUPPORT	44	/* Socket type not supported */
+#define	EOPNOTSUPP	45	/* Op not supported on transport endpoint */
+#define	EPFNOSUPPORT	46	/* Protocol family not supported */
+#define	EAFNOSUPPORT	47	/* Address family not supported by protocol */
+#define	EADDRINUSE	48	/* Address already in use */
+#define	EADDRNOTAVAIL	49	/* Cannot assign requested address */
+#define	ENETDOWN	50	/* Network is down */
+#define	ENETUNREACH	51	/* Network is unreachable */
+#define	ENETRESET	52	/* Net dropped connection because of reset */
+#define	ECONNABORTED	53	/* Software caused connection abort */
+#define	ECONNRESET	54	/* Connection reset by peer */
+#define	ENOBUFS		55	/* No buffer space available */
+#define	EISCONN		56	/* Transport endpoint is already connected */
+#define	ENOTCONN	57	/* Transport endpoint is not connected */
+#define	ESHUTDOWN	58	/* No send after transport endpoint shutdown */
+#define	ETOOMANYREFS	59	/* Too many references: cannot splice */
+#define	ETIMEDOUT	60	/* Connection timed out */
+#define	ECONNREFUSED	61	/* Connection refused */
+#define	ELOOP		62	/* Too many symbolic links encountered */
+#define	ENAMETOOLONG	63	/* File name too long */
+#define	EHOSTDOWN	64	/* Host is down */
+#define	EHOSTUNREACH	65	/* No route to host */
+#define	ENOTEMPTY	66	/* Directory not empty */
+#define EPROCLIM        67      /* SUNOS: Too many processes */
+#define	EUSERS		68	/* Too many users */
+#define	EDQUOT		69	/* Quota exceeded */
+#define	ESTALE		70	/* Stale file handle */
+#define	EREMOTE		71	/* Object is remote */
+#define	ENOSTR		72	/* Device not a stream */
+#define	ETIME		73	/* Timer expired */
+#define	ENOSR		74	/* Out of streams resources */
+#define	ENOMSG		75	/* No message of desired type */
+#define	EBADMSG		76	/* Not a data message */
+#define	EIDRM		77	/* Identifier removed */
+#define	EDEADLK		78	/* Resource deadlock would occur */
+#define	ENOLCK		79	/* No record locks available */
+#define	ENONET		80	/* Machine is not on the network */
+#define ERREMOTE        81      /* SunOS: Too many lvls of remote in path */
+#define	ENOLINK		82	/* Link has been severed */
+#define	EADV		83	/* Advertise error */
+#define	ESRMNT		84	/* Srmount error */
+#define	ECOMM		85      /* Communication error on send */
+#define	EPROTO		86	/* Protocol error */
+#define	EMULTIHOP	87	/* Multihop attempted */
+#define	EDOTDOT		88	/* RFS specific error */
+#define	EREMCHG		89	/* Remote address changed */
+#define	ENOSYS		90	/* Function not implemented */
+
+/* The rest have no SunOS equivalent. */
+#define	ESTRPIPE	91	/* Streams pipe error */
+#define	EOVERFLOW	92	/* Value too large for defined data type */
+#define	EBADFD		93	/* File descriptor in bad state */
+#define	ECHRNG		94	/* Channel number out of range */
+#define	EL2NSYNC	95	/* Level 2 not synchronized */
+#define	EL3HLT		96	/* Level 3 halted */
+#define	EL3RST		97	/* Level 3 reset */
+#define	ELNRNG		98	/* Link number out of range */
+#define	EUNATCH		99	/* Protocol driver not attached */
+#define	ENOCSI		100	/* No CSI structure available */
+#define	EL2HLT		101	/* Level 2 halted */
+#define	EBADE		102	/* Invalid exchange */
+#define	EBADR		103	/* Invalid request descriptor */
+#define	EXFULL		104	/* Exchange full */
+#define	ENOANO		105	/* No anode */
+#define	EBADRQC		106	/* Invalid request code */
+#define	EBADSLT		107	/* Invalid slot */
+#define	EDEADLOCK	108	/* File locking deadlock error */
+#define	EBFONT		109	/* Bad font file format */
+#define	ELIBEXEC	110	/* Cannot exec a shared library directly */
+#define	ENODATA		111	/* No data available */
+#define	ELIBBAD		112	/* Accessing a corrupted shared library */
+#define	ENOPKG		113	/* Package not installed */
+#define	ELIBACC		114	/* Can not access a needed shared library */
+#define	ENOTUNIQ	115	/* Name not unique on network */
+#define	ERESTART	116	/* Interrupted syscall should be restarted */
+#define	EUCLEAN		117	/* Structure needs cleaning */
+#define	ENOTNAM		118	/* Not a XENIX named type file */
+#define	ENAVAIL		119	/* No XENIX semaphores available */
+#define	EISNAM		120	/* Is a named type file */
+#define	EREMOTEIO	121	/* Remote I/O error */
+#define	EILSEQ		122	/* Illegal byte sequence */
+#define	ELIBMAX		123	/* Atmpt to link in too many shared libs */
+#define	ELIBSCN		124	/* .lib section in a.out corrupted */
+
+#define	ENOMEDIUM	125	/* No medium found */
+#define	EMEDIUMTYPE	126	/* Wrong medium type */
+#define	ECANCELED	127	/* Operation Cancelled */
+#define	ENOKEY		128	/* Required key not available */
+#define	EKEYEXPIRED	129	/* Key has expired */
+#define	EKEYREVOKED	130	/* Key has been revoked */
+#define	EKEYREJECTED	131	/* Key was rejected by service */
+
+/* for robust mutexes */
+#define	EOWNERDEAD	132	/* Owner died */
+#define	ENOTRECOVERABLE	133	/* State not recoverable */
+
+#define	ERFKILL		134	/* Operation not possible due to RF-kill */
+
+#define EHWPOISON	135	/* Memory page has hardware error */
+
+#endif
diff --git a/tools/arch/x86/include/uapi/asm/errno.h b/tools/arch/x86/include/uapi/asm/errno.h
new file mode 100644
index 0000000..4c82b50
--- /dev/null
+++ b/tools/arch/x86/include/uapi/asm/errno.h
@@ -0,0 +1 @@
+#include <asm-generic/errno.h>
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index f81ca50..83a65d3 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -36,6 +36,13 @@ arch/s390/include/uapi/asm/sie.h
 arch/s390/include/uapi/asm/unistd.h
 arch/arm/include/uapi/asm/kvm.h
 arch/arm64/include/uapi/asm/kvm.h
+arch/alpha/include/uapi/asm/errno.h
+arch/mips/include/asm/errno.h
+arch/mips/include/uapi/asm/errno.h
+arch/parisc/include/uapi/asm/errno.h
+arch/powerpc/include/uapi/asm/errno.h
+arch/sparc/include/uapi/asm/errno.h
+arch/x86/include/uapi/asm/errno.h
 include/asm-generic/bitops/arch_hweight.h
 include/asm-generic/bitops/const_hweight.h
 include/asm-generic/bitops/__fls.h
-- 
1.8.3.1

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

* [PATCH 2/5] tools include asm-generic: Grab errno.h and errno-base.h
  2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 1/5] tools include arch: Grab a copy of errno.h for arch's supported by perf Hendrik Brueckner
@ 2018-01-16  9:46 ` Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping Hendrik Brueckner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

This is a pre-req to generate an architecture specific mapping of
errno numbers to their names.  This errno mapping can be used by
perf trace to support cross-architecture trace reports and to
get rid of the audit-libs dependency.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
 tools/include/uapi/asm-generic/errno-base.h |  40 +++++++++
 tools/include/uapi/asm-generic/errno.h      | 123 ++++++++++++++++++++++++++++
 tools/perf/check-headers.sh                 |   2 +
 3 files changed, 165 insertions(+)
 create mode 100644 tools/include/uapi/asm-generic/errno-base.h
 create mode 100644 tools/include/uapi/asm-generic/errno.h

diff --git a/tools/include/uapi/asm-generic/errno-base.h b/tools/include/uapi/asm-generic/errno-base.h
new file mode 100644
index 0000000..9653140
--- /dev/null
+++ b/tools/include/uapi/asm-generic/errno-base.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_GENERIC_ERRNO_BASE_H
+#define _ASM_GENERIC_ERRNO_BASE_H
+
+#define	EPERM		 1	/* Operation not permitted */
+#define	ENOENT		 2	/* No such file or directory */
+#define	ESRCH		 3	/* No such process */
+#define	EINTR		 4	/* Interrupted system call */
+#define	EIO		 5	/* I/O error */
+#define	ENXIO		 6	/* No such device or address */
+#define	E2BIG		 7	/* Argument list too long */
+#define	ENOEXEC		 8	/* Exec format error */
+#define	EBADF		 9	/* Bad file number */
+#define	ECHILD		10	/* No child processes */
+#define	EAGAIN		11	/* Try again */
+#define	ENOMEM		12	/* Out of memory */
+#define	EACCES		13	/* Permission denied */
+#define	EFAULT		14	/* Bad address */
+#define	ENOTBLK		15	/* Block device required */
+#define	EBUSY		16	/* Device or resource busy */
+#define	EEXIST		17	/* File exists */
+#define	EXDEV		18	/* Cross-device link */
+#define	ENODEV		19	/* No such device */
+#define	ENOTDIR		20	/* Not a directory */
+#define	EISDIR		21	/* Is a directory */
+#define	EINVAL		22	/* Invalid argument */
+#define	ENFILE		23	/* File table overflow */
+#define	EMFILE		24	/* Too many open files */
+#define	ENOTTY		25	/* Not a typewriter */
+#define	ETXTBSY		26	/* Text file busy */
+#define	EFBIG		27	/* File too large */
+#define	ENOSPC		28	/* No space left on device */
+#define	ESPIPE		29	/* Illegal seek */
+#define	EROFS		30	/* Read-only file system */
+#define	EMLINK		31	/* Too many links */
+#define	EPIPE		32	/* Broken pipe */
+#define	EDOM		33	/* Math argument out of domain of func */
+#define	ERANGE		34	/* Math result not representable */
+
+#endif
diff --git a/tools/include/uapi/asm-generic/errno.h b/tools/include/uapi/asm-generic/errno.h
new file mode 100644
index 0000000..cf9c51a
--- /dev/null
+++ b/tools/include/uapi/asm-generic/errno.h
@@ -0,0 +1,123 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+#ifndef _ASM_GENERIC_ERRNO_H
+#define _ASM_GENERIC_ERRNO_H
+
+#include <asm-generic/errno-base.h>
+
+#define	EDEADLK		35	/* Resource deadlock would occur */
+#define	ENAMETOOLONG	36	/* File name too long */
+#define	ENOLCK		37	/* No record locks available */
+
+/*
+ * This error code is special: arch syscall entry code will return
+ * -ENOSYS if users try to call a syscall that doesn't exist.  To keep
+ * failures of syscalls that really do exist distinguishable from
+ * failures due to attempts to use a nonexistent syscall, syscall
+ * implementations should refrain from returning -ENOSYS.
+ */
+#define	ENOSYS		38	/* Invalid system call number */
+
+#define	ENOTEMPTY	39	/* Directory not empty */
+#define	ELOOP		40	/* Too many symbolic links encountered */
+#define	EWOULDBLOCK	EAGAIN	/* Operation would block */
+#define	ENOMSG		42	/* No message of desired type */
+#define	EIDRM		43	/* Identifier removed */
+#define	ECHRNG		44	/* Channel number out of range */
+#define	EL2NSYNC	45	/* Level 2 not synchronized */
+#define	EL3HLT		46	/* Level 3 halted */
+#define	EL3RST		47	/* Level 3 reset */
+#define	ELNRNG		48	/* Link number out of range */
+#define	EUNATCH		49	/* Protocol driver not attached */
+#define	ENOCSI		50	/* No CSI structure available */
+#define	EL2HLT		51	/* Level 2 halted */
+#define	EBADE		52	/* Invalid exchange */
+#define	EBADR		53	/* Invalid request descriptor */
+#define	EXFULL		54	/* Exchange full */
+#define	ENOANO		55	/* No anode */
+#define	EBADRQC		56	/* Invalid request code */
+#define	EBADSLT		57	/* Invalid slot */
+
+#define	EDEADLOCK	EDEADLK
+
+#define	EBFONT		59	/* Bad font file format */
+#define	ENOSTR		60	/* Device not a stream */
+#define	ENODATA		61	/* No data available */
+#define	ETIME		62	/* Timer expired */
+#define	ENOSR		63	/* Out of streams resources */
+#define	ENONET		64	/* Machine is not on the network */
+#define	ENOPKG		65	/* Package not installed */
+#define	EREMOTE		66	/* Object is remote */
+#define	ENOLINK		67	/* Link has been severed */
+#define	EADV		68	/* Advertise error */
+#define	ESRMNT		69	/* Srmount error */
+#define	ECOMM		70	/* Communication error on send */
+#define	EPROTO		71	/* Protocol error */
+#define	EMULTIHOP	72	/* Multihop attempted */
+#define	EDOTDOT		73	/* RFS specific error */
+#define	EBADMSG		74	/* Not a data message */
+#define	EOVERFLOW	75	/* Value too large for defined data type */
+#define	ENOTUNIQ	76	/* Name not unique on network */
+#define	EBADFD		77	/* File descriptor in bad state */
+#define	EREMCHG		78	/* Remote address changed */
+#define	ELIBACC		79	/* Can not access a needed shared library */
+#define	ELIBBAD		80	/* Accessing a corrupted shared library */
+#define	ELIBSCN		81	/* .lib section in a.out corrupted */
+#define	ELIBMAX		82	/* Attempting to link in too many shared libraries */
+#define	ELIBEXEC	83	/* Cannot exec a shared library directly */
+#define	EILSEQ		84	/* Illegal byte sequence */
+#define	ERESTART	85	/* Interrupted system call should be restarted */
+#define	ESTRPIPE	86	/* Streams pipe error */
+#define	EUSERS		87	/* Too many users */
+#define	ENOTSOCK	88	/* Socket operation on non-socket */
+#define	EDESTADDRREQ	89	/* Destination address required */
+#define	EMSGSIZE	90	/* Message too long */
+#define	EPROTOTYPE	91	/* Protocol wrong type for socket */
+#define	ENOPROTOOPT	92	/* Protocol not available */
+#define	EPROTONOSUPPORT	93	/* Protocol not supported */
+#define	ESOCKTNOSUPPORT	94	/* Socket type not supported */
+#define	EOPNOTSUPP	95	/* Operation not supported on transport endpoint */
+#define	EPFNOSUPPORT	96	/* Protocol family not supported */
+#define	EAFNOSUPPORT	97	/* Address family not supported by protocol */
+#define	EADDRINUSE	98	/* Address already in use */
+#define	EADDRNOTAVAIL	99	/* Cannot assign requested address */
+#define	ENETDOWN	100	/* Network is down */
+#define	ENETUNREACH	101	/* Network is unreachable */
+#define	ENETRESET	102	/* Network dropped connection because of reset */
+#define	ECONNABORTED	103	/* Software caused connection abort */
+#define	ECONNRESET	104	/* Connection reset by peer */
+#define	ENOBUFS		105	/* No buffer space available */
+#define	EISCONN		106	/* Transport endpoint is already connected */
+#define	ENOTCONN	107	/* Transport endpoint is not connected */
+#define	ESHUTDOWN	108	/* Cannot send after transport endpoint shutdown */
+#define	ETOOMANYREFS	109	/* Too many references: cannot splice */
+#define	ETIMEDOUT	110	/* Connection timed out */
+#define	ECONNREFUSED	111	/* Connection refused */
+#define	EHOSTDOWN	112	/* Host is down */
+#define	EHOSTUNREACH	113	/* No route to host */
+#define	EALREADY	114	/* Operation already in progress */
+#define	EINPROGRESS	115	/* Operation now in progress */
+#define	ESTALE		116	/* Stale file handle */
+#define	EUCLEAN		117	/* Structure needs cleaning */
+#define	ENOTNAM		118	/* Not a XENIX named type file */
+#define	ENAVAIL		119	/* No XENIX semaphores available */
+#define	EISNAM		120	/* Is a named type file */
+#define	EREMOTEIO	121	/* Remote I/O error */
+#define	EDQUOT		122	/* Quota exceeded */
+
+#define	ENOMEDIUM	123	/* No medium found */
+#define	EMEDIUMTYPE	124	/* Wrong medium type */
+#define	ECANCELED	125	/* Operation Canceled */
+#define	ENOKEY		126	/* Required key not available */
+#define	EKEYEXPIRED	127	/* Key has expired */
+#define	EKEYREVOKED	128	/* Key has been revoked */
+#define	EKEYREJECTED	129	/* Key was rejected by service */
+
+/* for robust mutexes */
+#define	EOWNERDEAD	130	/* Owner died */
+#define	ENOTRECOVERABLE	131	/* State not recoverable */
+
+#define ERFKILL		132	/* Operation not possible due to RF-kill */
+
+#define EHWPOISON	133	/* Memory page has hardware error */
+
+#endif
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 83a65d3..51abdb0 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -49,6 +49,8 @@ include/asm-generic/bitops/__fls.h
 include/asm-generic/bitops/fls.h
 include/asm-generic/bitops/fls64.h
 include/linux/coresight-pmu.h
+include/uapi/asm-generic/errno.h
+include/uapi/asm-generic/errno-base.h
 include/uapi/asm-generic/ioctls.h
 include/uapi/asm-generic/mman-common.h
 '
-- 
1.8.3.1

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

* [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 1/5] tools include arch: Grab a copy of errno.h for arch's supported by perf Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 2/5] tools include asm-generic: Grab errno.h and errno-base.h Hendrik Brueckner
@ 2018-01-16  9:46 ` Hendrik Brueckner
  2018-01-16 13:58   ` Arnaldo Carvalho de Melo
  2018-01-18 10:07   ` Jiri Olsa
  2018-01-16  9:46 ` [PATCH 4/5] perf trace: Obtain errno values by using arch_errno_to_name() Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 5/5] perf trace: Remove audit-libs dependency if syscall tables are present Hendrik Brueckner
  4 siblings, 2 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

Introduce a script that generates a mapping of errno numbers to
their names for each architecture that is supported by perf (i.e.
has a subdirectory in tools/perf/arch/).

The file is generated as util/errno-names.c.  A corresponding
header file util/errno-names.h is provided that defines the
arch_errno_to_name() function.  Use arch_errno_to_name() to
lookup an errno value to obtain the errno name (e.g. ENOENT)
for a particular architecture.

This is to be used by perf trace.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/.gitignore                   |   1 +
 tools/perf/Makefile.config              |   2 +-
 tools/perf/Makefile.perf                |   9 ++-
 tools/perf/util/Build                   |   1 +
 tools/perf/util/errno-names.h           |   7 +++
 tools/perf/util/generate-errno-names.sh | 101 ++++++++++++++++++++++++++++++++
 6 files changed, 118 insertions(+), 3 deletions(-)
 create mode 100644 tools/perf/util/errno-names.h
 create mode 100755 tools/perf/util/generate-errno-names.sh

diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 643cc4ba..1d4d43c 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -14,6 +14,7 @@ perf*.1
 perf*.xml
 perf*.html
 common-cmds.h
+errno-names.c
 perf.data
 perf.data.old
 output.svg
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 12dec6e..90ce14f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
 INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
 
-# $(obj-perf)      for generated common-cmds.h
+# $(obj-perf)      for generated common-cmds.h and errno-names.c
 # $(obj-perf)/util for generated bison/flex headers
 ifneq ($(OUTPUT),)
 INC_FLAGS += -I$(obj-perf)/util
diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 9fdefd7..332b4b4 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
 $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
 	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
 
+$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
+	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
+
 $(SCRIPTS) : % : %.sh
 	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
 
@@ -565,7 +568,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
 	$(vhost_virtio_ioctl_array) \
 	$(madvise_behavior_array) \
 	$(perf_ioctl_array) \
-	$(prctl_option_array)
+	$(prctl_option_array) \
+	$(OUTPUT)util/errno-names.c
 
 $(OUTPUT)%.o: %.c prepare FORCE
 	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
@@ -847,7 +851,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
 		$(OUTPUT)$(kcmp_type_array) \
 		$(OUTPUT)$(vhost_virtio_ioctl_array) \
 		$(OUTPUT)$(perf_ioctl_array) \
-		$(OUTPUT)$(prctl_option_array)
+		$(OUTPUT)$(prctl_option_array) \
+		$(OUTPUT)util/errno-names.c
 	$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
 
 #
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 7c6a8b4..6d4f8f0 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -5,6 +5,7 @@ libperf-y += config.o
 libperf-y += ctype.o
 libperf-y += db-export.o
 libperf-y += env.o
+libperf-y += errno-names.o
 libperf-y += event.o
 libperf-y += evlist.o
 libperf-y += evsel.o
diff --git a/tools/perf/util/errno-names.h b/tools/perf/util/errno-names.h
new file mode 100644
index 0000000..1cdcbd3
--- /dev/null
+++ b/tools/perf/util/errno-names.h
@@ -0,0 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __PERF_ERRNO_NAMES_H
+#define __PERF_ERRNO_NAMES_H
+
+const char *arch_errno_to_name(const char *arch, int err);
+
+#endif /* __PERF_ERRNO_NAMES_H */
diff --git a/tools/perf/util/generate-errno-names.sh b/tools/perf/util/generate-errno-names.sh
new file mode 100755
index 0000000..1738800
--- /dev/null
+++ b/tools/perf/util/generate-errno-names.sh
@@ -0,0 +1,101 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Generate C file mapping errno codes to errno names.
+#
+# Copyright IBM Corp. 2018
+# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
+
+gcc="$1"
+toolsdir="$2"
+include_path="-I$toolsdir/include/uapi"
+
+arch_string()
+{
+	echo "$1" |sed -e 'y/- /__/' |tr '[[:upper:]]' '[[:lower:]]'
+}
+
+asm_errno_file()
+{
+	local arch="$1"
+	local header
+
+	header="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
+	if test -r "$header"; then
+		echo "$header"
+	else
+		echo "$toolsdir/include/uapi/asm-generic/errno.h"
+	fi
+}
+
+create_errno_lookup_func()
+{
+	local arch=$(arch_string "$1")
+	local nr name
+
+	cat <<EoFuncBegin
+static const char *errno_to_name__$arch(int err)
+{
+	switch (err) {
+EoFuncBegin
+
+	while read name nr; do
+		printf '\tcase %d: return "%s";\n' $nr $name
+	done
+
+	cat <<EoFuncEnd
+	default:
+		return "(unknown)";
+	}
+}
+
+EoFuncEnd
+}
+
+process_arch()
+{
+	local arch="$1"
+	local asm_errno=$(asm_errno_file "$arch")
+
+	$gcc $include_path -E -dM -x c $asm_errno \
+		|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
+		|awk '{ print $2","$3; }' \
+		|sort -t, -k2 -nu \
+		|IFS=, create_errno_lookup_func "$arch"
+}
+
+create_arch_errno_table_func()
+{
+	local archlist="$1"
+	local default="$2"
+	local arch
+
+	printf 'const char *arch_errno_to_name(const char *arch, int err)\n'
+	printf '{\n'
+	for arch in $archlist; do
+		printf '\tif (!strcmp(arch, "%s"))\n' $(arch_string "$arch")
+		printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
+	done
+	printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
+	printf '}'
+}
+
+cat <<EoHEADER
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <string.h>
+#include "errno-names.h"
+
+EoHEADER
+
+# Create list of architectures and ignore those that do not appear
+# in tools/perf/arch
+archlist=""
+for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" |sort); do
+	test -d arch/$arch && archlist="$archlist $arch"
+done
+
+for arch in $archlist generic; do
+	process_arch "$arch"
+done
+create_arch_errno_table_func "$archlist" "generic"
-- 
1.8.3.1

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

* [PATCH 4/5] perf trace: Obtain errno values by using arch_errno_to_name()
  2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
                   ` (2 preceding siblings ...)
  2018-01-16  9:46 ` [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping Hendrik Brueckner
@ 2018-01-16  9:46 ` Hendrik Brueckner
  2018-01-16  9:46 ` [PATCH 5/5] perf trace: Remove audit-libs dependency if syscall tables are present Hendrik Brueckner
  4 siblings, 0 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

Replace the errno_to_name() from the audit-libs with the newly
introduced arch_errno_to_name() function.

With this change:

1.  With replacing errno_to_name() from audit-libs, perf trace
    does no longer require audit-lib interfaces.

2. In addition to 1, the audit-libs dependency can be removed
   for architectures that support syscall tables in perf.
   This is achieved in a follow-up commit.

3. With the architecture specific errno number/name mapping,
   perf trace reports can work across architectures.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/builtin-trace.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index 0362974..f7a57b6 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -21,6 +21,7 @@
 #include "builtin.h"
 #include "util/color.h"
 #include "util/debug.h"
+#include "util/env.h"
 #include "util/event.h"
 #include "util/evlist.h"
 #include <subcmd/exec-cmd.h>
@@ -42,17 +43,16 @@
 #include "string2.h"
 #include "syscalltbl.h"
 #include "rb_resort.h"
+#include "util/errno-names.h"
 
 #include <errno.h>
 #include <inttypes.h>
-#include <libaudit.h> /* FIXME: Still needed for audit_errno_to_name */
 #include <poll.h>
 #include <signal.h>
 #include <stdlib.h>
 #include <string.h>
 #include <linux/err.h>
 #include <linux/filter.h>
-#include <linux/audit.h>
 #include <linux/kernel.h>
 #include <linux/random.h>
 #include <linux/stringify.h>
@@ -1660,6 +1660,14 @@ static int trace__fprintf_callchain(struct trace *trace, struct perf_sample *sam
 	return sample__fprintf_callchain(sample, 38, print_opts, &callchain_cursor, trace->output);
 }
 
+static const char *errno_to_name(struct perf_evsel *evsel, int err)
+{
+	struct perf_env *env = perf_evsel__env(evsel);
+	const char *arch_name = perf_env__arch(env);
+
+	return arch_errno_to_name(arch_name, err);
+}
+
 static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
 			   union perf_event *event __maybe_unused,
 			   struct perf_sample *sample)
@@ -1730,7 +1738,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
 errno_print: {
 		char bf[STRERR_BUFSIZE];
 		const char *emsg = str_error_r(-ret, bf, sizeof(bf)),
-			   *e = audit_errno_to_name(-ret);
+			   *e = errno_to_name(evsel, -ret);
 
 		fprintf(trace->output, ") = -1 %s %s", e, emsg);
 	}
-- 
1.8.3.1

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

* [PATCH 5/5] perf trace: Remove audit-libs dependency if syscall tables are present
  2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
                   ` (3 preceding siblings ...)
  2018-01-16  9:46 ` [PATCH 4/5] perf trace: Obtain errno values by using arch_errno_to_name() Hendrik Brueckner
@ 2018-01-16  9:46 ` Hendrik Brueckner
  4 siblings, 0 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-16  9:46 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

Change the Makefile and build process to no longer require audit-libs
interfaces when the architecture provides system call tables.

Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
---
 tools/perf/Makefile.config          | 10 ++++++++--
 tools/perf/builtin-help.c           |  2 +-
 tools/perf/perf.c                   |  4 ++--
 tools/perf/util/generate-cmdlist.sh |  2 +-
 4 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 90ce14f..8ba416c 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -533,8 +533,14 @@ endif
 
 ifndef NO_LIBAUDIT
   ifneq ($(feature-libaudit), 1)
-    msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
-    NO_LIBAUDIT := 1
+    ifeq ($(NO_SYSCALL_TABLE), 1)
+      msg := $(warning No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev);
+      NO_LIBAUDIT := 1
+    else
+      # With syscall table support, auditlibs are no longer required to build
+      # the trace tool.
+      $(call detected,CONFIG_AUDIT)
+    endif
   else
     CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
     EXTLIBS += -laudit
diff --git a/tools/perf/builtin-help.c b/tools/perf/builtin-help.c
index a0f7ed2..4aca13f 100644
--- a/tools/perf/builtin-help.c
+++ b/tools/perf/builtin-help.c
@@ -439,7 +439,7 @@ int cmd_help(int argc, const char **argv)
 #ifdef HAVE_LIBELF_SUPPORT
 		"probe",
 #endif
-#ifdef HAVE_LIBAUDIT_SUPPORT
+#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE)
 		"trace",
 #endif
 	NULL };
diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 62b1351..1b3fc8e 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -73,7 +73,7 @@ struct cmd_struct {
 	{ "lock",	cmd_lock,	0 },
 	{ "kvm",	cmd_kvm,	0 },
 	{ "test",	cmd_test,	0 },
-#ifdef HAVE_LIBAUDIT_SUPPORT
+#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE)
 	{ "trace",	cmd_trace,	0 },
 #endif
 	{ "inject",	cmd_inject,	0 },
@@ -485,7 +485,7 @@ int main(int argc, const char **argv)
 		argv[0] = cmd;
 	}
 	if (strstarts(cmd, "trace")) {
-#ifdef HAVE_LIBAUDIT_SUPPORT
+#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE)
 		setup_path();
 		argv[0] = "trace";
 		return cmd_trace(argc, argv);
diff --git a/tools/perf/util/generate-cmdlist.sh b/tools/perf/util/generate-cmdlist.sh
index 9bbcec4..ff17920 100755
--- a/tools/perf/util/generate-cmdlist.sh
+++ b/tools/perf/util/generate-cmdlist.sh
@@ -38,7 +38,7 @@ do
 done
 echo "#endif /* HAVE_LIBELF_SUPPORT */"
 
-echo "#ifdef HAVE_LIBAUDIT_SUPPORT"
+echo "#if defined(HAVE_LIBAUDIT_SUPPORT) || defined(HAVE_SYSCALL_TABLE)"
 sed -n -e 's/^perf-\([^ 	]*\)[ 	].* audit*/\1/p' command-list.txt |
 sort |
 while read cmd
-- 
1.8.3.1

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-16  9:46 ` [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping Hendrik Brueckner
@ 2018-01-16 13:58   ` Arnaldo Carvalho de Melo
  2018-01-17  8:49     ` Hendrik Brueckner
  2018-01-18 10:07   ` Jiri Olsa
  1 sibling, 1 reply; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-01-16 13:58 UTC (permalink / raw)
  To: Hendrik Brueckner
  Cc: Thomas-Mich Richter, Michael Petlan, Jiri Olsa, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

Em Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner escreveu:
> Introduce a script that generates a mapping of errno numbers to
> their names for each architecture that is supported by perf (i.e.
> has a subdirectory in tools/perf/arch/).
> 
> The file is generated as util/errno-names.c.  A corresponding
> header file util/errno-names.h is provided that defines the
> arch_errno_to_name() function.  Use arch_errno_to_name() to
> lookup an errno value to obtain the errno name (e.g. ENOENT)
> for a particular architecture.
> 
> This is to be used by perf trace.

Ok, this is almost there, one nit I think needs to be fixed, instead of
generating it on $(OUTPUT)util/errno-names.c we can generate it here:

[acme@jouet perf]$ ls -la /tmp/build/perf/trace/beauty/generated
total 16
drwxrwxr-x. 3 acme acme  140 Jan 16 10:23 .
drwxrwxr-x. 3 acme acme  380 Jan 16 10:23 ..
drwxrwxr-x. 2 acme acme  160 Jan 16 10:23 ioctl
-rw-rw-r--. 1 acme acme  235 Jan 16 10:23 kcmp_type_array.c
-rw-rw-r--. 1 acme acme  421 Jan 16 10:23 madvise_behavior_array.c
-rw-rw-r--. 1 acme acme  152 Jan 16 10:23 pkey_alloc_access_rights_array.c
-rw-rw-r--. 1 acme acme 1222 Jan 16 10:23 prctl_option_array.c
[acme@jouet perf]$ 
[acme@jouet perf]$ ls -la /tmp/build/perf/trace/beauty/generated/ioctl/
total 28
drwxrwxr-x. 2 acme acme  160 Jan 16 10:23 .
drwxrwxr-x. 3 acme acme  140 Jan 16 10:23 ..
-rw-rw-r--. 1 acme acme 5440 Jan 16 10:23 drm_ioctl_array.c
-rw-rw-r--. 1 acme acme 2269 Jan 16 10:23 kvm_ioctl_array.c
-rw-rw-r--. 1 acme acme  226 Jan 16 10:23 perf_ioctl_array.c
-rw-rw-r--. 1 acme acme  689 Jan 16 10:23 sndrv_ctl_ioctl_array.c
-rw-rw-r--. 1 acme acme  716 Jan 16 10:23 sndrv_pcm_ioctl_array.c
-rw-rw-r--. 1 acme acme  883 Jan 16 10:23 vhost_virtio_ioctl_array.c
[acme@jouet perf]$ 

I.e. all these are beautifier routines generated by shell scripts from
kernel header copies, so I think this new one, for errno, belongs there,
ok?

tools/perf/Makefile.perf is where this is being done, arguably with a
lot of cut'n'paste boilerplate that has to get cleaned up at some point
:-\

What do you think?

- Arnaldo
 
> Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
> Reviewed-by: Thomas Richter <tmricht@linux.vnet.ibm.com>
> Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
> Cc: Jiri Olsa <jolsa@redhat.com>
> ---
>  tools/perf/.gitignore                   |   1 +
>  tools/perf/Makefile.config              |   2 +-
>  tools/perf/Makefile.perf                |   9 ++-
>  tools/perf/util/Build                   |   1 +
>  tools/perf/util/errno-names.h           |   7 +++
>  tools/perf/util/generate-errno-names.sh | 101 ++++++++++++++++++++++++++++++++
>  6 files changed, 118 insertions(+), 3 deletions(-)
>  create mode 100644 tools/perf/util/errno-names.h
>  create mode 100755 tools/perf/util/generate-errno-names.sh
> 
> diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
> index 643cc4ba..1d4d43c 100644
> --- a/tools/perf/.gitignore
> +++ b/tools/perf/.gitignore
> @@ -14,6 +14,7 @@ perf*.1
>  perf*.xml
>  perf*.html
>  common-cmds.h
> +errno-names.c
>  perf.data
>  perf.data.old
>  output.svg
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 12dec6e..90ce14f 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
>  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
>  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
>  
> -# $(obj-perf)      for generated common-cmds.h
> +# $(obj-perf)      for generated common-cmds.h and errno-names.c
>  # $(obj-perf)/util for generated bison/flex headers
>  ifneq ($(OUTPUT),)
>  INC_FLAGS += -I$(obj-perf)/util
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 9fdefd7..332b4b4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
>  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
>  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
>  
> +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
> +
>  $(SCRIPTS) : % : %.sh
>  	$(QUIET_GEN)$(INSTALL) '$@.sh' '$(OUTPUT)$@'
>  
> @@ -565,7 +568,8 @@ prepare: $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)common-cmds.h archheaders $(drm_ioc
>  	$(vhost_virtio_ioctl_array) \
>  	$(madvise_behavior_array) \
>  	$(perf_ioctl_array) \
> -	$(prctl_option_array)
> +	$(prctl_option_array) \
> +	$(OUTPUT)util/errno-names.c
>  
>  $(OUTPUT)%.o: %.c prepare FORCE
>  	$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
> @@ -847,7 +851,8 @@ clean:: $(LIBTRACEEVENT)-clean $(LIBAPI)-clean $(LIBBPF)-clean $(LIBSUBCMD)-clea
>  		$(OUTPUT)$(kcmp_type_array) \
>  		$(OUTPUT)$(vhost_virtio_ioctl_array) \
>  		$(OUTPUT)$(perf_ioctl_array) \
> -		$(OUTPUT)$(prctl_option_array)
> +		$(OUTPUT)$(prctl_option_array) \
> +		$(OUTPUT)util/errno-names.c
>  	$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
>  
>  #
> diff --git a/tools/perf/util/Build b/tools/perf/util/Build
> index 7c6a8b4..6d4f8f0 100644
> --- a/tools/perf/util/Build
> +++ b/tools/perf/util/Build
> @@ -5,6 +5,7 @@ libperf-y += config.o
>  libperf-y += ctype.o
>  libperf-y += db-export.o
>  libperf-y += env.o
> +libperf-y += errno-names.o
>  libperf-y += event.o
>  libperf-y += evlist.o
>  libperf-y += evsel.o
> diff --git a/tools/perf/util/errno-names.h b/tools/perf/util/errno-names.h
> new file mode 100644
> index 0000000..1cdcbd3
> --- /dev/null
> +++ b/tools/perf/util/errno-names.h
> @@ -0,0 +1,7 @@
> +/* SPDX-License-Identifier: GPL-2.0 */
> +#ifndef __PERF_ERRNO_NAMES_H
> +#define __PERF_ERRNO_NAMES_H
> +
> +const char *arch_errno_to_name(const char *arch, int err);
> +
> +#endif /* __PERF_ERRNO_NAMES_H */
> diff --git a/tools/perf/util/generate-errno-names.sh b/tools/perf/util/generate-errno-names.sh
> new file mode 100755
> index 0000000..1738800
> --- /dev/null
> +++ b/tools/perf/util/generate-errno-names.sh
> @@ -0,0 +1,101 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate C file mapping errno codes to errno names.
> +#
> +# Copyright IBM Corp. 2018
> +# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
> +
> +gcc="$1"
> +toolsdir="$2"
> +include_path="-I$toolsdir/include/uapi"
> +
> +arch_string()
> +{
> +	echo "$1" |sed -e 'y/- /__/' |tr '[[:upper:]]' '[[:lower:]]'
> +}
> +
> +asm_errno_file()
> +{
> +	local arch="$1"
> +	local header
> +
> +	header="$toolsdir/arch/$arch/include/uapi/asm/errno.h"
> +	if test -r "$header"; then
> +		echo "$header"
> +	else
> +		echo "$toolsdir/include/uapi/asm-generic/errno.h"
> +	fi
> +}
> +
> +create_errno_lookup_func()
> +{
> +	local arch=$(arch_string "$1")
> +	local nr name
> +
> +	cat <<EoFuncBegin
> +static const char *errno_to_name__$arch(int err)
> +{
> +	switch (err) {
> +EoFuncBegin
> +
> +	while read name nr; do
> +		printf '\tcase %d: return "%s";\n' $nr $name
> +	done
> +
> +	cat <<EoFuncEnd
> +	default:
> +		return "(unknown)";
> +	}
> +}
> +
> +EoFuncEnd
> +}
> +
> +process_arch()
> +{
> +	local arch="$1"
> +	local asm_errno=$(asm_errno_file "$arch")
> +
> +	$gcc $include_path -E -dM -x c $asm_errno \
> +		|grep -hE '^#define[[:blank:]]+(E[^[:blank:]]+)[[:blank:]]+([[:digit:]]+).*' \
> +		|awk '{ print $2","$3; }' \
> +		|sort -t, -k2 -nu \
> +		|IFS=, create_errno_lookup_func "$arch"
> +}
> +
> +create_arch_errno_table_func()
> +{
> +	local archlist="$1"
> +	local default="$2"
> +	local arch
> +
> +	printf 'const char *arch_errno_to_name(const char *arch, int err)\n'
> +	printf '{\n'
> +	for arch in $archlist; do
> +		printf '\tif (!strcmp(arch, "%s"))\n' $(arch_string "$arch")
> +		printf '\t\treturn errno_to_name__%s(err);\n' $(arch_string "$arch")
> +	done
> +	printf '\treturn errno_to_name__%s(err);\n' $(arch_string "$default")
> +	printf '}'
> +}
> +
> +cat <<EoHEADER
> +/* SPDX-License-Identifier: GPL-2.0 */
> +
> +#include <string.h>
> +#include "errno-names.h"
> +
> +EoHEADER
> +
> +# Create list of architectures and ignore those that do not appear
> +# in tools/perf/arch
> +archlist=""
> +for arch in $(find $toolsdir/arch -maxdepth 1 -mindepth 1 -type d -printf "%f\n" |sort); do
> +	test -d arch/$arch && archlist="$archlist $arch"
> +done
> +
> +for arch in $archlist generic; do
> +	process_arch "$arch"
> +done
> +create_arch_errno_table_func "$archlist" "generic"
> -- 
> 1.8.3.1

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-16 13:58   ` Arnaldo Carvalho de Melo
@ 2018-01-17  8:49     ` Hendrik Brueckner
  0 siblings, 0 replies; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-17  8:49 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Hendrik Brueckner, Thomas-Mich Richter, Michael Petlan,
	Jiri Olsa, linux-perf-users, linux-s390,
	Arnaldo Carvalho de Melo

On Tue, Jan 16, 2018 at 10:58:48AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner escreveu:
> > Introduce a script that generates a mapping of errno numbers to
> > their names for each architecture that is supported by perf (i.e.
> > has a subdirectory in tools/perf/arch/).
> > 
> > The file is generated as util/errno-names.c.  A corresponding
> > header file util/errno-names.h is provided that defines the
> > arch_errno_to_name() function.  Use arch_errno_to_name() to
> > lookup an errno value to obtain the errno name (e.g. ENOENT)
> > for a particular architecture.
> > 
> > This is to be used by perf trace.
> 
> Ok, this is almost there, one nit I think needs to be fixed, instead of
> generating it on $(OUTPUT)util/errno-names.c we can generate it here:
> 
[...]
> 
> I.e. all these are beautifier routines generated by shell scripts from
> kernel header copies, so I think this new one, for errno, belongs there,
> ok?

At the moment, just perf trace use this interface. Hence, putting it to
the trace beautifiers makes sense.  Will update the patch accordingly and
re-post a v2 of the patch again.

Additional feedback is welcome... so I can decide whether to post the
single patch or an updated series.


Thanks and kind regards,
  Hendrik

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-16  9:46 ` [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping Hendrik Brueckner
  2018-01-16 13:58   ` Arnaldo Carvalho de Melo
@ 2018-01-18 10:07   ` Jiri Olsa
  2018-01-18 10:49     ` Arnaldo Carvalho de Melo
  1 sibling, 1 reply; 13+ messages in thread
From: Jiri Olsa @ 2018-01-18 10:07 UTC (permalink / raw)
  To: Hendrik Brueckner
  Cc: Arnaldo Carvalho de Melo, Thomas-Mich Richter, Michael Petlan,
	linux-perf-users, linux-s390, Arnaldo Carvalho de Melo

On Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner wrote:

SNIP

> index 12dec6e..90ce14f 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
>  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
>  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
>  
> -# $(obj-perf)      for generated common-cmds.h
> +# $(obj-perf)      for generated common-cmds.h and errno-names.c
>  # $(obj-perf)/util for generated bison/flex headers
>  ifneq ($(OUTPUT),)
>  INC_FLAGS += -I$(obj-perf)/util
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 9fdefd7..332b4b4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
>  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
>  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
>  
> +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@

so this generates errno-names.c with following code:

const char *arch_errno_to_name(const char *arch, int err)
{
        if (!strcmp(arch, "alpha"))
                return errno_to_name__alpha(err);
        if (!strcmp(arch, "arm"))
                return errno_to_name__arm(err);
        if (!strcmp(arch, "arm64"))
                return errno_to_name__arm64(err);


is there a reason why we want all archs compiled in?
I'd think we just need the arch perf is built in

thanks,
jirka

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-18 10:07   ` Jiri Olsa
@ 2018-01-18 10:49     ` Arnaldo Carvalho de Melo
  2018-01-18 11:33       ` Hendrik Brueckner
  2018-01-18 12:19       ` Jiri Olsa
  0 siblings, 2 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-01-18 10:49 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Hendrik Brueckner, Thomas-Mich Richter, Michael Petlan,
	linux-perf-users, linux-s390, Arnaldo Carvalho de Melo

Em Thu, Jan 18, 2018 at 11:07:33AM +0100, Jiri Olsa escreveu:
> On Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner wrote:
> 
> SNIP
> 
> > index 12dec6e..90ce14f 100644
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
> >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
> >  
> > -# $(obj-perf)      for generated common-cmds.h
> > +# $(obj-perf)      for generated common-cmds.h and errno-names.c
> >  # $(obj-perf)/util for generated bison/flex headers
> >  ifneq ($(OUTPUT),)
> >  INC_FLAGS += -I$(obj-perf)/util
> > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > index 9fdefd7..332b4b4 100644
> > --- a/tools/perf/Makefile.perf
> > +++ b/tools/perf/Makefile.perf
> > @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> >  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> >  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> >  
> > +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> > +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
> 
> so this generates errno-names.c with following code:
> 
> const char *arch_errno_to_name(const char *arch, int err)
> {
>         if (!strcmp(arch, "alpha"))
>                 return errno_to_name__alpha(err);
>         if (!strcmp(arch, "arm"))
>                 return errno_to_name__arm(err);
>         if (!strcmp(arch, "arm64"))
>                 return errno_to_name__arm64(err);
> 
> 
> is there a reason why we want all archs compiled in?
> I'd think we just need the arch perf is built in

think about:

On an arm64 system:

	perf trace record -a sleep 1

scp that to an x86_64 system and do:

	perf trace -i perf.data

But doing that strcmp per call seems excessive, perhaps we could have
something like:

	trace->arch = arch_syscalls__init(arch_name);

	char *s = arch_syscalls__strerrno(trace->arch, err);

Have to look at the code to find the right naming according to what we
already have.

- Arnaldo
- Arnaldo

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-18 10:49     ` Arnaldo Carvalho de Melo
@ 2018-01-18 11:33       ` Hendrik Brueckner
  2018-01-18 14:11         ` Arnaldo Carvalho de Melo
  2018-01-18 12:19       ` Jiri Olsa
  1 sibling, 1 reply; 13+ messages in thread
From: Hendrik Brueckner @ 2018-01-18 11:33 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Jiri Olsa, Hendrik Brueckner, Thomas-Mich Richter,
	Michael Petlan, linux-perf-users, linux-s390,
	Arnaldo Carvalho de Melo

On Thu, Jan 18, 2018 at 07:49:53AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jan 18, 2018 at 11:07:33AM +0100, Jiri Olsa escreveu:
> > On Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner wrote:
> > 
> > SNIP
> > 
> > > index 12dec6e..90ce14f 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
> > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
> > >  
> > > -# $(obj-perf)      for generated common-cmds.h
> > > +# $(obj-perf)      for generated common-cmds.h and errno-names.c
> > >  # $(obj-perf)/util for generated bison/flex headers
> > >  ifneq ($(OUTPUT),)
> > >  INC_FLAGS += -I$(obj-perf)/util
> > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > > index 9fdefd7..332b4b4 100644
> > > --- a/tools/perf/Makefile.perf
> > > +++ b/tools/perf/Makefile.perf
> > > @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> > >  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> > >  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> > >  
> > > +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> > > +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
> > 
> > so this generates errno-names.c with following code:
> > 
> > const char *arch_errno_to_name(const char *arch, int err)
> > {
> >         if (!strcmp(arch, "alpha"))
> >                 return errno_to_name__alpha(err);
> >         if (!strcmp(arch, "arm"))
> >                 return errno_to_name__arm(err);
> >         if (!strcmp(arch, "arm64"))
> >                 return errno_to_name__arm64(err);
> > 
> > 
> > is there a reason why we want all archs compiled in?
> > I'd think we just need the arch perf is built in
> 
> think about:
> 
> On an arm64 system:
> 
> 	perf trace record -a sleep 1
> 
> scp that to an x86_64 system and do:
> 
> 	perf trace -i perf.data
> 
> But doing that strcmp per call seems excessive, perhaps we could have
> something like:
> 
> 	trace->arch = arch_syscalls__init(arch_name);
> 
> 	char *s = arch_syscalls__strerrno(trace->arch, err);
> 
> Have to look at the code to find the right naming according to what we
> already have.

Another idea to get rid of the strcmp's is to introduce an arch enum
and let normalize_arch() in util/env.c return an enum number and handle
the arch stuff then on the enum.  Where necessary, the arch string can
be used.  But for "internal" purposes, an enum would be better.

Thanks and kind regards,
  Hendrik

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-18 10:49     ` Arnaldo Carvalho de Melo
  2018-01-18 11:33       ` Hendrik Brueckner
@ 2018-01-18 12:19       ` Jiri Olsa
  1 sibling, 0 replies; 13+ messages in thread
From: Jiri Olsa @ 2018-01-18 12:19 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Hendrik Brueckner, Thomas-Mich Richter, Michael Petlan,
	linux-perf-users, linux-s390, Arnaldo Carvalho de Melo

On Thu, Jan 18, 2018 at 07:49:53AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Jan 18, 2018 at 11:07:33AM +0100, Jiri Olsa escreveu:
> > On Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner wrote:
> > 
> > SNIP
> > 
> > > index 12dec6e..90ce14f 100644
> > > --- a/tools/perf/Makefile.config
> > > +++ b/tools/perf/Makefile.config
> > > @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
> > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
> > >  
> > > -# $(obj-perf)      for generated common-cmds.h
> > > +# $(obj-perf)      for generated common-cmds.h and errno-names.c
> > >  # $(obj-perf)/util for generated bison/flex headers
> > >  ifneq ($(OUTPUT),)
> > >  INC_FLAGS += -I$(obj-perf)/util
> > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > > index 9fdefd7..332b4b4 100644
> > > --- a/tools/perf/Makefile.perf
> > > +++ b/tools/perf/Makefile.perf
> > > @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> > >  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> > >  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> > >  
> > > +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> > > +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
> > 
> > so this generates errno-names.c with following code:
> > 
> > const char *arch_errno_to_name(const char *arch, int err)
> > {
> >         if (!strcmp(arch, "alpha"))
> >                 return errno_to_name__alpha(err);
> >         if (!strcmp(arch, "arm"))
> >                 return errno_to_name__arm(err);
> >         if (!strcmp(arch, "arm64"))
> >                 return errno_to_name__arm64(err);
> > 
> > 
> > is there a reason why we want all archs compiled in?
> > I'd think we just need the arch perf is built in
> 
> think about:
> 
> On an arm64 system:
> 
> 	perf trace record -a sleep 1

oops, forgot we can store in perf trace.. ok then ;-)

thanks,
jirka

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

* Re: [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping
  2018-01-18 11:33       ` Hendrik Brueckner
@ 2018-01-18 14:11         ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 13+ messages in thread
From: Arnaldo Carvalho de Melo @ 2018-01-18 14:11 UTC (permalink / raw)
  To: Hendrik Brueckner
  Cc: Jiri Olsa, Thomas-Mich Richter, Michael Petlan, linux-perf-users,
	linux-s390, Arnaldo Carvalho de Melo

Em Thu, Jan 18, 2018 at 12:33:20PM +0100, Hendrik Brueckner escreveu:
> On Thu, Jan 18, 2018 at 07:49:53AM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, Jan 18, 2018 at 11:07:33AM +0100, Jiri Olsa escreveu:
> > > On Tue, Jan 16, 2018 at 10:46:29AM +0100, Hendrik Brueckner wrote:
> > > 
> > > SNIP
> > > 
> > > > index 12dec6e..90ce14f 100644
> > > > --- a/tools/perf/Makefile.config
> > > > +++ b/tools/perf/Makefile.config
> > > > @@ -249,7 +249,7 @@ INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/uapi
> > > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/include/
> > > >  INC_FLAGS += -I$(srctree)/tools/arch/$(SRCARCH)/
> > > >  
> > > > -# $(obj-perf)      for generated common-cmds.h
> > > > +# $(obj-perf)      for generated common-cmds.h and errno-names.c
> > > >  # $(obj-perf)/util for generated bison/flex headers
> > > >  ifneq ($(OUTPUT),)
> > > >  INC_FLAGS += -I$(obj-perf)/util
> > > > diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> > > > index 9fdefd7..332b4b4 100644
> > > > --- a/tools/perf/Makefile.perf
> > > > +++ b/tools/perf/Makefile.perf
> > > > @@ -518,6 +518,9 @@ $(OUTPUT)common-cmds.h: util/generate-cmdlist.sh command-list.txt
> > > >  $(OUTPUT)common-cmds.h: $(wildcard Documentation/perf-*.txt)
> > > >  	$(QUIET_GEN). util/generate-cmdlist.sh > $@+ && mv $@+ $@
> > > >  
> > > > +$(OUTPUT)util/errno-names.c: util/generate-errno-names.sh
> > > > +	$(QUIET_GEN). util/generate-errno-names.sh "$(CC)" "$(srctree)/tools" > $@+ && mv $@+ $@
> > > 
> > > so this generates errno-names.c with following code:
> > > 
> > > const char *arch_errno_to_name(const char *arch, int err)
> > > {
> > >         if (!strcmp(arch, "alpha"))
> > >                 return errno_to_name__alpha(err);
> > >         if (!strcmp(arch, "arm"))
> > >                 return errno_to_name__arm(err);
> > >         if (!strcmp(arch, "arm64"))
> > >                 return errno_to_name__arm64(err);
> > > 
> > > 
> > > is there a reason why we want all archs compiled in?
> > > I'd think we just need the arch perf is built in
> > 
> > think about:
> > 
> > On an arm64 system:
> > 
> > 	perf trace record -a sleep 1
> > 
> > scp that to an x86_64 system and do:
> > 
> > 	perf trace -i perf.data
> > 
> > But doing that strcmp per call seems excessive, perhaps we could have
> > something like:
> > 
> > 	trace->arch = arch_syscalls__init(arch_name);
> > 
> > 	char *s = arch_syscalls__strerrno(trace->arch, err);
> > 
> > Have to look at the code to find the right naming according to what we
> > already have.
> 
> Another idea to get rid of the strcmp's is to introduce an arch enum
> and let normalize_arch() in util/env.c return an enum number and handle
> the arch stuff then on the enum.  Where necessary, the arch string can
> be used.  But for "internal" purposes, an enum would be better.

Right, we can go on improving things, but I think that after you get the
generated directory sorted out I'll apply your patches in the current
form, and then we can go on improving things from there, ok?

- Arnaldo

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

end of thread, other threads:[~2018-01-18 14:11 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16  9:46 [PATCH 0/5] perf trace: Introduce arch-specific errno code/name mappings Hendrik Brueckner
2018-01-16  9:46 ` [PATCH 1/5] tools include arch: Grab a copy of errno.h for arch's supported by perf Hendrik Brueckner
2018-01-16  9:46 ` [PATCH 2/5] tools include asm-generic: Grab errno.h and errno-base.h Hendrik Brueckner
2018-01-16  9:46 ` [PATCH 3/5] perf util: Introduce architecture specific errno/name mapping Hendrik Brueckner
2018-01-16 13:58   ` Arnaldo Carvalho de Melo
2018-01-17  8:49     ` Hendrik Brueckner
2018-01-18 10:07   ` Jiri Olsa
2018-01-18 10:49     ` Arnaldo Carvalho de Melo
2018-01-18 11:33       ` Hendrik Brueckner
2018-01-18 14:11         ` Arnaldo Carvalho de Melo
2018-01-18 12:19       ` Jiri Olsa
2018-01-16  9:46 ` [PATCH 4/5] perf trace: Obtain errno values by using arch_errno_to_name() Hendrik Brueckner
2018-01-16  9:46 ` [PATCH 5/5] perf trace: Remove audit-libs dependency if syscall tables are present Hendrik Brueckner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.