Re: [PATCH] pert/report: Support s390 diag event display on x86

2019-05-21 Thread Hendrik Brueckner
On Mon, May 20, 2019 at 04:42:42PM +0200, Thomas Richter wrote:
> Perf report fails to display s390 specific event numbered bd000
> on an x86 platform. For example on s390 this works without error:
> 
> [root@m35lp76 perf]# uname -m
> s390x
> [root@m35lp76 perf]# ./perf record -e rbd000 -- find / >/dev/null
> [ perf record: Woken up 3 times to write data ]
> [ perf record: Captured and wrote 0.549 MB perf.data ]
> [root@m35lp76 perf]# ./perf report -D --stdio  > /dev/null
> [root@m35lp76 perf]#
> 
> Transfering this perf.data file to an x86 platform and executing
> the same report command produces:
> 
> [root@f29 perf]# uname -m
> x86_64
> [root@f29 perf]# ./perf report -i ~/perf.data.m35lp76 --stdio
> interpreting bpf_prog_info from systems with endianity is not yet supported
> interpreting btf from systems with endianity is not yet supported
> 0x8c890 [0x8]: failed to process type: 68
> Error:
> failed to process sample
> 
> Event bd000 generates auxiliary data which is stored in big endian
> format in the perf data file.
> This error is caused by missing endianess handling on the x86 platform
> when the data is displayed. Fix this by handling s390 auxiliary event
> data depending on the local platform endianness.
> 
> Output after on x86:
> 
> [root@f29 perf]# ./perf report -D -i ~/perf.data.m35lp76 --stdio > /dev/null
> interpreting bpf_prog_info from systems with endianity is not yet supported
> interpreting btf from systems with endianity is not yet supported
> [root@f29 perf]#
> 
> Signed-off-by: Thomas Richter 
> ---
>  tools/perf/util/s390-cpumsf.c | 95 ++++---
>  1 file changed, 77 insertions(+), 18 deletions(-)
> 

Looks sane to me.

Thanks, Thomas.

Reviewed-by: Hendrik Brueckner 



Re: [PATCH] pert/report: Support s390 diag event display on x86

2019-05-21 Thread Hendrik Brueckner
On Mon, May 20, 2019 at 02:03:22PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, May 20, 2019 at 04:42:42PM +0200, Thomas Richter escreveu:
> > Perf report fails to display s390 specific event numbered bd000
> > on an x86 platform. For example on s390 this works without error:
> > 
> > [root@m35lp76 perf]# uname -m
> > s390x
> > [root@m35lp76 perf]# ./perf record -e rbd000 -- find / >/dev/null
> > [ perf record: Woken up 3 times to write data ]
> > [ perf record: Captured and wrote 0.549 MB perf.data ]
> > [root@m35lp76 perf]# ./perf report -D --stdio  > /dev/null
> > [root@m35lp76 perf]#
> > 
> > Transfering this perf.data file to an x86 platform and executing
> > the same report command produces:
> > 
> > [root@f29 perf]# uname -m
> > x86_64
> > [root@f29 perf]# ./perf report -i ~/perf.data.m35lp76 --stdio
> > interpreting bpf_prog_info from systems with endianity is not yet supported
> > interpreting btf from systems with endianity is not yet supported
> > 0x8c890 [0x8]: failed to process type: 68
> > Error:
> > failed to process sample
> > 
> > Event bd000 generates auxiliary data which is stored in big endian
> > format in the perf data file.
> > This error is caused by missing endianess handling on the x86 platform
> > when the data is displayed. Fix this by handling s390 auxiliary event
> > data depending on the local platform endianness.
> > 
> > Output after on x86:
> > 
> > [root@f29 perf]# ./perf report -D -i ~/perf.data.m35lp76 --stdio > /dev/null
> > interpreting bpf_prog_info from systems with endianity is not yet supported
> > interpreting btf from systems with endianity is not yet supported
> > [root@f29 perf]#
> > 
> > Signed-off-by: Thomas Richter 
> > ---
> >  tools/perf/util/s390-cpumsf.c | 95 ---
> >  1 file changed, 77 insertions(+), 18 deletions(-)
> > 
> > diff --git a/tools/perf/util/s390-cpumsf.c b/tools/perf/util/s390-cpumsf.c
> > index c215704931dc..884ac79528ff 100644
> > --- a/tools/perf/util/s390-cpumsf.c
> > +++ b/tools/perf/util/s390-cpumsf.c
> > @@ -17,8 +17,8 @@
> >   * see Documentation/perf.data-file-format.txt.
> >   * PERF_RECORD_AUXTRACE_INFO:
> >   * Defines a table of contains for PERF_RECORD_AUXTRACE records. This
> > - * record is generated during 'perf record' command. Each record contains 
> > up
> > - * to 256 entries describing offset and size of the AUXTRACE data in the
> > + * record is generated during 'perf record' command. Each record contains
> > + * up to 256 entries describing offset and size of the AUXTRACE data in the
> 
> What is this for? Just a text reflow?

Look like this is indeed a text reflow to fit into 80 column space.
For me this is OK.  In case you any objections, I think Thomas could
respin the patch and exclude that hunk.

> Also, can you get a Reviewed-by from some other person that works with
> s/390?

Reviewed by me.

Thanks and kind regards,
  Hendrik



Re: [PATCH] perf/report: Report OOM in perf report status line

2019-04-15 Thread Hendrik Brueckner
Thomas,

On Mon, Apr 15, 2019 at 11:46:17AM +0200, Thomas Richter wrote:
[...]

> Signed-off-by: Thomas Richter 
> Reviewed-by: Jiri Olsa 
> ---
>  tools/perf/util/session.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
> index b17f1c9bc965..e89716175588 100644
> --- a/tools/perf/util/session.c
> +++ b/tools/perf/util/session.c
> @@ -1930,10 +1930,10 @@ reader__process_events(struct reader *rd, struct 
> perf_session *session,
> 
>   if (size < sizeof(struct perf_event_header) ||
>   (skip = rd->process(session, event, file_pos)) < 0) {
> - pr_err("%#" PRIx64 " [%#x]: failed to process type: %d\n",
> + pr_err("%#" PRIx64 " [%#x]: failed to process type: %d [%s]\n",
>  file_offset + head, event->header.size,
> -event->header.type);
> - err = -EINVAL;
> +event->header.type, strerror(-skip));
> + err = skip;
>   goto out;
>   }
> 

Thanks for solving this issue.

Reviewed-by: Hendrik Brueckner 



Re: [PATCH 1/3] perf auxtrace: Support for perf report -D for s390

2018-08-03 Thread Hendrik Brueckner
Arnaldo,

On Thu, Aug 02, 2018 at 09:49:09AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 02, 2018 at 09:46:20AM +0200, Thomas Richter escreveu:
> > Add initial support for s390 auxiliary traces using the
> > CPU-Measurement Sampling Facility.
> 
> Could you please provide one or two paragraphs explaining what is this
> "CPU-Measurement Sampling Facility", in which hardware this is available
> (all s/390 hardware has it? Just the 64-bit model(s)?) and provide a
> public URL for people interested in further reading?

The CPU-Measurement Facility (CPU-MF) provides a set of functions to obtain
performance information on the mainframe.  Basically, it was introduced
with System z10 years ago for the z/Architecture, that means, 64-bit.
For Linux, there are two facilities of interest, counter facility and sampling
facility.  The counter facility provides hardware counters for instructions,
cycles, crypto-activities, and many more.

The sampling facility is a hardware sampler that when started will write
samples at a particular interval into a sampling buffer.  At some point,
for example, if a sample block is full, it generates an interrupt to collect
samples (while the sampler continues to run).

Few years ago, I started to provide the a perf PMU to use the counter
and sampling facilities.  Recently, the device driver was updated to also
"export" the sampling buffer into the AUX area.  Thomas now completed the
related perf work to interpret and process these AUX data.

If people are more interested in the sampling facility, they can have a
look into:

- The Load-Program-Parameter and the CPU-Measurement Facilities, SA23-2260-05
  
http://www-01.ibm.com/support/docview.wss?uid=isg26fcd1cc32246f4c8852574ce0044734a

and to learn how-to use it for Linux on Z, have look at chapter 54,
"Using the CPU-measurement facilities" in the:

- Device Drivers, Features, and Commands, SC33-8411-34
  http://public.dhe.ibm.com/software/dw/linux390/docu/l416dd34.pdf


Thanks and kind regards,
  Hendrik



Re: [PATCH 1/3] perf auxtrace: Support for perf report -D for s390

2018-08-03 Thread Hendrik Brueckner
Arnaldo,

On Thu, Aug 02, 2018 at 09:49:09AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, Aug 02, 2018 at 09:46:20AM +0200, Thomas Richter escreveu:
> > Add initial support for s390 auxiliary traces using the
> > CPU-Measurement Sampling Facility.
> 
> Could you please provide one or two paragraphs explaining what is this
> "CPU-Measurement Sampling Facility", in which hardware this is available
> (all s/390 hardware has it? Just the 64-bit model(s)?) and provide a
> public URL for people interested in further reading?

The CPU-Measurement Facility (CPU-MF) provides a set of functions to obtain
performance information on the mainframe.  Basically, it was introduced
with System z10 years ago for the z/Architecture, that means, 64-bit.
For Linux, there are two facilities of interest, counter facility and sampling
facility.  The counter facility provides hardware counters for instructions,
cycles, crypto-activities, and many more.

The sampling facility is a hardware sampler that when started will write
samples at a particular interval into a sampling buffer.  At some point,
for example, if a sample block is full, it generates an interrupt to collect
samples (while the sampler continues to run).

Few years ago, I started to provide the a perf PMU to use the counter
and sampling facilities.  Recently, the device driver was updated to also
"export" the sampling buffer into the AUX area.  Thomas now completed the
related perf work to interpret and process these AUX data.

If people are more interested in the sampling facility, they can have a
look into:

- The Load-Program-Parameter and the CPU-Measurement Facilities, SA23-2260-05
  
http://www-01.ibm.com/support/docview.wss?uid=isg26fcd1cc32246f4c8852574ce0044734a

and to learn how-to use it for Linux on Z, have look at chapter 54,
"Using the CPU-measurement facilities" in the:

- Device Drivers, Features, and Commands, SC33-8411-34
  http://public.dhe.ibm.com/software/dw/linux390/docu/l416dd34.pdf


Thanks and kind regards,
  Hendrik



Re: [PATCH] kconfig: remove EXPERT from CHECKPOINT_RESTORE

2018-07-12 Thread Hendrik Brueckner
On Thu, Jul 12, 2018 at 03:07:33PM +0200, Adrian Reber wrote:
> The CHECKPOINT_RESTORE configuration option was introduced in 2012 and
> combined with EXPERT. CHECKPOINT_RESTORE is already enabled in many
> distribution kernels and also part of the defconfigs of various
> architectures.
> 
> To make it easier for distributions to enable CHECKPOINT_RESTORE this
> removes EXPERT and moves the configuration option out of the EXPERT
> block.
> 
> Signed-off-by: Adrian Reber 
> Cc: Oleg Nesterov 
> Cc: Pavel Emelyanov 
> Cc: Andrew Morton 
> Cc: Eric W. Biederman 
> Cc: Andrei Vagin 
> Cc: Hendrik Brueckner 
> ---
>  init/Kconfig | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/init/Kconfig b/init/Kconfig
> index 041f3a022122..9c529c763326 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -932,6 +932,18 @@ config NET_NS
> 
>  endif # NAMESPACES
> 
> +config CHECKPOINT_RESTORE
> + bool "Checkpoint/restore support"
> + select PROC_CHILDREN
> + default n
> + help
> +   Enables additional kernel features in a sake of checkpoint/restore.
> +   In particular it adds auxiliary prctl codes to setup process text,
> +   data and heap segment sizes, and a few additional /proc filesystem
> +   entries.
> +
> +   If unsure, say N here.
> +
>  config SCHED_AUTOGROUP
>   bool "Automatic process group scheduling"
>   select CGROUPS
> @@ -1348,18 +1360,6 @@ config MEMBARRIER
> 
> If unsure, say Y.
> 
> -config CHECKPOINT_RESTORE
> - bool "Checkpoint/restore support" if EXPERT
> - select PROC_CHILDREN
> - default n
> - help
> -   Enables additional kernel features in a sake of checkpoint/restore.
> -   In particular it adds auxiliary prctl codes to setup process text,
> -   data and heap segment sizes, and a few additional /proc filesystem
> -   entries.
> -
> -   If unsure, say N here.
> -
>  config KALLSYMS
>bool "Load all symbols for debugging/ksymoops" if EXPERT
>default y

Thanks!

Reviewed-by: Hendrik Brueckner 



Re: [PATCH] kconfig: remove EXPERT from CHECKPOINT_RESTORE

2018-07-12 Thread Hendrik Brueckner
On Thu, Jul 12, 2018 at 03:07:33PM +0200, Adrian Reber wrote:
> The CHECKPOINT_RESTORE configuration option was introduced in 2012 and
> combined with EXPERT. CHECKPOINT_RESTORE is already enabled in many
> distribution kernels and also part of the defconfigs of various
> architectures.
> 
> To make it easier for distributions to enable CHECKPOINT_RESTORE this
> removes EXPERT and moves the configuration option out of the EXPERT
> block.
> 
> Signed-off-by: Adrian Reber 
> Cc: Oleg Nesterov 
> Cc: Pavel Emelyanov 
> Cc: Andrew Morton 
> Cc: Eric W. Biederman 
> Cc: Andrei Vagin 
> Cc: Hendrik Brueckner 
> ---
>  init/Kconfig | 24 
>  1 file changed, 12 insertions(+), 12 deletions(-)
> 
> diff --git a/init/Kconfig b/init/Kconfig
> index 041f3a022122..9c529c763326 100644
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -932,6 +932,18 @@ config NET_NS
> 
>  endif # NAMESPACES
> 
> +config CHECKPOINT_RESTORE
> + bool "Checkpoint/restore support"
> + select PROC_CHILDREN
> + default n
> + help
> +   Enables additional kernel features in a sake of checkpoint/restore.
> +   In particular it adds auxiliary prctl codes to setup process text,
> +   data and heap segment sizes, and a few additional /proc filesystem
> +   entries.
> +
> +   If unsure, say N here.
> +
>  config SCHED_AUTOGROUP
>   bool "Automatic process group scheduling"
>   select CGROUPS
> @@ -1348,18 +1360,6 @@ config MEMBARRIER
> 
> If unsure, say Y.
> 
> -config CHECKPOINT_RESTORE
> - bool "Checkpoint/restore support" if EXPERT
> - select PROC_CHILDREN
> - default n
> - help
> -   Enables additional kernel features in a sake of checkpoint/restore.
> -   In particular it adds auxiliary prctl codes to setup process text,
> -   data and heap segment sizes, and a few additional /proc filesystem
> -   entries.
> -
> -   If unsure, say N here.
> -
>  config KALLSYMS
>bool "Load all symbols for debugging/ksymoops" if EXPERT
>default y

Thanks!

Reviewed-by: Hendrik Brueckner 



Re: [PATCH v2 2/3] perf arm64: Generate system call table from asm/unistd.h

2018-07-06 Thread Hendrik Brueckner
Hi Kim,

On Thu, Jul 05, 2018 at 06:12:16PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> Using the existing other arch scripts resulted in this error:
> 
> tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: 
> __NR3264_ftruncate: expected numeric value
> 
> because, unlike other arches, asm-generic's unistd.h does things like:
> 
>  #define __NR_ftruncate __NR3264_ftruncate
> 
> Turning the scripts printf's %d into a %s resulted in this in the
> generated syscalls.c file:
> 
> static const char *syscalltbl_arm64[] = {
> [__NR3264_ftruncate] = "ftruncate",
> 
> So we use the host C compiler to fold the macros, and print them out
> from within a temporary C program, in order to get the correct output:
> 
> static const char *syscalltbl_arm64[] = {
>     [46] = "ftruncate",
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
> Changes in V2:
>  - added the "sc" and "nr" local variables, for the sake of completion 
> (Hendrik
>Brueckner)
>  - Removed the unsafe -u from mktemp, added more X's, and now pipe the
>C code to the $hostcc command, so we now only require a single temp
>file that is written by gcc. (Hendrik Brueckner)
>  - used cat << EoHEADER instead of echos for the c file header, to make it 
> more
>readable (Hendrik Brueckner)
>  - $RM -> rm, to be able to run standalone (Hendrik Brueckner)

Many thanks for incorporating the feedback!

>  - moved the rm into the function that makes the file
>  - converted other echos to printf "%s\n" for more portable printing of
>backslash characters (bash and dash built-in echo commands differ in
>how many escape backslashes are needed).  The initial "%s\n" is needed
>in order to keep the external printf command from interpreting the %ds.
> 
>  tools/perf/arch/arm64/Makefile| 21 +++
>  .../arch/arm64/entry/syscalls/mksyscalltbl| 61 +++
>  2 files changed, 82 insertions(+)
>  create mode 100755 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> 
> diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
> index 91de4860faad..85fdf4949db3 100644
> --- a/tools/perf/arch/arm64/Makefile
> +++ b/tools/perf/arch/arm64/Makefile
> @@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
>  endif
>  PERF_HAVE_JITDUMP := 1
>  PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
> +
> +#
> +# Syscall table generation for perf
> +#
> +
> +out:= $(OUTPUT)arch/arm64/include/generated/asm
> +header := $(out)/syscalls.c
> +sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
> +sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
> +systbl := $(sysprf)/mksyscalltbl
> +
> +# Create output directory if not already present
> +_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
> +
> +$(header): $(sysdef) $(systbl)
> + $(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
> +
> +clean::
> + $(call QUIET_CLEAN, arm64) $(RM) $(header)
> +
> +archheaders: $(header)
> diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl 
> b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> new file mode 100755
> index ..f806542eb3cc
> --- /dev/null
> +++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> @@ -0,0 +1,61 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate system call table for perf. Derived from
> +# powerpc script.
> +#
> +# Copyright IBM Corp. 2017
> +# Author(s):  Hendrik Brueckner 
> +# Changed by: Ravi Bangoria 
> +# Changed by: Kim Phillips 
> +
> +gcc=$1
> +hostcc=$2
> +input=$3
> +
> +if ! test -r $input; then
> + echo "Could not read input file" >&2
> + exit 1
> +fi
> +
> +create_table_from_c()
> +{
> + local sc nr last_sc
> +
> + create_table_exe=`mktemp /tmp/create-table-XX`
> +
> + {
> +
> +cat << _EoHEADER
> +#include 
> +#include "$input"
> +int main(int argc, char *argv[])
> +{
> +_EoHEADER

One minor style hint: Using cat <<-_EoHEADER (with a dash) strips any leading
tabs from the what is being concatenated.  With this, using the same indent as
for as the other function statements it possible.  For example,

cat <<-

Re: [PATCH v2 2/3] perf arm64: Generate system call table from asm/unistd.h

2018-07-06 Thread Hendrik Brueckner
Hi Kim,

On Thu, Jul 05, 2018 at 06:12:16PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> Using the existing other arch scripts resulted in this error:
> 
> tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: 
> __NR3264_ftruncate: expected numeric value
> 
> because, unlike other arches, asm-generic's unistd.h does things like:
> 
>  #define __NR_ftruncate __NR3264_ftruncate
> 
> Turning the scripts printf's %d into a %s resulted in this in the
> generated syscalls.c file:
> 
> static const char *syscalltbl_arm64[] = {
> [__NR3264_ftruncate] = "ftruncate",
> 
> So we use the host C compiler to fold the macros, and print them out
> from within a temporary C program, in order to get the correct output:
> 
> static const char *syscalltbl_arm64[] = {
>     [46] = "ftruncate",
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
> Changes in V2:
>  - added the "sc" and "nr" local variables, for the sake of completion 
> (Hendrik
>Brueckner)
>  - Removed the unsafe -u from mktemp, added more X's, and now pipe the
>C code to the $hostcc command, so we now only require a single temp
>file that is written by gcc. (Hendrik Brueckner)
>  - used cat << EoHEADER instead of echos for the c file header, to make it 
> more
>readable (Hendrik Brueckner)
>  - $RM -> rm, to be able to run standalone (Hendrik Brueckner)

Many thanks for incorporating the feedback!

>  - moved the rm into the function that makes the file
>  - converted other echos to printf "%s\n" for more portable printing of
>backslash characters (bash and dash built-in echo commands differ in
>how many escape backslashes are needed).  The initial "%s\n" is needed
>in order to keep the external printf command from interpreting the %ds.
> 
>  tools/perf/arch/arm64/Makefile| 21 +++
>  .../arch/arm64/entry/syscalls/mksyscalltbl| 61 +++
>  2 files changed, 82 insertions(+)
>  create mode 100755 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> 
> diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
> index 91de4860faad..85fdf4949db3 100644
> --- a/tools/perf/arch/arm64/Makefile
> +++ b/tools/perf/arch/arm64/Makefile
> @@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
>  endif
>  PERF_HAVE_JITDUMP := 1
>  PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
> +
> +#
> +# Syscall table generation for perf
> +#
> +
> +out:= $(OUTPUT)arch/arm64/include/generated/asm
> +header := $(out)/syscalls.c
> +sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
> +sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
> +systbl := $(sysprf)/mksyscalltbl
> +
> +# Create output directory if not already present
> +_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
> +
> +$(header): $(sysdef) $(systbl)
> + $(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
> +
> +clean::
> + $(call QUIET_CLEAN, arm64) $(RM) $(header)
> +
> +archheaders: $(header)
> diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl 
> b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> new file mode 100755
> index ..f806542eb3cc
> --- /dev/null
> +++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> @@ -0,0 +1,61 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate system call table for perf. Derived from
> +# powerpc script.
> +#
> +# Copyright IBM Corp. 2017
> +# Author(s):  Hendrik Brueckner 
> +# Changed by: Ravi Bangoria 
> +# Changed by: Kim Phillips 
> +
> +gcc=$1
> +hostcc=$2
> +input=$3
> +
> +if ! test -r $input; then
> + echo "Could not read input file" >&2
> + exit 1
> +fi
> +
> +create_table_from_c()
> +{
> + local sc nr last_sc
> +
> + create_table_exe=`mktemp /tmp/create-table-XX`
> +
> + {
> +
> +cat << _EoHEADER
> +#include 
> +#include "$input"
> +int main(int argc, char *argv[])
> +{
> +_EoHEADER

One minor style hint: Using cat <<-_EoHEADER (with a dash) strips any leading
tabs from the what is being concatenated.  With this, using the same indent as
for as the other function statements it possible.  For example,

cat <<-

Re: [PATCH 3/3] perf trace arm64: Use generated syscall table

2018-07-04 Thread Hendrik Brueckner
On Tue, Jul 03, 2018 at 12:32:38PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> It also enables users to specify wildcards, for example, perf trace -e
> 'open*', just like was already possible on x86, s390, and powerpc, which
> means arm64 can now pass the "Check open filename arg using perf trace +
> vfs_getname" test.
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
>  tools/perf/Makefile.config   | 2 ++
>  tools/perf/util/syscalltbl.c | 4 
>  2 files changed, 6 insertions(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index b5ac356ba323..3126155810bb 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -54,6 +54,8 @@ endif
> 
>  ifeq ($(SRCARCH),arm64)
>NO_PERF_REGS := 0
> +  NO_SYSCALL_TABLE := 0
> +  CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
>LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
>  endif
> 
> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
> index 0ee7f568d60c..3393d7ee9401 100644
> --- a/tools/perf/util/syscalltbl.c
> +++ b/tools/perf/util/syscalltbl.c
> @@ -38,6 +38,10 @@ static const char **syscalltbl_native = 
> syscalltbl_powerpc_64;
>  #include 
>  const int syscalltbl_native_max_id = SYSCALLTBL_POWERPC_32_MAX_ID;
>  static const char **syscalltbl_native = syscalltbl_powerpc_32;
> +#elif defined(__aarch64__)
> +#include 
> +const int syscalltbl_native_max_id = SYSCALLTBL_ARM64_MAX_ID;
> +static const char **syscalltbl_native = syscalltbl_arm64;
>  #endif
> 
>  struct syscall {

Looks good.

Reviewed-by: Hendrik Brueckner 



Re: [PATCH 3/3] perf trace arm64: Use generated syscall table

2018-07-04 Thread Hendrik Brueckner
On Tue, Jul 03, 2018 at 12:32:38PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> It also enables users to specify wildcards, for example, perf trace -e
> 'open*', just like was already possible on x86, s390, and powerpc, which
> means arm64 can now pass the "Check open filename arg using perf trace +
> vfs_getname" test.
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
>  tools/perf/Makefile.config   | 2 ++
>  tools/perf/util/syscalltbl.c | 4 
>  2 files changed, 6 insertions(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index b5ac356ba323..3126155810bb 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -54,6 +54,8 @@ endif
> 
>  ifeq ($(SRCARCH),arm64)
>NO_PERF_REGS := 0
> +  NO_SYSCALL_TABLE := 0
> +  CFLAGS += -I$(OUTPUT)arch/arm64/include/generated
>LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
>  endif
> 
> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
> index 0ee7f568d60c..3393d7ee9401 100644
> --- a/tools/perf/util/syscalltbl.c
> +++ b/tools/perf/util/syscalltbl.c
> @@ -38,6 +38,10 @@ static const char **syscalltbl_native = 
> syscalltbl_powerpc_64;
>  #include 
>  const int syscalltbl_native_max_id = SYSCALLTBL_POWERPC_32_MAX_ID;
>  static const char **syscalltbl_native = syscalltbl_powerpc_32;
> +#elif defined(__aarch64__)
> +#include 
> +const int syscalltbl_native_max_id = SYSCALLTBL_ARM64_MAX_ID;
> +static const char **syscalltbl_native = syscalltbl_arm64;
>  #endif
> 
>  struct syscall {

Looks good.

Reviewed-by: Hendrik Brueckner 



Re: [PATCH 2/3] perf arm64: Generate system call table from asm/unistd.h

2018-07-04 Thread Hendrik Brueckner
Hi Kim,

On Tue, Jul 03, 2018 at 12:32:28PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> Using the existing other arch scripts resulted in this error:
> 
> tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: 
> __NR3264_ftruncate: expected numeric value
> 
> because, unlike other arches, asm-generic's unistd.h does things like:
> 
>  #define __NR_ftruncate __NR3264_ftruncate
> 
> Turning the scripts printf's %d into a %s resulted in this in the
> generated syscalls.c file:
> 
> static const char *syscalltbl_arm64[] = {
> [__NR3264_ftruncate] = "ftruncate",
> 
> So we use the host C compiler to fold the macros, and print them out
> from within a temporary C program, in order to get the correct output:
> 
> static const char *syscalltbl_arm64[] = {
>     [46] = "ftruncate",
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
>  tools/perf/arch/arm64/Makefile| 21 
>  .../arch/arm64/entry/syscalls/mksyscalltbl| 54 +++
>  2 files changed, 75 insertions(+)
>  create mode 100755 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> 
> diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
> index 91de4860faad..85fdf4949db3 100644
> --- a/tools/perf/arch/arm64/Makefile
> +++ b/tools/perf/arch/arm64/Makefile
> @@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
>  endif
>  PERF_HAVE_JITDUMP := 1
>  PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
> +
> +#
> +# Syscall table generation for perf
> +#
> +
> +out:= $(OUTPUT)arch/arm64/include/generated/asm
> +header := $(out)/syscalls.c
> +sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
> +sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
> +systbl := $(sysprf)/mksyscalltbl
> +
> +# Create output directory if not already present
> +_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
> +
> +$(header): $(sysdef) $(systbl)
> + $(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
> +
> +clean::
> + $(call QUIET_CLEAN, arm64) $(RM) $(header)
> +
> +archheaders: $(header)
> diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl 
> b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> new file mode 100755
> index ..1148302b7194
> --- /dev/null
> +++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> @@ -0,0 +1,54 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate system call table for perf. Derived from
> +# powerpc script.
> +#
> +# Copyright IBM Corp. 2017
> +# Author(s):  Hendrik Brueckner 
> +# Changed by: Ravi Bangoria 
> +# Changed by: Kim Phillips 
> +
> +gcc=$1
> +hostcc=$2
> +input=$3
> +
> +if ! test -r $input; then
> + echo "Could not read input file" >&2
> + exit 1
> +fi
> +
> +create_table_from_c()
> +{
> + local last_sc

For the sake of completion, also add the "sc" and "nr" local variables.

> +
> + create_table_base=`mktemp -u /tmp/create-table-XXX`

- The -u is considered to be unsafe. But from below, I think you require
  this for the .c/.x file.  Alternatively, you could create the file
  (and prefer using more X for the template) and append to it.  Or pipe
  the C code to the $hostcc command, e.g.,
$hostcc -o $create_table_base -x c -
  which would require a single temp file that would be overwritten by gcc.

> + echo "#include " > ${create_table_base}.c
> + echo "#include \"$input\"" >> ${create_table_base}.c
> +
> + echo "int main(int argc, char *argv[])" >> ${create_table_base}.c
> + echo "{" >> ${create_table_base}.c

As alternative to these echos, use

cat >> ${create_table_base}.c <<-EoHEADER
#include 
#include "$input"
int main(int argc, char *argv[])
{
EoHeader

which is at least for larger portions a bit more readable.

> + while read sc nr; do
> + echo "  printf(\"\\\t[%d] = \\\"$sc\\\",\\\n\", __NR_$sc);" >> 
> ${create_table_base}.c
> + last_sc=$sc
> + done
> + echo "  printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\\n\", 
> __NR_$last_sc);" >> ${create_table_base}.

Re: [PATCH 2/3] perf arm64: Generate system call table from asm/unistd.h

2018-07-04 Thread Hendrik Brueckner
Hi Kim,

On Tue, Jul 03, 2018 at 12:32:28PM -0500, Kim Phillips wrote:
> This should speed up accessing new system calls introduced with the
> kernel rather than waiting for libaudit updates to include them.
> 
> Using the existing other arch scripts resulted in this error:
> 
> tools/perf/arch/arm64/entry/syscalls//mksyscalltbl: 25: printf: 
> __NR3264_ftruncate: expected numeric value
> 
> because, unlike other arches, asm-generic's unistd.h does things like:
> 
>  #define __NR_ftruncate __NR3264_ftruncate
> 
> Turning the scripts printf's %d into a %s resulted in this in the
> generated syscalls.c file:
> 
> static const char *syscalltbl_arm64[] = {
> [__NR3264_ftruncate] = "ftruncate",
> 
> So we use the host C compiler to fold the macros, and print them out
> from within a temporary C program, in order to get the correct output:
> 
> static const char *syscalltbl_arm64[] = {
>     [46] = "ftruncate",
> 
> Cc: Ravi Bangoria 
> Cc: Alexander Shishkin 
> Cc: Hendrik Brueckner 
> Cc: Jiri Olsa 
> Cc: Michael Ellerman 
> Cc: Namhyung Kim 
> Cc: Thomas Richter 
> Cc: Peter Zijlstra 
> Cc: Ingo Molnar 
> Cc: Arnaldo Carvalho de Melo 
> Signed-off-by: Kim Phillips 
> ---
>  tools/perf/arch/arm64/Makefile| 21 
>  .../arch/arm64/entry/syscalls/mksyscalltbl| 54 +++
>  2 files changed, 75 insertions(+)
>  create mode 100755 tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> 
> diff --git a/tools/perf/arch/arm64/Makefile b/tools/perf/arch/arm64/Makefile
> index 91de4860faad..85fdf4949db3 100644
> --- a/tools/perf/arch/arm64/Makefile
> +++ b/tools/perf/arch/arm64/Makefile
> @@ -4,3 +4,24 @@ PERF_HAVE_DWARF_REGS := 1
>  endif
>  PERF_HAVE_JITDUMP := 1
>  PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
> +
> +#
> +# Syscall table generation for perf
> +#
> +
> +out:= $(OUTPUT)arch/arm64/include/generated/asm
> +header := $(out)/syscalls.c
> +sysdef := $(srctree)/tools/arch/arm64/include/uapi/asm/unistd.h
> +sysprf := $(srctree)/tools/perf/arch/arm64/entry/syscalls/
> +systbl := $(sysprf)/mksyscalltbl
> +
> +# Create output directory if not already present
> +_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
> +
> +$(header): $(sysdef) $(systbl)
> + $(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(sysdef) > $@
> +
> +clean::
> + $(call QUIET_CLEAN, arm64) $(RM) $(header)
> +
> +archheaders: $(header)
> diff --git a/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl 
> b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> new file mode 100755
> index ..1148302b7194
> --- /dev/null
> +++ b/tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
> @@ -0,0 +1,54 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate system call table for perf. Derived from
> +# powerpc script.
> +#
> +# Copyright IBM Corp. 2017
> +# Author(s):  Hendrik Brueckner 
> +# Changed by: Ravi Bangoria 
> +# Changed by: Kim Phillips 
> +
> +gcc=$1
> +hostcc=$2
> +input=$3
> +
> +if ! test -r $input; then
> + echo "Could not read input file" >&2
> + exit 1
> +fi
> +
> +create_table_from_c()
> +{
> + local last_sc

For the sake of completion, also add the "sc" and "nr" local variables.

> +
> + create_table_base=`mktemp -u /tmp/create-table-XXX`

- The -u is considered to be unsafe. But from below, I think you require
  this for the .c/.x file.  Alternatively, you could create the file
  (and prefer using more X for the template) and append to it.  Or pipe
  the C code to the $hostcc command, e.g.,
$hostcc -o $create_table_base -x c -
  which would require a single temp file that would be overwritten by gcc.

> + echo "#include " > ${create_table_base}.c
> + echo "#include \"$input\"" >> ${create_table_base}.c
> +
> + echo "int main(int argc, char *argv[])" >> ${create_table_base}.c
> + echo "{" >> ${create_table_base}.c

As alternative to these echos, use

cat >> ${create_table_base}.c <<-EoHEADER
#include 
#include "$input"
int main(int argc, char *argv[])
{
EoHeader

which is at least for larger portions a bit more readable.

> + while read sc nr; do
> + echo "  printf(\"\\\t[%d] = \\\"$sc\\\",\\\n\", __NR_$sc);" >> 
> ${create_table_base}.c
> + last_sc=$sc
> + done
> + echo "  printf(\"#define SYSCALLTBL_ARM64_MAX_ID %d\\\n\", 
> __NR_$last_sc);" >> ${create_table_base}.

Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()

2018-07-03 Thread Hendrik Brueckner
On Mon, Jul 02, 2018 at 04:33:28PM -0600, Mathieu Poirier wrote:
> It can be advantagous to have access to all the information conveyed by
> a perf_event when setting up the AUX buffer, as it is the case when
> dealing with PMU specific driver configuration communicated to the kernel
> using an ioctl() call.
> 
> As such simply replace the cpu information by the complete perf_event
> structure and change all affected customers.
> 
> Signed-off-by: Mathieu Poirier 
> ---
>  arch/s390/kernel/perf_cpum_sf.c  | 4 ++--
>  arch/x86/events/intel/bts.c  | 4 +++-
>  arch/x86/events/intel/pt.c   | 5 +++--
>  drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
>  drivers/perf/arm_spe_pmu.c   | 6 +++---
>  include/linux/perf_event.h   | 2 +-
>  kernel/events/ring_buffer.c  | 2 +-
>  7 files changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 0292d68e7dde..e06daaa08894 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -1601,8 +1601,8 @@ static void aux_buffer_free(void *data)
>   *
>   * Return the private AUX buffer structure if success or NULL if fails.
>   */
> -static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
> -   bool snapshot)
> +static void *aux_buffer_setup(struct perf_event *event, void **pages,
> +   int nr_pages, bool snapshot);

Please remove the trailing semi-colon (;) in the function definition causing
the kbuild error.  Also, it would be great if you also could update the
function comment and replace the @cpu by the @event.

Many thanks.



Re: [PATCH 4/6] perf/aux: Make perf_event accessible to setup_aux()

2018-07-03 Thread Hendrik Brueckner
On Mon, Jul 02, 2018 at 04:33:28PM -0600, Mathieu Poirier wrote:
> It can be advantagous to have access to all the information conveyed by
> a perf_event when setting up the AUX buffer, as it is the case when
> dealing with PMU specific driver configuration communicated to the kernel
> using an ioctl() call.
> 
> As such simply replace the cpu information by the complete perf_event
> structure and change all affected customers.
> 
> Signed-off-by: Mathieu Poirier 
> ---
>  arch/s390/kernel/perf_cpum_sf.c  | 4 ++--
>  arch/x86/events/intel/bts.c  | 4 +++-
>  arch/x86/events/intel/pt.c   | 5 +++--
>  drivers/hwtracing/coresight/coresight-etm-perf.c | 6 +++---
>  drivers/perf/arm_spe_pmu.c   | 6 +++---
>  include/linux/perf_event.h   | 2 +-
>  kernel/events/ring_buffer.c  | 2 +-
>  7 files changed, 16 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/s390/kernel/perf_cpum_sf.c b/arch/s390/kernel/perf_cpum_sf.c
> index 0292d68e7dde..e06daaa08894 100644
> --- a/arch/s390/kernel/perf_cpum_sf.c
> +++ b/arch/s390/kernel/perf_cpum_sf.c
> @@ -1601,8 +1601,8 @@ static void aux_buffer_free(void *data)
>   *
>   * Return the private AUX buffer structure if success or NULL if fails.
>   */
> -static void *aux_buffer_setup(int cpu, void **pages, int nr_pages,
> -   bool snapshot)
> +static void *aux_buffer_setup(struct perf_event *event, void **pages,
> +   int nr_pages, bool snapshot);

Please remove the trailing semi-colon (;) in the function definition causing
the kbuild error.  Also, it would be great if you also could update the
function comment and replace the @cpu by the @event.

Many thanks.



[tip:perf/core] perf tests: Let 'perf test list' display subtests

2018-05-02 Thread tip-bot for Hendrik Brueckner
Commit-ID:  ea40b6d3222e5feef178d9b49baead28e9b5fe20
Gitweb: https://git.kernel.org/tip/ea40b6d3222e5feef178d9b49baead28e9b5fe20
Author: Hendrik Brueckner <brueck...@linux.ibm.com>
AuthorDate: Fri, 13 Apr 2018 09:42:23 +0200
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Thu, 26 Apr 2018 13:47:07 -0300

perf tests: Let 'perf test list' display subtests

The output of perf test and perf test list differ because perf test list
does not display subtests.  Correct this behavior and also let perf test
list report subtests.

For example:

$ ./perf test 2>&1 |wc -l
65

Without this commit:
$ ./perf test list 2>&1 |wc -l
57

With this commit:
$ ./perf test list 2>&1 |wc -l
    65

Signed-off-by: Hendrik Brueckner <brueck...@linux.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.ibm.com>
Acked-by: Jiri Olsa <jo...@kernel.org>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1523605343-11970-1-git-send-email-brueck...@linux.ibm.com
Link: https://lkml.kernel.org/n/tip-efb74jw7x2xs2bucp5hf4...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/tests/builtin-test.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index cac8f8889bc3..2bde505e2e7e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -654,6 +654,15 @@ static int perf_test__list(int argc, const char **argv)
continue;
 
pr_info("%2d: %s\n", i, t->desc);
+
+   if (t->subtest.get_nr) {
+   int subn = t->subtest.get_nr();
+   int subi;
+
+   for (subi = 0; subi < subn; subi++)
+   pr_info("%2d:%1d: %s\n", i, subi + 1,
+   t->subtest.get_desc(subi));
+   }
}
 
perf_test__list_shell(argc, argv, i);


[tip:perf/core] perf tests: Let 'perf test list' display subtests

2018-05-02 Thread tip-bot for Hendrik Brueckner
Commit-ID:  ea40b6d3222e5feef178d9b49baead28e9b5fe20
Gitweb: https://git.kernel.org/tip/ea40b6d3222e5feef178d9b49baead28e9b5fe20
Author: Hendrik Brueckner 
AuthorDate: Fri, 13 Apr 2018 09:42:23 +0200
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 26 Apr 2018 13:47:07 -0300

perf tests: Let 'perf test list' display subtests

The output of perf test and perf test list differ because perf test list
does not display subtests.  Correct this behavior and also let perf test
list report subtests.

For example:

$ ./perf test 2>&1 |wc -l
65

Without this commit:
$ ./perf test list 2>&1 |wc -l
57

With this commit:
$ ./perf test list 2>&1 |wc -l
    65

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Acked-by: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1523605343-11970-1-git-send-email-brueck...@linux.ibm.com
Link: https://lkml.kernel.org/n/tip-efb74jw7x2xs2bucp5hf4...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/builtin-test.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index cac8f8889bc3..2bde505e2e7e 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -654,6 +654,15 @@ static int perf_test__list(int argc, const char **argv)
continue;
 
pr_info("%2d: %s\n", i, t->desc);
+
+   if (t->subtest.get_nr) {
+   int subn = t->subtest.get_nr();
+   int subi;
+
+   for (subi = 0; subi < subn; subi++)
+   pr_info("%2d:%1d: %s\n", i, subi + 1,
+   t->subtest.get_desc(subi));
+   }
}
 
perf_test__list_shell(argc, argv, i);


Re: s390 perf events JSONs query

2018-04-20 Thread Hendrik Brueckner
Hi John,

On Fri, Apr 20, 2018 at 02:53:27PM +0100, John Garry wrote:
> On 20/04/2018 14:25, Thomas-Mich Richter wrote:
> >On 04/20/2018 12:51 PM, John Garry wrote:
> >>I noticed that in 4.17-rc1 support was included for s390 perf pmu-events. I 
> >>also notice that the JSONs contain many common (identical actually) events 
> >>between different chips for this arch.
> >>
> >>Support was added for factoring out common arch events in 
> >>https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/tools/perf/pmu-events?h=next-20180420=e9d32c1bf0cd7a98358ec4aa1625bf2b3459b9ac
> >>
> >>ARM64 chips use this feature. I am not familiar with the s390 arch, but do 
> >>you think you could also use this feature?
> >>
> >>Thanks,
> >>John
> >>
> >
> >I have just played with this feature. I was caught off by this error message:
> >
> >[root@s35lp76 pmu-events]# ./jevents s390 arch /tmp/xxx 10
> >d 04096 s390 arch/s390
> >d 14096 cf_z14   arch/s390/cf_z14
> >f 21338 basic.json   arch/s390/cf_z14/basic.json
> >
> >jevents: Ignoring file arch/s390/archevent.json  < confusing error 
> >message
> 
> Let me check if this can be silenced.
> 
> >
> >jevents: Processing mapfile arch/s390/mapfile.csv
> >[root@s35lp76 pmu-events]#
> >
> >I started debugging, until I realized this file is still processed.
> >(Just a side remark).
> >
> >Anyway the features is nice, but it does not save anything in the resulting
> >pmu-events.c file, correct? The events defined in the common archevent.json
> >files are just copied into the structures of a specific machine.
> >
> 
> Yes, the resulting derived pmu-events.c should be the same. In fact,
> if there was naming inconsistencies in JSONs previously, they should
> now be gone.
> 
> >The feature saves time and space when you create the machine specific json
> >files because it allows you to refer to a common event by name. Cool!
> >
> >On s390 we do not create the json files manually, but have some scripts to
> >create them based on s390 type/model hardware specific input files.
> 
> Right, I would say that this is mostly useful when the JSONs are
> created manually, which was the case in the ARM world, but not x86.

It is really the right way and the coolest feature to go when the JSONs need
to be created manually.

For s390, I started manually with adding descriptions for the libpfm4 library.
Then, the events sysfs came up and that was the point in time when I created
a common database for the counters in the s390-tools package.  Meanwhile,
s390-tools, libpfm4, kernel, and Thomas recently added perf JSONs as possible
outputs formats.

> >@Hendrik,
> >we could rework our internal tool chain to emit the new "ArchStdEvent"
> >keyword for common events, but in the end we do not save anything in the
> >resulting pmu-events.c file. And it requires considerable rework to
> >support it.
> >Given that, I would put it very low priority on your todo list, comments?

I would consider this a low-priority given the fact that have to overwrite
to the counter number (for the model-dependent counters) as well.

Many thanks!
 
Kind regards,
  Hendrik



Re: s390 perf events JSONs query

2018-04-20 Thread Hendrik Brueckner
Hi John,

On Fri, Apr 20, 2018 at 02:53:27PM +0100, John Garry wrote:
> On 20/04/2018 14:25, Thomas-Mich Richter wrote:
> >On 04/20/2018 12:51 PM, John Garry wrote:
> >>I noticed that in 4.17-rc1 support was included for s390 perf pmu-events. I 
> >>also notice that the JSONs contain many common (identical actually) events 
> >>between different chips for this arch.
> >>
> >>Support was added for factoring out common arch events in 
> >>https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/tools/perf/pmu-events?h=next-20180420=e9d32c1bf0cd7a98358ec4aa1625bf2b3459b9ac
> >>
> >>ARM64 chips use this feature. I am not familiar with the s390 arch, but do 
> >>you think you could also use this feature?
> >>
> >>Thanks,
> >>John
> >>
> >
> >I have just played with this feature. I was caught off by this error message:
> >
> >[root@s35lp76 pmu-events]# ./jevents s390 arch /tmp/xxx 10
> >d 04096 s390 arch/s390
> >d 14096 cf_z14   arch/s390/cf_z14
> >f 21338 basic.json   arch/s390/cf_z14/basic.json
> >
> >jevents: Ignoring file arch/s390/archevent.json  < confusing error 
> >message
> 
> Let me check if this can be silenced.
> 
> >
> >jevents: Processing mapfile arch/s390/mapfile.csv
> >[root@s35lp76 pmu-events]#
> >
> >I started debugging, until I realized this file is still processed.
> >(Just a side remark).
> >
> >Anyway the features is nice, but it does not save anything in the resulting
> >pmu-events.c file, correct? The events defined in the common archevent.json
> >files are just copied into the structures of a specific machine.
> >
> 
> Yes, the resulting derived pmu-events.c should be the same. In fact,
> if there was naming inconsistencies in JSONs previously, they should
> now be gone.
> 
> >The feature saves time and space when you create the machine specific json
> >files because it allows you to refer to a common event by name. Cool!
> >
> >On s390 we do not create the json files manually, but have some scripts to
> >create them based on s390 type/model hardware specific input files.
> 
> Right, I would say that this is mostly useful when the JSONs are
> created manually, which was the case in the ARM world, but not x86.

It is really the right way and the coolest feature to go when the JSONs need
to be created manually.

For s390, I started manually with adding descriptions for the libpfm4 library.
Then, the events sysfs came up and that was the point in time when I created
a common database for the counters in the s390-tools package.  Meanwhile,
s390-tools, libpfm4, kernel, and Thomas recently added perf JSONs as possible
outputs formats.

> >@Hendrik,
> >we could rework our internal tool chain to emit the new "ArchStdEvent"
> >keyword for common events, but in the end we do not save anything in the
> >resulting pmu-events.c file. And it requires considerable rework to
> >support it.
> >Given that, I would put it very low priority on your todo list, comments?

I would consider this a low-priority given the fact that have to overwrite
to the counter number (for the model-dependent counters) as well.

Many thanks!
 
Kind regards,
  Hendrik



Re: [PATCH] perf stat: Add support for s390 transaction counters

2018-03-14 Thread Hendrik Brueckner
Hi,

On Wed, Mar 14, 2018 at 08:43:17AM -0700, Andi Kleen wrote:
> > S390 has no support for Elision and uses transaction begin/end/abort
> > instructions. The CPU measurement counter facility provides counters for
> > transaction end and transaction abort.
> 
> You don't need to implement the el-* events.
> 
> > I have used this table (taken from arch/x86/events/intel/core.c) as 
> > giudeline:
> > /* Haswell special events */
> > EVENT_ATTR_STR(tx-start,tx_start,   "event=0xc9,umask=0x1");
> > EVENT_ATTR_STR(tx-commit,   tx_commit,  "event=0xc9,umask=0x2");
> > EVENT_ATTR_STR(tx-abort,tx_abort,   "event=0xc9,umask=0x4");
> > EVENT_ATTR_STR(tx-capacity, tx_capacity,"event=0x54,umask=0x2");
> > EVENT_ATTR_STR(tx-conflict, tx_conflict,"event=0x54,umask=0x1");
> > EVENT_ATTR_STR(el-start,el_start,   "event=0xc8,umask=0x1");
> > EVENT_ATTR_STR(el-commit,   el_commit,  "event=0xc8,umask=0x2");
> > EVENT_ATTR_STR(el-abort,el_abort,   "event=0xc8,umask=0x4");
> > EVENT_ATTR_STR(el-capacity, el_capacity,"event=0x54,umask=0x2");
> > EVENT_ATTR_STR(el-conflict, el_conflict,"event=0x54,umask=0x1");
> > EVENT_ATTR_STR(cycles-t,cycles_t,   "event=0x3c,in_tx=1");
> > EVENT_ATTR_STR(cycles-ct,   cycles_ct,  
> > "event=0x3c,in_tx=1,in_tx_cp=1");
> > 
> > 
> > So s390 can only support tx_commit and tx-abort symbolic names.

In detail, for s390 we have:

cpum_cf/TX_C_TABORT_NO_SPECIAL/
cpum_cf/TX_C_TABORT_SPECIAL/
cpum_cf/TX_C_TEND/
cpum_cf/TX_NC_TABORT/
cpum_cf/TX_NC_TEND/

The mapping of the above is not that easy. As s390 have counters for
non-constraint (TC_NC_*) and contraint (TX_C_*) transaction commits (TEND)
and aborts (TABORTs).

> We could change perf stat to fall back to only tx commit and tx abort.
> We already did that for one limited case.

Displaying these different types for s390 is important from my point of
view.  Of course, I could create a mapping of TX_NC_TABORT/TX_NC_TEND
to tx-commit/tx-abort.  The remaining events would still appear to be specific
to the cpum_cf.

So I would propose to go with adding the cpum_cf/ specific ones first.
If necessary, they could go into the perf/arch/s390/ directory and included
in builtin-stat.  I put a todo on my list to provide at least a
tx-commit/abort for the nonconstraint transactions. (The other would still be
specific).

Kind regards,
  Hendrik

-- 
Hendrik Brueckner
brueck...@linux.vnet.ibm.com  | IBM Deutschland Research & Development GmbH
Linux on z Systems Development| Schoenaicher Str. 220, 71032 Boeblingen


IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



Re: [PATCH] perf stat: Add support for s390 transaction counters

2018-03-14 Thread Hendrik Brueckner
Hi,

On Wed, Mar 14, 2018 at 08:43:17AM -0700, Andi Kleen wrote:
> > S390 has no support for Elision and uses transaction begin/end/abort
> > instructions. The CPU measurement counter facility provides counters for
> > transaction end and transaction abort.
> 
> You don't need to implement the el-* events.
> 
> > I have used this table (taken from arch/x86/events/intel/core.c) as 
> > giudeline:
> > /* Haswell special events */
> > EVENT_ATTR_STR(tx-start,tx_start,   "event=0xc9,umask=0x1");
> > EVENT_ATTR_STR(tx-commit,   tx_commit,  "event=0xc9,umask=0x2");
> > EVENT_ATTR_STR(tx-abort,tx_abort,   "event=0xc9,umask=0x4");
> > EVENT_ATTR_STR(tx-capacity, tx_capacity,"event=0x54,umask=0x2");
> > EVENT_ATTR_STR(tx-conflict, tx_conflict,"event=0x54,umask=0x1");
> > EVENT_ATTR_STR(el-start,el_start,   "event=0xc8,umask=0x1");
> > EVENT_ATTR_STR(el-commit,   el_commit,  "event=0xc8,umask=0x2");
> > EVENT_ATTR_STR(el-abort,el_abort,   "event=0xc8,umask=0x4");
> > EVENT_ATTR_STR(el-capacity, el_capacity,"event=0x54,umask=0x2");
> > EVENT_ATTR_STR(el-conflict, el_conflict,"event=0x54,umask=0x1");
> > EVENT_ATTR_STR(cycles-t,cycles_t,   "event=0x3c,in_tx=1");
> > EVENT_ATTR_STR(cycles-ct,   cycles_ct,  
> > "event=0x3c,in_tx=1,in_tx_cp=1");
> > 
> > 
> > So s390 can only support tx_commit and tx-abort symbolic names.

In detail, for s390 we have:

cpum_cf/TX_C_TABORT_NO_SPECIAL/
cpum_cf/TX_C_TABORT_SPECIAL/
cpum_cf/TX_C_TEND/
cpum_cf/TX_NC_TABORT/
cpum_cf/TX_NC_TEND/

The mapping of the above is not that easy. As s390 have counters for
non-constraint (TC_NC_*) and contraint (TX_C_*) transaction commits (TEND)
and aborts (TABORTs).

> We could change perf stat to fall back to only tx commit and tx abort.
> We already did that for one limited case.

Displaying these different types for s390 is important from my point of
view.  Of course, I could create a mapping of TX_NC_TABORT/TX_NC_TEND
to tx-commit/tx-abort.  The remaining events would still appear to be specific
to the cpum_cf.

So I would propose to go with adding the cpum_cf/ specific ones first.
If necessary, they could go into the perf/arch/s390/ directory and included
in builtin-stat.  I put a todo on my list to provide at least a
tx-commit/abort for the nonconstraint transactions. (The other would still be
specific).

Kind regards,
  Hendrik

-- 
Hendrik Brueckner
brueck...@linux.vnet.ibm.com  | IBM Deutschland Research & Development GmbH
Linux on z Systems Development| Schoenaicher Str. 220, 71032 Boeblingen


IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martina Koederitz
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



[tip:perf/urgent] Revert "tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h"

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  f1d0b4cde922863004ce3f5f39e8662cc0686c96
Gitweb: https://git.kernel.org/tip/f1d0b4cde922863004ce3f5f39e8662cc0686c96
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 8 Feb 2018 12:47:48 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Thu, 15 Feb 2018 10:06:15 -0300

Revert "tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h"

This reverts commit f120c7b187e6c418238710b48723ce141f467543 which is no
longer required with the introduction of a syscall.tbl on s390.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-q1lg0nvhha1tk39ri9aqa...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/arch/s390/include/uapi/asm/unistd.h | 412 --
 tools/perf/check-headers.sh   |   1 -
 2 files changed, 413 deletions(-)

diff --git a/tools/arch/s390/include/uapi/asm/unistd.h 
b/tools/arch/s390/include/uapi/asm/unistd.h
deleted file mode 100644
index 7251209..000
--- a/tools/arch/s390/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- *  S390 version
- *
- *  Derived from "include/asm-i386/unistd.h"
- */
-
-#ifndef _UAPI_ASM_S390_UNISTD_H_
-#define _UAPI_ASM_S390_UNISTD_H_
-
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_exit 1
-#define __NR_fork 2
-#define __NR_read 3
-#define __NR_write4
-#define __NR_open 5
-#define __NR_close6
-#define __NR_restart_syscall 7
-#define __NR_creat8
-#define __NR_link 9
-#define __NR_unlink  10
-#define __NR_execve  11
-#define __NR_chdir   12
-#define __NR_mknod   14
-#define __NR_chmod   15
-#define __NR_lseek   19
-#define __NR_getpid  20
-#define __NR_mount   21
-#define __NR_umount  22
-#define __NR_ptrace  26
-#define __NR_alarm   27
-#define __NR_pause   29
-#define __NR_utime   30
-#define __NR_access  33
-#define __NR_nice34
-#define __NR_sync36
-#define __NR_kill37
-#define __NR_rename  38
-#define __NR_mkdir   39
-#define __NR_rmdir   40
-#define __NR_dup 41
-#define __NR_pipe42
-#define __NR_times   43
-#define __NR_brk 45
-#define __NR_signal  48
-#define __NR_acct51
-#define __NR_umount2 52
-#define __NR_ioctl   54
-#define __NR_fcntl   55
-#define __NR_setpgid 57
-#define __NR_umask   60
-#define __NR_chroot  61
-#define __NR_ustat   62
-#define __NR_dup263
-#define __NR_getppid 64
-#define __NR_getpgrp 65
-#define __NR_setsid  66
-#define __NR_sigaction   67
-#define __NR_sigsuspend  72
-#define __NR_sigpending  73
-#define __NR_sethostname 74
-#define __NR_setrlimit   75
-#define __NR_getrusage   77
-#define __NR_gettimeofday78
-#define __NR_settimeofday79
-#define __NR_symlink 83
-#define __NR_readlink85
-#define __NR_uselib  86
-#define __NR_swapon  87
-#define __NR_reboot  88
-#define __NR_readdir 89
-#define __NR_mmap90
-#define __NR_munmap  91
-#define __NR_truncate92
-#define __NR_ftruncate   93
-#define __NR_fchmod  94
-#define __NR_getpriority 96
-#define __NR_setpriority 97
-#define __NR_statfs  99
-#define __NR_fstatfs100
-#define __NR_socketcall 102
-#define __NR_syslog 103
-#define __NR_setitimer  104
-#define __NR_getitimer  105
-#define __NR_stat   106
-#define __NR_lstat  107
-#define __NR_fstat  108
-#define __NR_lookup_dcookie 110
-#define __NR_vhangup111
-#define __NR_idle   112
-#define __NR_wait4  114
-#define __NR_swapoff115
-#define __NR_sysinfo116
-#define __NR_ipc117
-#define __NR_fsync  118
-#define __NR_sigreturn  119
-#define __NR_clone  120
-#define __NR_setdomainname  121
-#define __NR_uname  122
-#define __NR_adjtim

[tip:perf/urgent] Revert "tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h"

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  f1d0b4cde922863004ce3f5f39e8662cc0686c96
Gitweb: https://git.kernel.org/tip/f1d0b4cde922863004ce3f5f39e8662cc0686c96
Author: Hendrik Brueckner 
AuthorDate: Thu, 8 Feb 2018 12:47:48 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 15 Feb 2018 10:06:15 -0300

Revert "tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h"

This reverts commit f120c7b187e6c418238710b48723ce141f467543 which is no
longer required with the introduction of a syscall.tbl on s390.

Signed-off-by: Hendrik Brueckner 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: Thomas Richter 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-q1lg0nvhha1tk39ri9aqa...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/arch/s390/include/uapi/asm/unistd.h | 412 --
 tools/perf/check-headers.sh   |   1 -
 2 files changed, 413 deletions(-)

diff --git a/tools/arch/s390/include/uapi/asm/unistd.h 
b/tools/arch/s390/include/uapi/asm/unistd.h
deleted file mode 100644
index 7251209..000
--- a/tools/arch/s390/include/uapi/asm/unistd.h
+++ /dev/null
@@ -1,412 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
-/*
- *  S390 version
- *
- *  Derived from "include/asm-i386/unistd.h"
- */
-
-#ifndef _UAPI_ASM_S390_UNISTD_H_
-#define _UAPI_ASM_S390_UNISTD_H_
-
-/*
- * This file contains the system call numbers.
- */
-
-#define __NR_exit 1
-#define __NR_fork 2
-#define __NR_read 3
-#define __NR_write4
-#define __NR_open 5
-#define __NR_close6
-#define __NR_restart_syscall 7
-#define __NR_creat8
-#define __NR_link 9
-#define __NR_unlink  10
-#define __NR_execve  11
-#define __NR_chdir   12
-#define __NR_mknod   14
-#define __NR_chmod   15
-#define __NR_lseek   19
-#define __NR_getpid  20
-#define __NR_mount   21
-#define __NR_umount  22
-#define __NR_ptrace  26
-#define __NR_alarm   27
-#define __NR_pause   29
-#define __NR_utime   30
-#define __NR_access  33
-#define __NR_nice34
-#define __NR_sync36
-#define __NR_kill37
-#define __NR_rename  38
-#define __NR_mkdir   39
-#define __NR_rmdir   40
-#define __NR_dup 41
-#define __NR_pipe42
-#define __NR_times   43
-#define __NR_brk 45
-#define __NR_signal  48
-#define __NR_acct51
-#define __NR_umount2 52
-#define __NR_ioctl   54
-#define __NR_fcntl   55
-#define __NR_setpgid 57
-#define __NR_umask   60
-#define __NR_chroot  61
-#define __NR_ustat   62
-#define __NR_dup263
-#define __NR_getppid 64
-#define __NR_getpgrp 65
-#define __NR_setsid  66
-#define __NR_sigaction   67
-#define __NR_sigsuspend  72
-#define __NR_sigpending  73
-#define __NR_sethostname 74
-#define __NR_setrlimit   75
-#define __NR_getrusage   77
-#define __NR_gettimeofday78
-#define __NR_settimeofday79
-#define __NR_symlink 83
-#define __NR_readlink85
-#define __NR_uselib  86
-#define __NR_swapon  87
-#define __NR_reboot  88
-#define __NR_readdir 89
-#define __NR_mmap90
-#define __NR_munmap  91
-#define __NR_truncate92
-#define __NR_ftruncate   93
-#define __NR_fchmod  94
-#define __NR_getpriority 96
-#define __NR_setpriority 97
-#define __NR_statfs  99
-#define __NR_fstatfs100
-#define __NR_socketcall 102
-#define __NR_syslog 103
-#define __NR_setitimer  104
-#define __NR_getitimer  105
-#define __NR_stat   106
-#define __NR_lstat  107
-#define __NR_fstat  108
-#define __NR_lookup_dcookie 110
-#define __NR_vhangup111
-#define __NR_idle   112
-#define __NR_wait4  114
-#define __NR_swapoff115
-#define __NR_sysinfo116
-#define __NR_ipc117
-#define __NR_fsync  118
-#define __NR_sigreturn  119
-#define __NR_clone  120
-#define __NR_setdomainname  121
-#define __NR_uname  122
-#define __NR_adjtimex   124
-#define __NR_mprotect   125
-#define __NR_sigprocmask126
-#define __NR_create_module  127
-#define __NR_init_module128
-#define __NR_delete_modu

[tip:perf/urgent] perf s390: Rework system call table creation by using syscall.tbl

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  690d22d9d4423b4522fb44a71145403eef2df834
Gitweb: https://git.kernel.org/tip/690d22d9d4423b4522fb44a71145403eef2df834
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 8 Feb 2018 12:47:50 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Thu, 15 Feb 2018 10:06:08 -0300

perf s390: Rework system call table creation by using syscall.tbl

Recently, s390 uses a syscall.tbl input file to generate its system call
table and unistd uapi header files.  Hence, update mksyscalltbl to use
it as input to create the system table for perf.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-4-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-bdyhllhsq1zgxv2qx4m37...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/arch/s390/Makefile| 10 +++---
 tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 18 +++---
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 48228de..dfa6e31 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -10,15 +10,19 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out:= $(OUTPUT)arch/s390/include/generated/asm
 header := $(out)/syscalls_64.c
-sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h
-sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/
+syskrn := $(srctree)/arch/s390/kernel/syscalls/syscall.tbl
+sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls
+sysdef := $(sysprf)/syscall.tbl
 systbl := $(sysprf)/mksyscalltbl
 
 # Create output directory if not already present
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 
 $(header): $(sysdef) $(systbl)
-   $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@
+   @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
+(diff -B $(sysdef) $(syskrn) >/dev/null) \
+|| echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest 
version at '$(syskrn)'" >&2 )) || true
+   $(Q)$(SHELL) '$(systbl)' $(sysdef) > $@
 
 clean::
$(call QUIET_CLEAN, s390) $(RM) $(header)
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl 
b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
index 7fa0d0a..72ecbb6 100755
--- a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
@@ -3,25 +3,23 @@
 #
 # Generate system call table for perf
 #
-#
-# Copyright IBM Corp. 2017
+# Copyright IBM Corp. 2017, 2018
 # Author(s):  Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
 #
 
-gcc=$1
-input=$2
+SYSCALL_TBL=$1
 
-if ! test -r $input; then
+if ! test -r $SYSCALL_TBL; then
echo "Could not read input file" >&2
exit 1
 fi
 
 create_table()
 {
-   local max_nr
+   local max_nr nr abi sc discard
 
echo 'static const char *syscalltbl_s390_64[] = {'
-   while read sc nr; do
+   while read nr abi sc discard; do
printf '\t[%d] = "%s",\n' $nr $sc
max_nr=$nr
done
@@ -29,8 +27,6 @@ create_table()
echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
 }
 
-
-$gcc -m64 -E -dM -x c  $input \
-   |sed -ne 's/^#define __NR_//p' \
-   |sort -t' ' -k2 -nu\
+grep -E "^[[:digit:]]+[[:space:]]+(common|64)" $SYSCALL_TBL\
+   |sort -k1 -n\
|create_table


[tip:perf/urgent] perf s390: Rework system call table creation by using syscall.tbl

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  690d22d9d4423b4522fb44a71145403eef2df834
Gitweb: https://git.kernel.org/tip/690d22d9d4423b4522fb44a71145403eef2df834
Author: Hendrik Brueckner 
AuthorDate: Thu, 8 Feb 2018 12:47:50 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 15 Feb 2018 10:06:08 -0300

perf s390: Rework system call table creation by using syscall.tbl

Recently, s390 uses a syscall.tbl input file to generate its system call
table and unistd uapi header files.  Hence, update mksyscalltbl to use
it as input to create the system table for perf.

Signed-off-by: Hendrik Brueckner 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: Thomas Richter 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-4-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-bdyhllhsq1zgxv2qx4m37...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/s390/Makefile| 10 +++---
 tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 18 +++---
 2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 48228de..dfa6e31 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -10,15 +10,19 @@ PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 
 out:= $(OUTPUT)arch/s390/include/generated/asm
 header := $(out)/syscalls_64.c
-sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h
-sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/
+syskrn := $(srctree)/arch/s390/kernel/syscalls/syscall.tbl
+sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls
+sysdef := $(sysprf)/syscall.tbl
 systbl := $(sysprf)/mksyscalltbl
 
 # Create output directory if not already present
 _dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
 
 $(header): $(sysdef) $(systbl)
-   $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@
+   @(test -d ../../kernel -a -d ../../tools -a -d ../perf && ( \
+(diff -B $(sysdef) $(syskrn) >/dev/null) \
+|| echo "Warning: Kernel ABI header at '$(sysdef)' differs from latest 
version at '$(syskrn)'" >&2 )) || true
+   $(Q)$(SHELL) '$(systbl)' $(sysdef) > $@
 
 clean::
$(call QUIET_CLEAN, s390) $(RM) $(header)
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl 
b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
index 7fa0d0a..72ecbb6 100755
--- a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
+++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
@@ -3,25 +3,23 @@
 #
 # Generate system call table for perf
 #
-#
-# Copyright IBM Corp. 2017
+# Copyright IBM Corp. 2017, 2018
 # Author(s):  Hendrik Brueckner 
 #
 
-gcc=$1
-input=$2
+SYSCALL_TBL=$1
 
-if ! test -r $input; then
+if ! test -r $SYSCALL_TBL; then
echo "Could not read input file" >&2
exit 1
 fi
 
 create_table()
 {
-   local max_nr
+   local max_nr nr abi sc discard
 
echo 'static const char *syscalltbl_s390_64[] = {'
-   while read sc nr; do
+   while read nr abi sc discard; do
printf '\t[%d] = "%s",\n' $nr $sc
max_nr=$nr
done
@@ -29,8 +27,6 @@ create_table()
echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
 }
 
-
-$gcc -m64 -E -dM -x c  $input \
-   |sed -ne 's/^#define __NR_//p' \
-   |sort -t' ' -k2 -nu\
+grep -E "^[[:digit:]]+[[:space:]]+(common|64)" $SYSCALL_TBL\
+   |sort -k1 -n\
|create_table


[tip:perf/urgent] perf s390: Grab a copy of arch/s390/kernel/syscall/syscall.tbl

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  baa676103037e0dd145bb905eb51bc0b2f48fd49
Gitweb: https://git.kernel.org/tip/baa676103037e0dd145bb905eb51bc0b2f48fd49
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 8 Feb 2018 12:47:49 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Thu, 15 Feb 2018 10:06:00 -0300

perf s390: Grab a copy of arch/s390/kernel/syscall/syscall.tbl

Grab a copy of the s390 system call table file introduced with commit
857f46bfb07f53dc112d69bdfb137cc5ec3da7c5 "s390/syscalls: add system call
table".

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-3-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-hpw7vdjp7g92ivgpddrp5...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 {arch/s390/kernel => tools/perf/arch/s390/entry}/syscalls/syscall.tbl | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/arch/s390/kernel/syscalls/syscall.tbl 
b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
similarity index 100%
copy from arch/s390/kernel/syscalls/syscall.tbl
copy to tools/perf/arch/s390/entry/syscalls/syscall.tbl


[tip:perf/urgent] perf s390: Grab a copy of arch/s390/kernel/syscall/syscall.tbl

2018-02-16 Thread tip-bot for Hendrik Brueckner
Commit-ID:  baa676103037e0dd145bb905eb51bc0b2f48fd49
Gitweb: https://git.kernel.org/tip/baa676103037e0dd145bb905eb51bc0b2f48fd49
Author: Hendrik Brueckner 
AuthorDate: Thu, 8 Feb 2018 12:47:49 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Thu, 15 Feb 2018 10:06:00 -0300

perf s390: Grab a copy of arch/s390/kernel/syscall/syscall.tbl

Grab a copy of the s390 system call table file introduced with commit
857f46bfb07f53dc112d69bdfb137cc5ec3da7c5 "s390/syscalls: add system call
table".

Signed-off-by: Hendrik Brueckner 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: Thomas Richter 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1518090470-2899-3-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-hpw7vdjp7g92ivgpddrp5...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 {arch/s390/kernel => tools/perf/arch/s390/entry}/syscalls/syscall.tbl | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/arch/s390/kernel/syscalls/syscall.tbl 
b/tools/perf/arch/s390/entry/syscalls/syscall.tbl
similarity index 100%
copy from arch/s390/kernel/syscalls/syscall.tbl
copy to tools/perf/arch/s390/entry/syscalls/syscall.tbl


Re: s390 unistd.h & perf

2018-02-05 Thread Hendrik Brueckner
Hi Arnaldo,

On Fri, Feb 02, 2018 at 01:23:22PM -0300, Arnaldo Carvalho de Melo wrote:
> 
>   I noticed, after fast forwarding my perf/urgent branch to
> torvalds/master, that this appears in my perf build:
> 
> Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/unistd.h' 
> differs from latest version at 'arch/s390/include/uapi/asm/unistd.h'
> 
>   Looking at the log for that file I noticed this cset:
> 
> 4381f9f12e79 ("s390/syscalls: use generated syscall_table.h and unistd.h 
> header files")
> 
>   Can you please take a look how this affects the syscall table
> generation process in tools/perf and how can we proceed to silence that
> warning, i.e. to update the copy we have in tools/?

I reworked the our system call table a bit to also have a text file containing
the system calls.  For this, I also have an update for perf.  Will post these
patches by end of this week.

Thanks and kind regards,
  Hendrik



Re: s390 unistd.h & perf

2018-02-05 Thread Hendrik Brueckner
Hi Arnaldo,

On Fri, Feb 02, 2018 at 01:23:22PM -0300, Arnaldo Carvalho de Melo wrote:
> 
>   I noticed, after fast forwarding my perf/urgent branch to
> torvalds/master, that this appears in my perf build:
> 
> Warning: Kernel ABI header at 'tools/arch/s390/include/uapi/asm/unistd.h' 
> differs from latest version at 'arch/s390/include/uapi/asm/unistd.h'
> 
>   Looking at the log for that file I noticed this cset:
> 
> 4381f9f12e79 ("s390/syscalls: use generated syscall_table.h and unistd.h 
> header files")
> 
>   Can you please take a look how this affects the syscall table
> generation process in tools/perf and how can we proceed to silence that
> warning, i.e. to update the copy we have in tools/?

I reworked the our system call table a bit to also have a text file containing
the system calls.  For this, I also have an update for perf.  Will post these
patches by end of this week.

Thanks and kind regards,
  Hendrik



[tip:perf/core] perf util: Introduce architecture specific errno/name mapping

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  0337cf74ccf2a43437bff2e23b278e4f2dc4c6e2
Gitweb: https://git.kernel.org/tip/0337cf74ccf2a43437bff2e23b278e4f2dc4c6e2
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Fri, 19 Jan 2018 09:56:15 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

perf util: Introduce architecture specific errno/name mapping

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 errno mapping is generated as part of the trace beautifiers and can
be used by including the trace/beauty/arch_errno_names.c file.  Then,
use arch_syscalls__strerrno() to look up an errno value to obtain the
errno name (e.g. ENOENT) for a particular architecture.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Suggested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-4-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-8zlsjnuoep2ww39aq5z41...@git.kernel.org
[ Make x86 be the first arch, most common, add newline to last line, fixing 
build on centos:5 ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Makefile.perf|  13 +++-
 tools/perf/trace/beauty/arch_errno_names.c  |   1 +
 tools/perf/trace/beauty/arch_errno_names.sh | 100 
 tools/perf/trace/beauty/beauty.h|   2 +
 4 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 9fdefd7..9a9b528 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -462,6 +462,13 @@ prctl_option_tbl := 
$(srctree)/tools/perf/trace/beauty/prctl_option.sh
 $(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
$(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
 
+arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
+arch_errno_hdr_dir := $(srctree)/tools
+arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
+
+$(arch_errno_name_array): $(arch_errno_tbl)
+   $(Q)$(SHELL) '$(arch_errno_tbl)' $(CC) $(arch_errno_hdr_dir) > $@
+
 all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) 
$(OTHER_PROGRAMS)
 
 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) 
$(LIBTRACEEVENT_DYNAMIC_LIST)
@@ -565,7 +572,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) \
+   $(arch_errno_name_array)
 
 $(OUTPUT)%.o: %.c prepare FORCE
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
@@ -847,7 +855,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)$(arch_errno_name_array)
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
 
 #
diff --git a/tools/perf/trace/beauty/arch_errno_names.c 
b/tools/perf/trace/beauty/arch_errno_names.c
new file mode 100644
index 000..ede031c
--- /dev/null
+++ b/tools/perf/trace/beauty/arch_errno_names.c
@@ -0,0 +1 @@
+#include "trace/beauty/generated/arch_errno_name_array.c"
diff --git a/tools/perf/trace/beauty/arch_errno_names.sh 
b/tools/perf/trace/beauty/arch_errno_names.sh
new file mode 100755
index 000..22c9fc9
--- /dev/null
+++ b/tools/perf/trace/beauty/arch_errno_names.sh
@@ -0,0 +1,100 @@
+#!/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 <brueck...@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 <
+
+EoHEADER
+
+# Create list of architectures and ignore those that 

[tip:perf/core] perf util: Introduce architecture specific errno/name mapping

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  0337cf74ccf2a43437bff2e23b278e4f2dc4c6e2
Gitweb: https://git.kernel.org/tip/0337cf74ccf2a43437bff2e23b278e4f2dc4c6e2
Author: Hendrik Brueckner 
AuthorDate: Fri, 19 Jan 2018 09:56:15 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

perf util: Introduce architecture specific errno/name mapping

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 errno mapping is generated as part of the trace beautifiers and can
be used by including the trace/beauty/arch_errno_names.c file.  Then,
use arch_syscalls__strerrno() to look up an errno value to obtain the
errno name (e.g. ENOENT) for a particular architecture.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Suggested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-4-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-8zlsjnuoep2ww39aq5z41...@git.kernel.org
[ Make x86 be the first arch, most common, add newline to last line, fixing 
build on centos:5 ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.perf|  13 +++-
 tools/perf/trace/beauty/arch_errno_names.c  |   1 +
 tools/perf/trace/beauty/arch_errno_names.sh | 100 
 tools/perf/trace/beauty/beauty.h|   2 +
 4 files changed, 114 insertions(+), 2 deletions(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 9fdefd7..9a9b528 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -462,6 +462,13 @@ prctl_option_tbl := 
$(srctree)/tools/perf/trace/beauty/prctl_option.sh
 $(prctl_option_array): $(prctl_hdr_dir)/prctl.h $(prctl_option_tbl)
$(Q)$(SHELL) '$(prctl_option_tbl)' $(prctl_hdr_dir) > $@
 
+arch_errno_name_array := $(beauty_outdir)/arch_errno_name_array.c
+arch_errno_hdr_dir := $(srctree)/tools
+arch_errno_tbl := $(srctree)/tools/perf/trace/beauty/arch_errno_names.sh
+
+$(arch_errno_name_array): $(arch_errno_tbl)
+   $(Q)$(SHELL) '$(arch_errno_tbl)' $(CC) $(arch_errno_hdr_dir) > $@
+
 all: shell_compatibility_test $(ALL_PROGRAMS) $(LANG_BINDINGS) 
$(OTHER_PROGRAMS)
 
 $(OUTPUT)python/perf.so: $(PYTHON_EXT_SRCS) $(PYTHON_EXT_DEPS) 
$(LIBTRACEEVENT_DYNAMIC_LIST)
@@ -565,7 +572,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) \
+   $(arch_errno_name_array)
 
 $(OUTPUT)%.o: %.c prepare FORCE
$(Q)$(MAKE) -f $(srctree)/tools/build/Makefile.build dir=$(build-dir) $@
@@ -847,7 +855,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)$(arch_errno_name_array)
$(QUIET_SUBDIR0)Documentation $(QUIET_SUBDIR1) clean
 
 #
diff --git a/tools/perf/trace/beauty/arch_errno_names.c 
b/tools/perf/trace/beauty/arch_errno_names.c
new file mode 100644
index 000..ede031c
--- /dev/null
+++ b/tools/perf/trace/beauty/arch_errno_names.c
@@ -0,0 +1 @@
+#include "trace/beauty/generated/arch_errno_name_array.c"
diff --git a/tools/perf/trace/beauty/arch_errno_names.sh 
b/tools/perf/trace/beauty/arch_errno_names.sh
new file mode 100755
index 000..22c9fc9
--- /dev/null
+++ b/tools/perf/trace/beauty/arch_errno_names.sh
@@ -0,0 +1,100 @@
+#!/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 
+
+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 <
+
+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" | grep -v x86 | sort); do
+   test -d arch/$arch && archlist="$archlist $arch"
+don

[tip:perf/core] perf trace: Remove audit-libs dependency if syscall tables are present

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  b3fa38963a6a95bef888350ff3125182462c523c
Gitweb: https://git.kernel.org/tip/b3fa38963a6a95bef888350ff3125182462c523c
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Fri, 19 Jan 2018 09:56:17 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 23 Jan 2018 09:51:38 -0300

perf trace: Remove audit-libs dependency if syscall tables are present

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

Committer notes:

Its not enough to hook into the NO_LIBAUDIT makefile block, we need to
define a CONFIG_TRACE that gets selected by both architectures
generating the syscall tables from the kernel headers and from detecting
the availability of libaudit.

With that in place we will not link against libaudit even if the
necessary files are available for that, in fact we will not even try to
detect its availability, speeding up a bit the feature detection phase.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-6-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-j68lub6ipm8apvy52vd3l...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Build|  4 ++--
 tools/perf/Makefile.config  | 20 
 tools/perf/builtin-help.c   |  2 +-
 tools/perf/perf.c   |  4 ++--
 tools/perf/util/Build   |  2 +-
 tools/perf/util/generate-cmdlist.sh |  2 +-
 6 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index b48ca40..e5232d5 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -25,7 +25,7 @@ perf-y += builtin-data.o
 perf-y += builtin-version.o
 perf-y += builtin-c2c.o
 
-perf-$(CONFIG_AUDIT) += builtin-trace.o
+perf-$(CONFIG_TRACE) += builtin-trace.o
 perf-$(CONFIG_LIBELF) += builtin-probe.o
 
 perf-y += bench/
@@ -50,6 +50,6 @@ libperf-y += util/
 libperf-y += arch/
 libperf-y += ui/
 libperf-y += scripts/
-libperf-$(CONFIG_AUDIT) += trace/beauty/
+libperf-$(CONFIG_TRACE) += trace/beauty/
 
 gtk-y += ui/gtk/
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 92265b3..a042ccc 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -531,14 +531,18 @@ ifndef NO_LIBUNWIND
   EXTLIBS += $(EXTLIBS_LIBUNWIND)
 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
-  else
-CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
-EXTLIBS += -laudit
-$(call detected,CONFIG_AUDIT)
+ifeq ($(NO_SYSCALL_TABLE),0)
+  $(call detected,CONFIG_TRACE)
+else
+  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
+else
+  CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
+  EXTLIBS += -laudit
+  $(call detected,CONFIG_TRACE)
+endif
   endif
 endif
 
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 @@ static struct cmd_struct commands[] = {
{ "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/Build b/tools/perf/util/Build
index 7c6a8b4..4eef0c2 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -44,7 +44,7 @@ libperf-y += mac

[tip:perf/core] perf trace: Remove audit-libs dependency if syscall tables are present

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  b3fa38963a6a95bef888350ff3125182462c523c
Gitweb: https://git.kernel.org/tip/b3fa38963a6a95bef888350ff3125182462c523c
Author: Hendrik Brueckner 
AuthorDate: Fri, 19 Jan 2018 09:56:17 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Jan 2018 09:51:38 -0300

perf trace: Remove audit-libs dependency if syscall tables are present

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

Committer notes:

Its not enough to hook into the NO_LIBAUDIT makefile block, we need to
define a CONFIG_TRACE that gets selected by both architectures
generating the syscall tables from the kernel headers and from detecting
the availability of libaudit.

With that in place we will not link against libaudit even if the
necessary files are available for that, in fact we will not even try to
detect its availability, speeding up a bit the feature detection phase.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-6-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-j68lub6ipm8apvy52vd3l...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Build|  4 ++--
 tools/perf/Makefile.config  | 20 
 tools/perf/builtin-help.c   |  2 +-
 tools/perf/perf.c   |  4 ++--
 tools/perf/util/Build   |  2 +-
 tools/perf/util/generate-cmdlist.sh |  2 +-
 6 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/tools/perf/Build b/tools/perf/Build
index b48ca40..e5232d5 100644
--- a/tools/perf/Build
+++ b/tools/perf/Build
@@ -25,7 +25,7 @@ perf-y += builtin-data.o
 perf-y += builtin-version.o
 perf-y += builtin-c2c.o
 
-perf-$(CONFIG_AUDIT) += builtin-trace.o
+perf-$(CONFIG_TRACE) += builtin-trace.o
 perf-$(CONFIG_LIBELF) += builtin-probe.o
 
 perf-y += bench/
@@ -50,6 +50,6 @@ libperf-y += util/
 libperf-y += arch/
 libperf-y += ui/
 libperf-y += scripts/
-libperf-$(CONFIG_AUDIT) += trace/beauty/
+libperf-$(CONFIG_TRACE) += trace/beauty/
 
 gtk-y += ui/gtk/
diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 92265b3..a042ccc 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -531,14 +531,18 @@ ifndef NO_LIBUNWIND
   EXTLIBS += $(EXTLIBS_LIBUNWIND)
 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
-  else
-CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
-EXTLIBS += -laudit
-$(call detected,CONFIG_AUDIT)
+ifeq ($(NO_SYSCALL_TABLE),0)
+  $(call detected,CONFIG_TRACE)
+else
+  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
+else
+  CFLAGS += -DHAVE_LIBAUDIT_SUPPORT
+  EXTLIBS += -laudit
+  $(call detected,CONFIG_TRACE)
+endif
   endif
 endif
 
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 @@ static struct cmd_struct commands[] = {
{ "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/Build b/tools/perf/util/Build
index 7c6a8b4..4eef0c2 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -44,7 +44,7 @@ libperf-y += machine.o
 libperf-y += map.o
 libperf-y += pstack.o
 libperf-y += session.o
-libperf-$(CONFIG_AUDIT) += syscalltbl.o
+libperf-$(CONFIG_TRACE) += syscalltbl.o
 libperf-y += ordered-events.o
 libperf-y += namespaces.o
 libper

[tip:perf/core] tools include arch: Grab a copy of errno.h for arch's supported by perf

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  95f28190aa012b18eab14799b905b6db3cf31529
Gitweb: https://git.kernel.org/tip/95f28190aa012b18eab14799b905b6db3cf31529
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Fri, 19 Jan 2018 09:56:13 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

tools include arch: Grab a copy of errno.h for arch's supported by perf

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 <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-73azjhrzpjsskwi129020...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 {arch => tools/arch}/alpha/include/uapi/asm/errno.h   | 0
 {arch => tools/arch}/mips/include/asm/errno.h | 0
 {arch => tools/arch}/mips/include/uapi/asm/errno.h| 0
 {arch => tools/arch}/parisc/include/uapi/asm/errno.h  | 0
 {arch => tools/arch}/powerpc/include/uapi/asm/errno.h | 0
 {arch => tools/arch}/sparc/include/uapi/asm/errno.h   | 0
 {arch => tools/arch}/x86/include/uapi/asm/errno.h | 0
 tools/perf/check-headers.sh   | 7 +++
 8 files changed, 7 insertions(+)

diff --git a/arch/alpha/include/uapi/asm/errno.h 
b/tools/arch/alpha/include/uapi/asm/errno.h
similarity index 100%
copy from arch/alpha/include/uapi/asm/errno.h
copy to tools/arch/alpha/include/uapi/asm/errno.h
diff --git a/arch/mips/include/asm/errno.h b/tools/arch/mips/include/asm/errno.h
similarity index 100%
copy from arch/mips/include/asm/errno.h
copy to tools/arch/mips/include/asm/errno.h
diff --git a/arch/mips/include/uapi/asm/errno.h 
b/tools/arch/mips/include/uapi/asm/errno.h
similarity index 100%
copy from arch/mips/include/uapi/asm/errno.h
copy to tools/arch/mips/include/uapi/asm/errno.h
diff --git a/arch/parisc/include/uapi/asm/errno.h 
b/tools/arch/parisc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/parisc/include/uapi/asm/errno.h
copy to tools/arch/parisc/include/uapi/asm/errno.h
diff --git a/arch/powerpc/include/uapi/asm/errno.h 
b/tools/arch/powerpc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/powerpc/include/uapi/asm/errno.h
copy to tools/arch/powerpc/include/uapi/asm/errno.h
diff --git a/arch/sparc/include/uapi/asm/errno.h 
b/tools/arch/sparc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/sparc/include/uapi/asm/errno.h
copy to tools/arch/sparc/include/uapi/asm/errno.h
diff --git a/arch/x86/include/uapi/asm/errno.h 
b/tools/arch/x86/include/uapi/asm/errno.h
similarity index 100%
copy from arch/x86/include/uapi/asm/errno.h
copy to tools/arch/x86/include/uapi/asm/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


[tip:perf/core] perf trace: Obtain errno strings by using arch_syscalls__strerrno()

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  092bd3cd7169085b09e4a5307de95e461d0581d7
Gitweb: https://git.kernel.org/tip/092bd3cd7169085b09e4a5307de95e461d0581d7
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Fri, 19 Jan 2018 09:56:16 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 23 Jan 2018 09:51:38 -0300

perf trace: Obtain errno strings by using arch_syscalls__strerrno()

Replace the errno_to_name() from the audit-libs with the newly
introduced arch_syscalls__strerrno() 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 <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-5-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-xjvoqzhwmu4wn4kl9ng11...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@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 531d43b..7dece5e 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 
@@ -45,14 +46,12 @@
 
 #include 
 #include 
-#include  /* FIXME: Still needed for audit_errno_to_name */
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -545,6 +544,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char 
*bf, size_t size,
  { .scnprintf  = SCA_STRARRAY, \
.parm   = __##array, }
 
+#include "trace/beauty/arch_errno_names.c"
 #include "trace/beauty/eventfd.c"
 #include "trace/beauty/flock.c"
 #include "trace/beauty/futex_op.c"
@@ -1660,6 +1660,14 @@ static int trace__fprintf_callchain(struct trace *trace, 
struct perf_sample *sam
return sample__fprintf_callchain(sample, 38, print_opts, 
_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_syscalls__strerrno(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 @@ signed_print:
 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);
}


[tip:perf/core] tools include arch: Grab a copy of errno.h for arch's supported by perf

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  95f28190aa012b18eab14799b905b6db3cf31529
Gitweb: https://git.kernel.org/tip/95f28190aa012b18eab14799b905b6db3cf31529
Author: Hendrik Brueckner 
AuthorDate: Fri, 19 Jan 2018 09:56:13 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

tools include arch: Grab a copy of errno.h for arch's supported by perf

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 
Reviewed-by: Thomas Richter 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-73azjhrzpjsskwi129020...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 {arch => tools/arch}/alpha/include/uapi/asm/errno.h   | 0
 {arch => tools/arch}/mips/include/asm/errno.h | 0
 {arch => tools/arch}/mips/include/uapi/asm/errno.h| 0
 {arch => tools/arch}/parisc/include/uapi/asm/errno.h  | 0
 {arch => tools/arch}/powerpc/include/uapi/asm/errno.h | 0
 {arch => tools/arch}/sparc/include/uapi/asm/errno.h   | 0
 {arch => tools/arch}/x86/include/uapi/asm/errno.h | 0
 tools/perf/check-headers.sh   | 7 +++
 8 files changed, 7 insertions(+)

diff --git a/arch/alpha/include/uapi/asm/errno.h 
b/tools/arch/alpha/include/uapi/asm/errno.h
similarity index 100%
copy from arch/alpha/include/uapi/asm/errno.h
copy to tools/arch/alpha/include/uapi/asm/errno.h
diff --git a/arch/mips/include/asm/errno.h b/tools/arch/mips/include/asm/errno.h
similarity index 100%
copy from arch/mips/include/asm/errno.h
copy to tools/arch/mips/include/asm/errno.h
diff --git a/arch/mips/include/uapi/asm/errno.h 
b/tools/arch/mips/include/uapi/asm/errno.h
similarity index 100%
copy from arch/mips/include/uapi/asm/errno.h
copy to tools/arch/mips/include/uapi/asm/errno.h
diff --git a/arch/parisc/include/uapi/asm/errno.h 
b/tools/arch/parisc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/parisc/include/uapi/asm/errno.h
copy to tools/arch/parisc/include/uapi/asm/errno.h
diff --git a/arch/powerpc/include/uapi/asm/errno.h 
b/tools/arch/powerpc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/powerpc/include/uapi/asm/errno.h
copy to tools/arch/powerpc/include/uapi/asm/errno.h
diff --git a/arch/sparc/include/uapi/asm/errno.h 
b/tools/arch/sparc/include/uapi/asm/errno.h
similarity index 100%
copy from arch/sparc/include/uapi/asm/errno.h
copy to tools/arch/sparc/include/uapi/asm/errno.h
diff --git a/arch/x86/include/uapi/asm/errno.h 
b/tools/arch/x86/include/uapi/asm/errno.h
similarity index 100%
copy from arch/x86/include/uapi/asm/errno.h
copy to tools/arch/x86/include/uapi/asm/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


[tip:perf/core] perf trace: Obtain errno strings by using arch_syscalls__strerrno()

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  092bd3cd7169085b09e4a5307de95e461d0581d7
Gitweb: https://git.kernel.org/tip/092bd3cd7169085b09e4a5307de95e461d0581d7
Author: Hendrik Brueckner 
AuthorDate: Fri, 19 Jan 2018 09:56:16 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Jan 2018 09:51:38 -0300

perf trace: Obtain errno strings by using arch_syscalls__strerrno()

Replace the errno_to_name() from the audit-libs with the newly
introduced arch_syscalls__strerrno() 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 
Reviewed-by: Thomas Richter 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-5-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-xjvoqzhwmu4wn4kl9ng11...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 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 531d43b..7dece5e 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 
@@ -45,14 +46,12 @@
 
 #include 
 #include 
-#include  /* FIXME: Still needed for audit_errno_to_name */
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -545,6 +544,7 @@ static size_t syscall_arg__scnprintf_getrandom_flags(char 
*bf, size_t size,
  { .scnprintf  = SCA_STRARRAY, \
.parm   = __##array, }
 
+#include "trace/beauty/arch_errno_names.c"
 #include "trace/beauty/eventfd.c"
 #include "trace/beauty/flock.c"
 #include "trace/beauty/futex_op.c"
@@ -1660,6 +1660,14 @@ static int trace__fprintf_callchain(struct trace *trace, 
struct perf_sample *sam
return sample__fprintf_callchain(sample, 38, print_opts, 
_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_syscalls__strerrno(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 @@ signed_print:
 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);
}


[tip:perf/core] tools include asm-generic: Grab errno.h and errno-base.h

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  28b8f954003e59dbf0b56be6df0d81f83e64f36b
Gitweb: https://git.kernel.org/tip/28b8f954003e59dbf0b56be6df0d81f83e64f36b
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Fri, 19 Jan 2018 09:56:14 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

tools include asm-generic: Grab errno.h and errno-base.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 <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-3-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-q13ystrw4sjz4wyvd3654...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 {include => tools/include}/uapi/asm-generic/errno-base.h | 0
 {include => tools/include}/uapi/asm-generic/errno.h  | 0
 tools/perf/check-headers.sh  | 2 ++
 3 files changed, 2 insertions(+)

diff --git a/include/uapi/asm-generic/errno-base.h 
b/tools/include/uapi/asm-generic/errno-base.h
similarity index 100%
copy from include/uapi/asm-generic/errno-base.h
copy to tools/include/uapi/asm-generic/errno-base.h
diff --git a/include/uapi/asm-generic/errno.h 
b/tools/include/uapi/asm-generic/errno.h
similarity index 100%
copy from include/uapi/asm-generic/errno.h
copy to tools/include/uapi/asm-generic/errno.h
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
 '


[tip:perf/core] tools include asm-generic: Grab errno.h and errno-base.h

2018-01-24 Thread tip-bot for Hendrik Brueckner
Commit-ID:  28b8f954003e59dbf0b56be6df0d81f83e64f36b
Gitweb: https://git.kernel.org/tip/28b8f954003e59dbf0b56be6df0d81f83e64f36b
Author: Hendrik Brueckner 
AuthorDate: Fri, 19 Jan 2018 09:56:14 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 23 Jan 2018 09:51:37 -0300

tools include asm-generic: Grab errno.h and errno-base.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 
Reviewed-by: Thomas Richter 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1516352177-11106-3-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-q13ystrw4sjz4wyvd3654...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 {include => tools/include}/uapi/asm-generic/errno-base.h | 0
 {include => tools/include}/uapi/asm-generic/errno.h  | 0
 tools/perf/check-headers.sh  | 2 ++
 3 files changed, 2 insertions(+)

diff --git a/include/uapi/asm-generic/errno-base.h 
b/tools/include/uapi/asm-generic/errno-base.h
similarity index 100%
copy from include/uapi/asm-generic/errno-base.h
copy to tools/include/uapi/asm-generic/errno-base.h
diff --git a/include/uapi/asm-generic/errno.h 
b/tools/include/uapi/asm-generic/errno.h
similarity index 100%
copy from include/uapi/asm-generic/errno.h
copy to tools/include/uapi/asm-generic/errno.h
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
 '


Re: [PATCH v2] perf trace: Fix missing handling of --call-graph dwarf

2018-01-15 Thread Hendrik Brueckner
On Mon, Jan 15, 2018 at 10:57:52AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jan 15, 2018 at 01:31:00PM +0100, Thomas-Mich Richter escreveu:
> > On 01/12/2018 09:02 PM, Arnaldo Carvalho de Melo wrote:
> > > Em Fri, Jan 12, 2018 at 01:47:06PM -0300, Arnaldo Carvalho de Melo 
> > > escreveu:
> > >
> [root@jouet ~]# perf trace --no-syscalls --call-graph fp --max-stack 3 -e 
> probe_libc:inet_pton ping -6 -c 1 ::1
> perf trace --no-syscalls --call-graph dwarf --max-stack 3 -e 
> probe_libc:inet_pton ping -6 -c 1 ::1
> PING ::1(::1) 56 data bytes
> 64 bytes from ::1: icmp_seq=1 ttl=64 time=0.080 ms
> 
> --- ::1 ping statistics ---
> 1 packets transmitted, 1 received, 0% packet loss, time 0ms
> rtt min/avg/max/mdev = 0.080/0.080/0.080/0.000 ms
>  0.000 probe_libc:inet_pton:(7f33e9647350))
>__inet_pton (inlined)
>gaih_inet.constprop.7 
> (/usr/lib64/libc-2.26.so)
>__GI_getaddrinfo (inlined)
> [root@jouet ~]# 
> 
> And here we see a difference in the fp and DWARF unwinders, have to dig
> deeper into this one, perhaps using the DWARF one we have more info and
> then can end up with inlines instead of what it calls.

DWARF includes information about which functions are inlined.  The ORC
unwinder data is based on the analysis of the generated instructions
(created with the objtool).  Hence, it does no (and no longer) know whether
a bunch of instructions are originally part of a function or inlined.

Thanks and kind regards,
  Hendrik



Re: [PATCH v2] perf trace: Fix missing handling of --call-graph dwarf

2018-01-15 Thread Hendrik Brueckner
On Mon, Jan 15, 2018 at 10:57:52AM -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jan 15, 2018 at 01:31:00PM +0100, Thomas-Mich Richter escreveu:
> > On 01/12/2018 09:02 PM, Arnaldo Carvalho de Melo wrote:
> > > Em Fri, Jan 12, 2018 at 01:47:06PM -0300, Arnaldo Carvalho de Melo 
> > > escreveu:
> > >
> [root@jouet ~]# perf trace --no-syscalls --call-graph fp --max-stack 3 -e 
> probe_libc:inet_pton ping -6 -c 1 ::1
> perf trace --no-syscalls --call-graph dwarf --max-stack 3 -e 
> probe_libc:inet_pton ping -6 -c 1 ::1
> PING ::1(::1) 56 data bytes
> 64 bytes from ::1: icmp_seq=1 ttl=64 time=0.080 ms
> 
> --- ::1 ping statistics ---
> 1 packets transmitted, 1 received, 0% packet loss, time 0ms
> rtt min/avg/max/mdev = 0.080/0.080/0.080/0.000 ms
>  0.000 probe_libc:inet_pton:(7f33e9647350))
>__inet_pton (inlined)
>gaih_inet.constprop.7 
> (/usr/lib64/libc-2.26.so)
>__GI_getaddrinfo (inlined)
> [root@jouet ~]# 
> 
> And here we see a difference in the fp and DWARF unwinders, have to dig
> deeper into this one, perhaps using the DWARF one we have more info and
> then can end up with inlines instead of what it calls.

DWARF includes information about which functions are inlined.  The ORC
unwinder data is based on the analysis of the generated instructions
(created with the objtool).  Hence, it does no (and no longer) know whether
a bunch of instructions are originally part of a function or inlined.

Thanks and kind regards,
  Hendrik



[tip:perf/core] perf s390: Always build with -fPIC

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  a9a3f1d18a6c9ccf89728e23474645aa91e2f4f1
Gitweb: https://git.kernel.org/tip/a9a3f1d18a6c9ccf89728e23474645aa91e2f4f1
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Wed, 13 Dec 2017 17:46:54 -0300
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 27 Dec 2017 12:15:57 -0300

perf s390: Always build with -fPIC

On s390, object files must be compiled with position-indepedent code in
order to be incrementally linked or linked to shared libraries.

Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
is built properly.

Reported-by: Jonathan Hermann <jonathan.herm...@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: linux s390 list <linux-s...@vger.kernel.org>
Link: https://lkml.kernel.org/r/20171207080951.gc4...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index eb6bd99..f050f38 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -58,7 +58,7 @@ endif
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
   NO_SYSCALL_TABLE := 0
-  CFLAGS += -I$(OUTPUT)arch/s390/include/generated
+  CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
 endif
 
 ifeq ($(NO_PERF_REGS),0)


[tip:perf/core] perf s390: Always build with -fPIC

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  a9a3f1d18a6c9ccf89728e23474645aa91e2f4f1
Gitweb: https://git.kernel.org/tip/a9a3f1d18a6c9ccf89728e23474645aa91e2f4f1
Author: Hendrik Brueckner 
AuthorDate: Wed, 13 Dec 2017 17:46:54 -0300
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Dec 2017 12:15:57 -0300

perf s390: Always build with -fPIC

On s390, object files must be compiled with position-indepedent code in
order to be incrementally linked or linked to shared libraries.

Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
is built properly.

Reported-by: Jonathan Hermann 
Signed-off-by: Hendrik Brueckner 
Cc: Heiko Carstens 
Cc: Martin Schwidefsky 
Cc: Thomas Richter 
Cc: linux s390 list 
Link: https://lkml.kernel.org/r/20171207080951.gc4...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.config | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index eb6bd99..f050f38 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -58,7 +58,7 @@ endif
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
   NO_SYSCALL_TABLE := 0
-  CFLAGS += -I$(OUTPUT)arch/s390/include/generated
+  CFLAGS += -fPIC -I$(OUTPUT)arch/s390/include/generated
 endif
 
 ifeq ($(NO_PERF_REGS),0)


[tip:perf/core] perf trace: Use generated syscall table on s390 too

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  901bb0280b60782603e999a6c1e30ddfe1c7b0fb
Gitweb: https://git.kernel.org/tip/901bb0280b60782603e999a6c1e30ddfe1c7b0fb
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 27 Dec 2017 12:15:50 -0300

perf trace: Use generated syscall table on s390 too

This should speed up accessing new system calls introduced with the
kernel rather than waiting for libaudit updates to include them.

It also enables users to specify wildcards, for example, perf trace -e
'open*', just like was already possible on x86.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-htplh3nbrivi7g3cffbh4...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Makefile.config   | 10 +-
 tools/perf/util/syscalltbl.c |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 79b117a..6f73c23 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -22,6 +22,7 @@ include $(srctree)/tools/scripts/Makefile.arch
 $(call detected_var,SRCARCH)
 
 NO_PERF_REGS := 1
+NO_SYSCALL_TABLE := 1
 
 # Additional ARCH settings for ppc
 ifeq ($(SRCARCH),powerpc)
@@ -33,7 +34,8 @@ endif
 ifeq ($(SRCARCH),x86)
   $(call detected,CONFIG_X86)
   ifeq (${IS_64_BIT}, 1)
-CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE 
-I$(OUTPUT)arch/x86/include/generated
+NO_SYSCALL_TABLE := 0
+CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S 
../../arch/x86/lib/memset_64.S
 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
 $(call detected,CONFIG_X86_64)
@@ -56,12 +58,18 @@ endif
 
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
+  NO_SYSCALL_TABLE := 0
+  CFLAGS += -I$(OUTPUT)arch/s390/include/generated
 endif
 
 ifeq ($(NO_PERF_REGS),0)
   $(call detected,CONFIG_PERF_REGS)
 endif
 
+ifneq ($(NO_SYSCALL_TABLE),1)
+  CFLAGS += -DHAVE_SYSCALL_TABLE
+endif
+
 # So far there's only x86 and arm libdw unwind support merged in perf.
 # Disable it on all other architectures in case libdw unwind
 # support is detected in system. Add supported architectures
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 6eea7cf..303bdb8 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -26,6 +26,10 @@
 #include 
 const int syscalltbl_native_max_id = SYSCALLTBL_x86_64_MAX_ID;
 static const char **syscalltbl_native = syscalltbl_x86_64;
+#elif defined(__s390x__)
+#include 
+const int syscalltbl_native_max_id = SYSCALLTBL_S390_64_MAX_ID;
+static const char **syscalltbl_native = syscalltbl_s390_64;
 #endif
 
 struct syscall {


[tip:perf/core] perf trace: Use generated syscall table on s390 too

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  901bb0280b60782603e999a6c1e30ddfe1c7b0fb
Gitweb: https://git.kernel.org/tip/901bb0280b60782603e999a6c1e30ddfe1c7b0fb
Author: Hendrik Brueckner 
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Dec 2017 12:15:50 -0300

perf trace: Use generated syscall table on s390 too

This should speed up accessing new system calls introduced with the
kernel rather than waiting for libaudit updates to include them.

It also enables users to specify wildcards, for example, perf trace -e
'open*', just like was already possible on x86.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-htplh3nbrivi7g3cffbh4...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.config   | 10 +-
 tools/perf/util/syscalltbl.c |  4 
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 79b117a..6f73c23 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -22,6 +22,7 @@ include $(srctree)/tools/scripts/Makefile.arch
 $(call detected_var,SRCARCH)
 
 NO_PERF_REGS := 1
+NO_SYSCALL_TABLE := 1
 
 # Additional ARCH settings for ppc
 ifeq ($(SRCARCH),powerpc)
@@ -33,7 +34,8 @@ endif
 ifeq ($(SRCARCH),x86)
   $(call detected,CONFIG_X86)
   ifeq (${IS_64_BIT}, 1)
-CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -DHAVE_SYSCALL_TABLE 
-I$(OUTPUT)arch/x86/include/generated
+NO_SYSCALL_TABLE := 0
+CFLAGS += -DHAVE_ARCH_X86_64_SUPPORT -I$(OUTPUT)arch/x86/include/generated
 ARCH_INCLUDE = ../../arch/x86/lib/memcpy_64.S 
../../arch/x86/lib/memset_64.S
 LIBUNWIND_LIBS = -lunwind-x86_64 -lunwind -llzma
 $(call detected,CONFIG_X86_64)
@@ -56,12 +58,18 @@ endif
 
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
+  NO_SYSCALL_TABLE := 0
+  CFLAGS += -I$(OUTPUT)arch/s390/include/generated
 endif
 
 ifeq ($(NO_PERF_REGS),0)
   $(call detected,CONFIG_PERF_REGS)
 endif
 
+ifneq ($(NO_SYSCALL_TABLE),1)
+  CFLAGS += -DHAVE_SYSCALL_TABLE
+endif
+
 # So far there's only x86 and arm libdw unwind support merged in perf.
 # Disable it on all other architectures in case libdw unwind
 # support is detected in system. Add supported architectures
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 6eea7cf..303bdb8 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -26,6 +26,10 @@
 #include 
 const int syscalltbl_native_max_id = SYSCALLTBL_x86_64_MAX_ID;
 static const char **syscalltbl_native = syscalltbl_x86_64;
+#elif defined(__s390x__)
+#include 
+const int syscalltbl_native_max_id = SYSCALLTBL_S390_64_MAX_ID;
+static const char **syscalltbl_native = syscalltbl_s390_64;
 #endif
 
 struct syscall {


[tip:perf/core] perf s390: Generate system call table from asm/unistd.h

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  164a747f1ac2380c582988d2a4d9a9af13f8e644
Gitweb: https://git.kernel.org/tip/164a747f1ac2380c582988d2a4d9a9af13f8e644
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 27 Dec 2017 12:15:50 -0300

perf s390: Generate system call table from asm/unistd.h

This should speed up accessing new system calls introduced with
the kernel rather than waiting for libaudit updates to include
them.

Committer testing:

  $ rm -rf /tmp/build/perf
  $ mkdir /tmp/build/perf
  $ make srctree=/home/acme/git/perf -C tools/perf/arch/s390 
OUTPUT=/tmp/build/perf/ archheaders
  make: Entering directory '/home/acme/git/perf/tools/perf/arch/s390'
  /bin/sh 
'/home/acme/git/perf/tools/perf/arch/s390/entry/syscalls//mksyscalltbl' 'cc' 
/home/acme/git/perf/tools/arch/s390/include/uapi/asm/unistd.h > 
/tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
  make: Leaving directory '/home/acme/git/perf/tools/perf/arch/s390'
  $ head -5 /tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
  static const char *syscalltbl_s390_64[] = {
[1] = "exit",
[2] = "fork",
[3] = "read",
[4] = "write",
  $ tail -5 /tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
[378] = "s390_guarded_storage",
[379] = "statx",
[380] = "s390_sthyi",
  };
  #define SYSCALLTBL_S390_64_MAX_ID 380
  $

Now to plug this into 'perf trace' proper.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Tested-by: Arnaldo Carvalho de Melo <a...@redhat.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-h5km60rdg3rqxvsys85q5...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/arch/s390/Makefile| 21 ++
 tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 36 
 2 files changed, 57 insertions(+)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 09ba923..48228de 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -3,3 +3,24 @@ PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+
+#
+# Syscall table generation for perf
+#
+
+out:= $(OUTPUT)arch/s390/include/generated/asm
+header := $(out)/syscalls_64.c
+sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h
+sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/
+systbl := $(sysprf)/mksyscalltbl
+
+# Create output directory if not already present
+_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+$(header): $(sysdef) $(systbl)
+   $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@
+
+clean::
+   $(call QUIET_CLEAN, s390) $(RM) $(header)
+
+archheaders: $(header)
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl 
b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
new file mode 100755
index 000..7fa0d0a
--- /dev/null
+++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
@@ -0,0 +1,36 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Generate system call table for perf
+#
+#
+# Copyright IBM Corp. 2017
+# Author(s):  Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
+#
+
+gcc=$1
+input=$2
+
+if ! test -r $input; then
+   echo "Could not read input file" >&2
+   exit 1
+fi
+
+create_table()
+{
+   local max_nr
+
+   echo 'static const char *syscalltbl_s390_64[] = {'
+   while read sc nr; do
+   printf '\t[%d] = "%s",\n' $nr $sc
+   max_nr=$nr
+   done
+   echo '};'
+   echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
+}
+
+
+$gcc -m64 -E -dM -x c  $input \
+   |sed -ne 's/^#define __NR_//p' \
+   |sort -t' ' -k2 -nu\
+   |create_table


[tip:perf/core] perf s390: Generate system call table from asm/unistd.h

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  164a747f1ac2380c582988d2a4d9a9af13f8e644
Gitweb: https://git.kernel.org/tip/164a747f1ac2380c582988d2a4d9a9af13f8e644
Author: Hendrik Brueckner 
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Dec 2017 12:15:50 -0300

perf s390: Generate system call table from asm/unistd.h

This should speed up accessing new system calls introduced with
the kernel rather than waiting for libaudit updates to include
them.

Committer testing:

  $ rm -rf /tmp/build/perf
  $ mkdir /tmp/build/perf
  $ make srctree=/home/acme/git/perf -C tools/perf/arch/s390 
OUTPUT=/tmp/build/perf/ archheaders
  make: Entering directory '/home/acme/git/perf/tools/perf/arch/s390'
  /bin/sh 
'/home/acme/git/perf/tools/perf/arch/s390/entry/syscalls//mksyscalltbl' 'cc' 
/home/acme/git/perf/tools/arch/s390/include/uapi/asm/unistd.h > 
/tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
  make: Leaving directory '/home/acme/git/perf/tools/perf/arch/s390'
  $ head -5 /tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
  static const char *syscalltbl_s390_64[] = {
[1] = "exit",
[2] = "fork",
[3] = "read",
[4] = "write",
  $ tail -5 /tmp/build/perf/arch/s390/include/generated/asm/syscalls_64.c
[378] = "s390_guarded_storage",
[379] = "statx",
[380] = "s390_sthyi",
  };
  #define SYSCALLTBL_S390_64_MAX_ID 380
  $

Now to plug this into 'perf trace' proper.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Tested-by: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-h5km60rdg3rqxvsys85q5...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/s390/Makefile| 21 ++
 tools/perf/arch/s390/entry/syscalls/mksyscalltbl | 36 
 2 files changed, 57 insertions(+)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 09ba923..48228de 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -3,3 +3,24 @@ PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
+
+#
+# Syscall table generation for perf
+#
+
+out:= $(OUTPUT)arch/s390/include/generated/asm
+header := $(out)/syscalls_64.c
+sysdef := $(srctree)/tools/arch/s390/include/uapi/asm/unistd.h
+sysprf := $(srctree)/tools/perf/arch/s390/entry/syscalls/
+systbl := $(sysprf)/mksyscalltbl
+
+# Create output directory if not already present
+_dummy := $(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+$(header): $(sysdef) $(systbl)
+   $(Q)$(SHELL) '$(systbl)' '$(CC)' $(sysdef) > $@
+
+clean::
+   $(call QUIET_CLEAN, s390) $(RM) $(header)
+
+archheaders: $(header)
diff --git a/tools/perf/arch/s390/entry/syscalls/mksyscalltbl 
b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
new file mode 100755
index 000..7fa0d0a
--- /dev/null
+++ b/tools/perf/arch/s390/entry/syscalls/mksyscalltbl
@@ -0,0 +1,36 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Generate system call table for perf
+#
+#
+# Copyright IBM Corp. 2017
+# Author(s):  Hendrik Brueckner 
+#
+
+gcc=$1
+input=$2
+
+if ! test -r $input; then
+   echo "Could not read input file" >&2
+   exit 1
+fi
+
+create_table()
+{
+   local max_nr
+
+   echo 'static const char *syscalltbl_s390_64[] = {'
+   while read sc nr; do
+   printf '\t[%d] = "%s",\n' $nr $sc
+   max_nr=$nr
+   done
+   echo '};'
+   echo "#define SYSCALLTBL_S390_64_MAX_ID $max_nr"
+}
+
+
+$gcc -m64 -E -dM -x c  $input \
+   |sed -ne 's/^#define __NR_//p' \
+   |sort -t' ' -k2 -nu\
+   |create_table


[tip:perf/core] tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  7af7919f0f4bde0cec1f546f924be81cfe50533d
Gitweb: https://git.kernel.org/tip/7af7919f0f4bde0cec1f546f924be81cfe50533d
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Wed, 27 Dec 2017 12:15:49 -0300

tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h

Will be used for generating the syscall id/string translation table.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Michael Petlan <mpet...@redhat.com>
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-vjfbfvgjrnqnbdluqd7le...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 {arch => tools/arch}/s390/include/uapi/asm/unistd.h | 0
 tools/perf/check-headers.sh | 1 +
 2 files changed, 1 insertion(+)

diff --git a/arch/s390/include/uapi/asm/unistd.h 
b/tools/arch/s390/include/uapi/asm/unistd.h
similarity index 100%
copy from arch/s390/include/uapi/asm/unistd.h
copy to tools/arch/s390/include/uapi/asm/unistd.h
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index ea602cd..f81ca50 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -33,6 +33,7 @@ arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
 arch/s390/include/uapi/asm/ptrace.h
 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
 include/asm-generic/bitops/arch_hweight.h


[tip:perf/core] tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h

2017-12-28 Thread tip-bot for Hendrik Brueckner
Commit-ID:  7af7919f0f4bde0cec1f546f924be81cfe50533d
Gitweb: https://git.kernel.org/tip/7af7919f0f4bde0cec1f546f924be81cfe50533d
Author: Hendrik Brueckner 
AuthorDate: Thu, 7 Dec 2017 09:27:59 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Wed, 27 Dec 2017 12:15:49 -0300

tools include s390: Grab a copy of arch/s390/include/uapi/asm/unistd.h

Will be used for generating the syscall id/string translation table.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Cc: Jiri Olsa 
Cc: Michael Petlan 
Cc: linux-s...@vger.kernel.org
LPU-Reference: 1512635281-20733-2-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-vjfbfvgjrnqnbdluqd7le...@git.kernel.org
[ split from a larger patch ]
Signed-off-by: Arnaldo Carvalho de Melo 
---
 {arch => tools/arch}/s390/include/uapi/asm/unistd.h | 0
 tools/perf/check-headers.sh | 1 +
 2 files changed, 1 insertion(+)

diff --git a/arch/s390/include/uapi/asm/unistd.h 
b/tools/arch/s390/include/uapi/asm/unistd.h
similarity index 100%
copy from arch/s390/include/uapi/asm/unistd.h
copy to tools/arch/s390/include/uapi/asm/unistd.h
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index ea602cd..f81ca50 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -33,6 +33,7 @@ arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
 arch/s390/include/uapi/asm/ptrace.h
 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
 include/asm-generic/bitops/arch_hweight.h


Re: [PATCH 18/36] perf s390: Always build with -fPIC

2017-12-07 Thread Hendrik Brueckner
Hi Arnaldo,

On Wed, Dec 06, 2017 at 11:40:57AM -0300, Arnaldo Carvalho de Melo wrote:
> From: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
> 
> On s390, object files must be compiled with position-indepedent code in
> order to be incrementally linked or linked to shared libraries.
> Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
> is built properly.
> 
> Reported-by: Jonathan Hermann <jonathan.herm...@de.ibm.com>
> Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
> Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
> Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
> Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
> Cc: linux s390 list <linux-s...@vger.kernel.org>
> LPU-Reference: 1512031765-9382-1-git-send-email-brueck...@linux.vnet.ibm.com
> Link: https://lkml.kernel.org/n/tip-a8wga8hrl0d0r84cal96f...@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
> ---
>  tools/perf/Makefile.config | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 2c437baf8364..bf86c09ca889 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -41,6 +41,7 @@ ifeq ($(SRCARCH),x86)
>  LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
>endif
>NO_PERF_REGS := 0
> +  CFLAGS += -fPIC
>  endif

I was just rebasing my syscall table work on top of your perf/core tree.
It looks like that there is a significant difference compared to linux
master tree.

With f704ef44602fbf403e6722c7ed13f62d17e8cb20 ("s390/perf: add support for
perf_regs and libdw"), Heiko introduced a change in the Makefile.config:

--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -53,6 +53,10 @@ ifeq ($(SRCARCH),arm64)
   LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
endif
 
+ifeq ($(ARCH),s390)
+  NO_PERF_REGS := 0
+endif
+
ifeq ($(NO_PERF_REGS),0)

The CFLAGS actually should applied to the s390 block and not in the x86
block.  Somehow this got messed up with git cherryp-pick / am.  So actually,
this should go into the section above:

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index ed65e82..0833d9f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -55,6 +55,7 @@ endif
 
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
+  CFLAGS += -fPIC
 endif
 
 ifeq ($(NO_PERF_REGS),0)



Re: [PATCH 18/36] perf s390: Always build with -fPIC

2017-12-07 Thread Hendrik Brueckner
Hi Arnaldo,

On Wed, Dec 06, 2017 at 11:40:57AM -0300, Arnaldo Carvalho de Melo wrote:
> From: Hendrik Brueckner 
> 
> On s390, object files must be compiled with position-indepedent code in
> order to be incrementally linked or linked to shared libraries.
> Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
> is built properly.
> 
> Reported-by: Jonathan Hermann 
> Signed-off-by: Hendrik Brueckner 
> Cc: Heiko Carstens 
> Cc: Martin Schwidefsky 
> Cc: Thomas Richter 
> Cc: linux s390 list 
> LPU-Reference: 1512031765-9382-1-git-send-email-brueck...@linux.vnet.ibm.com
> Link: https://lkml.kernel.org/n/tip-a8wga8hrl0d0r84cal96f...@git.kernel.org
> Signed-off-by: Arnaldo Carvalho de Melo 
> ---
>  tools/perf/Makefile.config | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 2c437baf8364..bf86c09ca889 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -41,6 +41,7 @@ ifeq ($(SRCARCH),x86)
>  LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
>endif
>NO_PERF_REGS := 0
> +  CFLAGS += -fPIC
>  endif

I was just rebasing my syscall table work on top of your perf/core tree.
It looks like that there is a significant difference compared to linux
master tree.

With f704ef44602fbf403e6722c7ed13f62d17e8cb20 ("s390/perf: add support for
perf_regs and libdw"), Heiko introduced a change in the Makefile.config:

--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -53,6 +53,10 @@ ifeq ($(SRCARCH),arm64)
   LIBUNWIND_LIBS = -lunwind -lunwind-aarch64
endif
 
+ifeq ($(ARCH),s390)
+  NO_PERF_REGS := 0
+endif
+
ifeq ($(NO_PERF_REGS),0)

The CFLAGS actually should applied to the s390 block and not in the x86
block.  Somehow this got messed up with git cherryp-pick / am.  So actually,
this should go into the section above:

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index ed65e82..0833d9f 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -55,6 +55,7 @@ endif
 
 ifeq ($(ARCH),s390)
   NO_PERF_REGS := 0
+  CFLAGS += -fPIC
 endif
 
 ifeq ($(NO_PERF_REGS),0)



[tip:perf/core] perf s390: Always build with -fPIC

2017-12-06 Thread tip-bot for Hendrik Brueckner
Commit-ID:  1dc4ddf112a408e607a073d951b962b6c6e2bd6c
Gitweb: https://git.kernel.org/tip/1dc4ddf112a408e607a073d951b962b6c6e2bd6c
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Thu, 30 Nov 2017 09:49:25 +0100
Committer:  Arnaldo Carvalho de Melo <a...@redhat.com>
CommitDate: Tue, 5 Dec 2017 10:24:32 -0300

perf s390: Always build with -fPIC

On s390, object files must be compiled with position-indepedent code in
order to be incrementally linked or linked to shared libraries.
Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
is built properly.

Reported-by: Jonathan Hermann <jonathan.herm...@de.ibm.com>
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: linux s390 list <linux-s...@vger.kernel.org>
LPU-Reference: 1512031765-9382-1-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-a8wga8hrl0d0r84cal96f...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/Makefile.config | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 2c437ba..bf86c09 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -41,6 +41,7 @@ ifeq ($(SRCARCH),x86)
 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
   endif
   NO_PERF_REGS := 0
+  CFLAGS += -fPIC
 endif
 
 ifeq ($(SRCARCH),arm)


[tip:perf/core] perf s390: Always build with -fPIC

2017-12-06 Thread tip-bot for Hendrik Brueckner
Commit-ID:  1dc4ddf112a408e607a073d951b962b6c6e2bd6c
Gitweb: https://git.kernel.org/tip/1dc4ddf112a408e607a073d951b962b6c6e2bd6c
Author: Hendrik Brueckner 
AuthorDate: Thu, 30 Nov 2017 09:49:25 +0100
Committer:  Arnaldo Carvalho de Melo 
CommitDate: Tue, 5 Dec 2017 10:24:32 -0300

perf s390: Always build with -fPIC

On s390, object files must be compiled with position-indepedent code in
order to be incrementally linked or linked to shared libraries.
Therefore, add -fPIC to the CFLAGS for s390 to ensure each object file
is built properly.

Reported-by: Jonathan Hermann 
Signed-off-by: Hendrik Brueckner 
Cc: Heiko Carstens 
Cc: Martin Schwidefsky 
Cc: Thomas Richter 
Cc: linux s390 list 
LPU-Reference: 1512031765-9382-1-git-send-email-brueck...@linux.vnet.ibm.com
Link: https://lkml.kernel.org/n/tip-a8wga8hrl0d0r84cal96f...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/Makefile.config | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 2c437ba..bf86c09 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -41,6 +41,7 @@ ifeq ($(SRCARCH),x86)
 LIBUNWIND_LIBS = -lunwind-x86 -llzma -lunwind
   endif
   NO_PERF_REGS := 0
+  CFLAGS += -fPIC
 endif
 
 ifeq ($(SRCARCH),arm)


[PATCH v2 2/6] s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
To mitigate and correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT
program type, introduce a user_pt_regs structure (similar to arm64) that
exports parts from the beginnig of the pt_regs structure.

The export must start with the beginning of the pt_regs structure because
to correctly calculate BPF prologues for perf (regs_query_register_offset()).

For BPF_PROG_TYPE_PERF_EVENT program types, the BPF program is then passed
a user_pt_regs structure.

Note: Depending on future changes to the s390 pt_regs structure, consider
the user_pt_regs structure to be stable for a particular kernel version
only. (Of course, s390 tries to ensure keep it stable as much as possible.)

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <a...@kernel.org>
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Daniel Borkmann <dan...@iogearbox.net>
---
 arch/s390/include/asm/perf_event.h  |  1 +
 arch/s390/include/asm/ptrace.h  | 11 ---
 arch/s390/include/uapi/asm/bpf_perf_event.h |  9 +
 arch/s390/include/uapi/asm/ptrace.h | 11 +++
 4 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/s390/include/asm/perf_event.h 
b/arch/s390/include/asm/perf_event.h
index d6c9d1e..b9c0e36 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -40,6 +40,7 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev,
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs) perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 
 /* Perf pt_regs extension for sample-data-entry indicators */
 struct perf_sf_sde_regs {
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index a3788da..6f70d81 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -74,9 +74,14 @@ enum {
  */
 struct pt_regs 
 {
-   unsigned long args[1];
-   psw_t psw;
-   unsigned long gprs[NUM_GPRS];
+   union {
+   user_pt_regs user_regs;
+   struct {
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+   };
+   };
unsigned long orig_gpr2;
unsigned int int_code;
unsigned int int_parm;
diff --git a/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 0d23c8f..70f7cb2 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -291,6 +291,17 @@
 } s390_regs;
 
 /*
+ * The user_pt_regs structure exports the beginning of
+ * the in-kernel pt_regs structure to user space.
+ */
+typedef struct
+{
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+} user_pt_regs;
+
+/*
  * Now for the user space program event recording (trace) definitions.
  * The following structures are used only for the ptrace interface, don't
  * touch or even look at it if you don't want to modify the user-space
-- 
1.8.3.1



[PATCH v2 1/6] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Commit 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT
program type") introduced the bpf_perf_event_data structure which
exports the pt_regs structure.  This is OK for multiple architectures
but fail for s390 and arm64 which do not export pt_regs.  Programs
using them, for example, the bpf selftest fail to compile on these
architectures.

For s390, exporting the pt_regs is not an option because s390 wants
to allow changes to it.  For arm64, there is a user_pt_regs structure
that covers parts of the pt_regs structure for use by user space.

To solve the broken uapi for s390 and arm64, introduce an abstract
type for pt_regs and add an asm/bpf_perf_event.h file that concretes
the type.  An asm-generic header file covers the architectures that
export pt_regs today.

The arch-specific enablement for s390 and arm64 follows in separate
commits.

Reported-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Fixes: 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type")
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <a...@kernel.org>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Daniel Borkmann <dan...@iogearbox.net>
---
 arch/alpha/include/uapi/asm/Kbuild| 2 ++
 arch/arc/include/uapi/asm/Kbuild  | 1 +
 arch/arm/include/uapi/asm/Kbuild  | 1 +
 arch/blackfin/include/uapi/asm/Kbuild | 1 +
 arch/c6x/include/uapi/asm/Kbuild  | 1 +
 arch/cris/include/uapi/asm/Kbuild | 1 +
 arch/frv/include/uapi/asm/Kbuild  | 2 ++
 arch/h8300/include/uapi/asm/Kbuild| 1 +
 arch/hexagon/include/uapi/asm/Kbuild  | 1 +
 arch/ia64/include/uapi/asm/Kbuild | 1 +
 arch/m32r/include/uapi/asm/Kbuild | 1 +
 arch/m68k/include/uapi/asm/Kbuild | 1 +
 arch/metag/include/uapi/asm/Kbuild| 1 +
 arch/microblaze/include/uapi/asm/Kbuild   | 1 +
 arch/mips/include/uapi/asm/Kbuild | 1 +
 arch/mn10300/include/uapi/asm/Kbuild  | 1 +
 arch/nios2/include/uapi/asm/Kbuild| 1 +
 arch/openrisc/include/uapi/asm/Kbuild | 1 +
 arch/parisc/include/uapi/asm/Kbuild   | 1 +
 arch/powerpc/include/uapi/asm/Kbuild  | 1 +
 arch/riscv/include/uapi/asm/Kbuild| 1 +
 arch/score/include/uapi/asm/Kbuild| 1 +
 arch/sh/include/uapi/asm/Kbuild   | 1 +
 arch/sparc/include/uapi/asm/Kbuild| 1 +
 arch/tile/include/uapi/asm/Kbuild | 1 +
 arch/unicore32/include/uapi/asm/Kbuild| 1 +
 arch/x86/include/uapi/asm/Kbuild  | 1 +
 arch/xtensa/include/uapi/asm/Kbuild   | 1 +
 include/linux/perf_event.h| 6 +-
 include/uapi/asm-generic/bpf_perf_event.h | 9 +
 include/uapi/linux/bpf_perf_event.h   | 5 ++---
 kernel/events/core.c  | 2 +-
 32 files changed, 47 insertions(+), 5 deletions(-)
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h

diff --git a/arch/alpha/include/uapi/asm/Kbuild 
b/arch/alpha/include/uapi/asm/Kbuild
index b15bf6b..14a2e9a 100644
--- a/arch/alpha/include/uapi/asm/Kbuild
+++ b/arch/alpha/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
+
+generic-y += bpf_perf_event.h
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild
index fa6d0ff..170b5db 100644
--- a/arch/arc/include/uapi/asm/Kbuild
+++ b/arch/arc/include/uapi/asm/Kbuild
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += auxvec.h
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += fcntl.h
 generic-y += ioctl.h
diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild
index 4d53de3..4d1cc18 100644
--- a/arch/arm/include/uapi/asm/Kbuild
+++ b/arch/arm/include/uapi/asm/Kbuild
@@ -7,6 +7,7 @@ generated-y += unistd-oabi.h
 generated-y += unistd-eabi.h
 
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += ioctl.h
 generic-y += ipcbuf.h
diff --git a/arch/blackfin/include/uapi/asm/Kbuild 
b/arch/blackfin/include/uapi/asm/Kbuild
index aa624b4..2240b38 100644
--- a/arch/blackfin/include/uapi/asm/Kbuild
+++ b/arch/blackfin/include/uapi/asm/Kbuild
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += auxvec.h
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += ioctl.h
 generic-y += ipcbuf.h
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild
index 67ee896..26644e1 100644
--- a/arch/c6x/include/uapi/asm/Kbuild
+++ b/

[PATCH v2 2/6] s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
To mitigate and correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT
program type, introduce a user_pt_regs structure (similar to arm64) that
exports parts from the beginnig of the pt_regs structure.

The export must start with the beginning of the pt_regs structure because
to correctly calculate BPF prologues for perf (regs_query_register_offset()).

For BPF_PROG_TYPE_PERF_EVENT program types, the BPF program is then passed
a user_pt_regs structure.

Note: Depending on future changes to the s390 pt_regs structure, consider
the user_pt_regs structure to be stable for a particular kernel version
only. (Of course, s390 tries to ensure keep it stable as much as possible.)

Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Acked-by: Alexei Starovoitov 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: Arnaldo Carvalho de Melo 
Cc: Daniel Borkmann 
---
 arch/s390/include/asm/perf_event.h  |  1 +
 arch/s390/include/asm/ptrace.h  | 11 ---
 arch/s390/include/uapi/asm/bpf_perf_event.h |  9 +
 arch/s390/include/uapi/asm/ptrace.h | 11 +++
 4 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/s390/include/asm/perf_event.h 
b/arch/s390/include/asm/perf_event.h
index d6c9d1e..b9c0e36 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -40,6 +40,7 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev,
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs) perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 
 /* Perf pt_regs extension for sample-data-entry indicators */
 struct perf_sf_sde_regs {
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index a3788da..6f70d81 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -74,9 +74,14 @@ enum {
  */
 struct pt_regs 
 {
-   unsigned long args[1];
-   psw_t psw;
-   unsigned long gprs[NUM_GPRS];
+   union {
+   user_pt_regs user_regs;
+   struct {
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+   };
+   };
unsigned long orig_gpr2;
unsigned int int_code;
unsigned int int_parm;
diff --git a/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 0d23c8f..70f7cb2 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -291,6 +291,17 @@
 } s390_regs;
 
 /*
+ * The user_pt_regs structure exports the beginning of
+ * the in-kernel pt_regs structure to user space.
+ */
+typedef struct
+{
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+} user_pt_regs;
+
+/*
  * Now for the user space program event recording (trace) definitions.
  * The following structures are used only for the ptrace interface, don't
  * touch or even look at it if you don't want to modify the user-space
-- 
1.8.3.1



[PATCH v2 1/6] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Commit 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT
program type") introduced the bpf_perf_event_data structure which
exports the pt_regs structure.  This is OK for multiple architectures
but fail for s390 and arm64 which do not export pt_regs.  Programs
using them, for example, the bpf selftest fail to compile on these
architectures.

For s390, exporting the pt_regs is not an option because s390 wants
to allow changes to it.  For arm64, there is a user_pt_regs structure
that covers parts of the pt_regs structure for use by user space.

To solve the broken uapi for s390 and arm64, introduce an abstract
type for pt_regs and add an asm/bpf_perf_event.h file that concretes
the type.  An asm-generic header file covers the architectures that
export pt_regs today.

The arch-specific enablement for s390 and arm64 follows in separate
commits.

Reported-by: Thomas Richter 
Fixes: 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type")
Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Acked-by: Alexei Starovoitov 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Arnd Bergmann 
Cc: Daniel Borkmann 
---
 arch/alpha/include/uapi/asm/Kbuild| 2 ++
 arch/arc/include/uapi/asm/Kbuild  | 1 +
 arch/arm/include/uapi/asm/Kbuild  | 1 +
 arch/blackfin/include/uapi/asm/Kbuild | 1 +
 arch/c6x/include/uapi/asm/Kbuild  | 1 +
 arch/cris/include/uapi/asm/Kbuild | 1 +
 arch/frv/include/uapi/asm/Kbuild  | 2 ++
 arch/h8300/include/uapi/asm/Kbuild| 1 +
 arch/hexagon/include/uapi/asm/Kbuild  | 1 +
 arch/ia64/include/uapi/asm/Kbuild | 1 +
 arch/m32r/include/uapi/asm/Kbuild | 1 +
 arch/m68k/include/uapi/asm/Kbuild | 1 +
 arch/metag/include/uapi/asm/Kbuild| 1 +
 arch/microblaze/include/uapi/asm/Kbuild   | 1 +
 arch/mips/include/uapi/asm/Kbuild | 1 +
 arch/mn10300/include/uapi/asm/Kbuild  | 1 +
 arch/nios2/include/uapi/asm/Kbuild| 1 +
 arch/openrisc/include/uapi/asm/Kbuild | 1 +
 arch/parisc/include/uapi/asm/Kbuild   | 1 +
 arch/powerpc/include/uapi/asm/Kbuild  | 1 +
 arch/riscv/include/uapi/asm/Kbuild| 1 +
 arch/score/include/uapi/asm/Kbuild| 1 +
 arch/sh/include/uapi/asm/Kbuild   | 1 +
 arch/sparc/include/uapi/asm/Kbuild| 1 +
 arch/tile/include/uapi/asm/Kbuild | 1 +
 arch/unicore32/include/uapi/asm/Kbuild| 1 +
 arch/x86/include/uapi/asm/Kbuild  | 1 +
 arch/xtensa/include/uapi/asm/Kbuild   | 1 +
 include/linux/perf_event.h| 6 +-
 include/uapi/asm-generic/bpf_perf_event.h | 9 +
 include/uapi/linux/bpf_perf_event.h   | 5 ++---
 kernel/events/core.c  | 2 +-
 32 files changed, 47 insertions(+), 5 deletions(-)
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h

diff --git a/arch/alpha/include/uapi/asm/Kbuild 
b/arch/alpha/include/uapi/asm/Kbuild
index b15bf6b..14a2e9a 100644
--- a/arch/alpha/include/uapi/asm/Kbuild
+++ b/arch/alpha/include/uapi/asm/Kbuild
@@ -1,2 +1,4 @@
 # UAPI Header export list
 include include/uapi/asm-generic/Kbuild.asm
+
+generic-y += bpf_perf_event.h
diff --git a/arch/arc/include/uapi/asm/Kbuild b/arch/arc/include/uapi/asm/Kbuild
index fa6d0ff..170b5db 100644
--- a/arch/arc/include/uapi/asm/Kbuild
+++ b/arch/arc/include/uapi/asm/Kbuild
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += auxvec.h
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += fcntl.h
 generic-y += ioctl.h
diff --git a/arch/arm/include/uapi/asm/Kbuild b/arch/arm/include/uapi/asm/Kbuild
index 4d53de3..4d1cc18 100644
--- a/arch/arm/include/uapi/asm/Kbuild
+++ b/arch/arm/include/uapi/asm/Kbuild
@@ -7,6 +7,7 @@ generated-y += unistd-oabi.h
 generated-y += unistd-eabi.h
 
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += ioctl.h
 generic-y += ipcbuf.h
diff --git a/arch/blackfin/include/uapi/asm/Kbuild 
b/arch/blackfin/include/uapi/asm/Kbuild
index aa624b4..2240b38 100644
--- a/arch/blackfin/include/uapi/asm/Kbuild
+++ b/arch/blackfin/include/uapi/asm/Kbuild
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += auxvec.h
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += ioctl.h
 generic-y += ipcbuf.h
diff --git a/arch/c6x/include/uapi/asm/Kbuild b/arch/c6x/include/uapi/asm/Kbuild
index 67ee896..26644e1 100644
--- a/arch/c6x/include/uapi/asm/Kbuild
+++ b/arch/c6x/include/uapi/asm/Kbuild
@@ -3,6 +3,7 @@ include include/uapi/asm-generic/Kbuild.asm
 
 generic-y += auxvec.h
 generic-y += bitsperlong.h
+generic-y += bpf_perf_event.h
 generic-y += errno.h
 generic-y += fcntl.h
 generic-y += ioctl.h
diff --git a/arch/cris/include/uapi/asm/Kbuild 
b/arch/cris/include/uapi/asm/Kbuild
index 368

[PATCH v2 5/6] selftests/bpf: sync kernel headers and introduce arch support in Makefile

2017-12-04 Thread Hendrik Brueckner
Synchronize the uapi kernel header files which solves the broken
uapi export of pt_regs.  Because of arch-specific uapi headers,
extended the include path in the Makefile.

With this change, the test_verifier program compiles and runs successfully
on s390.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <a...@kernel.org>
Cc: Daniel Borkmann <dan...@iogearbox.net>
Cc: Shuah Khan <sh...@kernel.org>
---
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 457 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/testing/selftests/bpf/Makefile   |  14 +-
 6 files changed, 500 insertions(+), 4 deletions(-)
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

diff --git a/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/ptrace.h 
b/tools/arch/s390/include/uapi/asm/ptrace.h
new file mode 100644
index 000..543dd70
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/ptrace.h
@@ -0,0 +1,457 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ *  S390 version
+ *Copyright IBM Corp. 1999, 2000
+ *Author(s): Denis Joseph Barrow (djbar...@de.ibm.com,barrow...@yahoo.com)
+ */
+
+#ifndef _UAPI_S390_PTRACE_H
+#define _UAPI_S390_PTRACE_H
+
+/*
+ * Offsets in the user_regs_struct. They are used for the ptrace
+ * system call and in entry.S
+ */
+#ifndef __s390x__
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x04
+#define PT_GPR0 0x08
+#define PT_GPR1 0x0C
+#define PT_GPR2 0x10
+#define PT_GPR3 0x14
+#define PT_GPR4 0x18
+#define PT_GPR5 0x1C
+#define PT_GPR6 0x20
+#define PT_GPR7 0x24
+#define PT_GPR8 0x28
+#define PT_GPR9 0x2C
+#define PT_GPR100x30
+#define PT_GPR110x34
+#define PT_GPR120x38
+#define PT_GPR130x3C
+#define PT_GPR140x40
+#define PT_GPR150x44
+#define PT_ACR0 0x48
+#define PT_ACR1 0x4C
+#define PT_ACR2 0x50
+#define PT_ACR3 0x54
+#define PT_ACR40x58
+#define PT_ACR50x5C
+#define PT_ACR60x60
+#define PT_ACR70x64
+#define PT_ACR80x68
+#define PT_ACR90x6C
+#define PT_ACR100x70
+#define PT_ACR110x74
+#define PT_ACR120x78
+#define PT_ACR130x7C
+#define PT_ACR140x80
+#define PT_ACR150x84
+#define PT_ORIGGPR2 0x88
+#define PT_FPC 0x90
+/*
+ * A nasty fact of life that the ptrace api
+ * only supports passing of longs.
+ */
+#define PT_FPR0_HI  0x98
+#define PT_FPR0_LO  0x9C
+#define PT_FPR1_HI  0xA0
+#define PT_FPR1_LO  0xA4
+#define PT_FPR2_HI  0xA8
+#define PT_FPR2_LO  0xAC
+#define PT_FPR3_HI  0xB0
+#define PT_FPR3_LO  0xB4
+#define PT_FPR4_HI  0xB8
+#define PT_FPR4_LO  0xBC
+#define PT_FPR5_HI  0xC0
+#define PT_FPR5_LO  0xC4
+#define PT_FPR6_HI  0xC8
+#define PT_FPR6_LO  0xCC
+#define PT_FPR7_HI  0xD0
+#define PT_FPR7_LO  0xD4
+#define PT_FPR8_HI  0xD8
+#define PT_FPR8_LO  0XDC
+#define PT_FPR9_HI  0xE0
+#define PT_FPR9_LO  0xE4
+#define PT_FPR10_HI 0xE8
+#define PT_FPR10_LO 0xEC
+#define PT_FPR11_HI 0xF0
+#define PT_FPR11_LO 0xF4
+#define PT_FPR12_HI 0xF8
+#define PT_FPR12_LO 0xFC
+#define PT_FPR13_HI 0x100
+#define PT_FPR13_LO 0x104
+#define PT_FPR14_HI 0x108
+#define PT_FPR14_LO 0x10C
+#define PT_FPR15_HI 0x110
+#define PT_FPR15_LO 0x114
+#define PT_CR_90x118
+#define PT_CR_100x11C
+#define PT_CR_110x120
+#define PT_IEEE_IP  0x13C
+#define PT_LASTOFF  PT_IEEE_IP
+#define PT_ENDREGS  0x140-1
+
+#define GPR_SIZE   4
+#define CR_SIZE4
+
+#define STACK_FRAME_OVERHEA

[PATCH v2 5/6] selftests/bpf: sync kernel headers and introduce arch support in Makefile

2017-12-04 Thread Hendrik Brueckner
Synchronize the uapi kernel header files which solves the broken
uapi export of pt_regs.  Because of arch-specific uapi headers,
extended the include path in the Makefile.

With this change, the test_verifier program compiles and runs successfully
on s390.

Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Acked-by: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Shuah Khan 
---
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 457 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/testing/selftests/bpf/Makefile   |  14 +-
 6 files changed, 500 insertions(+), 4 deletions(-)
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

diff --git a/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/ptrace.h 
b/tools/arch/s390/include/uapi/asm/ptrace.h
new file mode 100644
index 000..543dd70
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/ptrace.h
@@ -0,0 +1,457 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ *  S390 version
+ *Copyright IBM Corp. 1999, 2000
+ *Author(s): Denis Joseph Barrow (djbar...@de.ibm.com,barrow...@yahoo.com)
+ */
+
+#ifndef _UAPI_S390_PTRACE_H
+#define _UAPI_S390_PTRACE_H
+
+/*
+ * Offsets in the user_regs_struct. They are used for the ptrace
+ * system call and in entry.S
+ */
+#ifndef __s390x__
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x04
+#define PT_GPR0 0x08
+#define PT_GPR1 0x0C
+#define PT_GPR2 0x10
+#define PT_GPR3 0x14
+#define PT_GPR4 0x18
+#define PT_GPR5 0x1C
+#define PT_GPR6 0x20
+#define PT_GPR7 0x24
+#define PT_GPR8 0x28
+#define PT_GPR9 0x2C
+#define PT_GPR100x30
+#define PT_GPR110x34
+#define PT_GPR120x38
+#define PT_GPR130x3C
+#define PT_GPR140x40
+#define PT_GPR150x44
+#define PT_ACR0 0x48
+#define PT_ACR1 0x4C
+#define PT_ACR2 0x50
+#define PT_ACR3 0x54
+#define PT_ACR40x58
+#define PT_ACR50x5C
+#define PT_ACR60x60
+#define PT_ACR70x64
+#define PT_ACR80x68
+#define PT_ACR90x6C
+#define PT_ACR100x70
+#define PT_ACR110x74
+#define PT_ACR120x78
+#define PT_ACR130x7C
+#define PT_ACR140x80
+#define PT_ACR150x84
+#define PT_ORIGGPR2 0x88
+#define PT_FPC 0x90
+/*
+ * A nasty fact of life that the ptrace api
+ * only supports passing of longs.
+ */
+#define PT_FPR0_HI  0x98
+#define PT_FPR0_LO  0x9C
+#define PT_FPR1_HI  0xA0
+#define PT_FPR1_LO  0xA4
+#define PT_FPR2_HI  0xA8
+#define PT_FPR2_LO  0xAC
+#define PT_FPR3_HI  0xB0
+#define PT_FPR3_LO  0xB4
+#define PT_FPR4_HI  0xB8
+#define PT_FPR4_LO  0xBC
+#define PT_FPR5_HI  0xC0
+#define PT_FPR5_LO  0xC4
+#define PT_FPR6_HI  0xC8
+#define PT_FPR6_LO  0xCC
+#define PT_FPR7_HI  0xD0
+#define PT_FPR7_LO  0xD4
+#define PT_FPR8_HI  0xD8
+#define PT_FPR8_LO  0XDC
+#define PT_FPR9_HI  0xE0
+#define PT_FPR9_LO  0xE4
+#define PT_FPR10_HI 0xE8
+#define PT_FPR10_LO 0xEC
+#define PT_FPR11_HI 0xF0
+#define PT_FPR11_LO 0xF4
+#define PT_FPR12_HI 0xF8
+#define PT_FPR12_LO 0xFC
+#define PT_FPR13_HI 0x100
+#define PT_FPR13_LO 0x104
+#define PT_FPR14_HI 0x108
+#define PT_FPR14_LO 0x10C
+#define PT_FPR15_HI 0x110
+#define PT_FPR15_LO 0x114
+#define PT_CR_90x118
+#define PT_CR_100x11C
+#define PT_CR_110x120
+#define PT_IEEE_IP  0x13C
+#define PT_LASTOFF  PT_IEEE_IP
+#define PT_ENDREGS  0x140-1
+
+#define GPR_SIZE   4
+#define CR_SIZE4
+
+#define STACK_FRAME_OVERHEAD   96  /* size of minimum stack frame */
+
+#else /* __s390x__ */
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x08
+#define PT_GPR0 0x10

[PATCH v2 4/6] s390/uapi: correct whitespace & coding style in asm/ptrace.h

2017-12-04 Thread Hendrik Brueckner
Correct whitespace and coding style issues in the s390 asm/ptrace.h
uapi header file.  This is preparatory work to copy it to the tools/
directory for inclusion by selftests and perf.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
---
 arch/s390/include/uapi/asm/ptrace.h | 118 
 1 file changed, 52 insertions(+), 66 deletions(-)

diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 70f7cb2..543dd70 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -162,7 +162,7 @@
 #define GPR_SIZE   8
 #define CR_SIZE8
 
-#define STACK_FRAME_OVERHEAD160  /* size of minimum stack frame */
+#define STACK_FRAME_OVERHEAD   160  /* size of minimum stack frame */
 
 #endif /* __s390x__ */
 
@@ -179,17 +179,16 @@
 #define ACR_SIZE   4
 
 
-#define PTRACE_OLDSETOPTIONS 21
+#define PTRACE_OLDSETOPTIONS21
 
 #ifndef __ASSEMBLY__
 #include 
 #include 
 
-typedef union
-{
-   float   f;
-   double  d;
-__u64   ui;
+typedef union {
+   float   f;
+   double  d;
+   __u64   ui;
struct
{
__u32 hi;
@@ -197,23 +196,21 @@
} fp;
 } freg_t;
 
-typedef struct
-{
-   __u32   fpc;
+typedef struct {
+   __u32   fpc;
__u32   pad;
-   freg_t  fprs[NUM_FPRS];  
+   freg_t  fprs[NUM_FPRS];
 } s390_fp_regs;
 
-#define FPC_EXCEPTION_MASK  0xF800
-#define FPC_FLAGS_MASK  0x00F8
-#define FPC_DXC_MASK0xFF00
-#define FPC_RM_MASK 0x0003
+#define FPC_EXCEPTION_MASK 0xF800
+#define FPC_FLAGS_MASK 0x00F8
+#define FPC_DXC_MASK   0xFF00
+#define FPC_RM_MASK0x0003
 
 /* this typedef defines how a Program Status Word looks like */
-typedef struct 
-{
-unsigned long mask;
-unsigned long addr;
+typedef struct {
+   unsigned long mask;
+   unsigned long addr;
 } __attribute__ ((aligned(8))) psw_t;
 
 #ifndef __s390x__
@@ -282,8 +279,7 @@
 /*
  * The s390_regs structure is used to define the elf_gregset_t.
  */
-typedef struct
-{
+typedef struct {
psw_t psw;
unsigned long gprs[NUM_GPRS];
unsigned int  acrs[NUM_ACRS];
@@ -294,8 +290,7 @@
  * The user_pt_regs structure exports the beginning of
  * the in-kernel pt_regs structure to user space.
  */
-typedef struct
-{
+typedef struct {
unsigned long args[1];
psw_t psw;
unsigned long gprs[NUM_GPRS];
@@ -307,19 +302,17 @@
  * touch or even look at it if you don't want to modify the user-space
  * ptrace interface. In particular stay away from it for in-kernel PER.
  */
-typedef struct
-{
+typedef struct {
unsigned long cr[NUM_CR_WORDS];
 } per_cr_words;
 
 #define PER_EM_MASK 0xE800UL
 
-typedefstruct
-{
+typedef struct {
 #ifdef __s390x__
-   unsigned   : 32;
+   unsigned   : 32;
 #endif /* __s390x__ */
-   unsigned em_branching  : 1;
+   unsigned em_branching  : 1;
unsigned em_instruction_fetch  : 1;
/*
 * Switching on storage alteration automatically fixes
@@ -328,44 +321,41 @@
unsigned em_storage_alteration : 1;
unsigned em_gpr_alt_unused : 1;
unsigned em_store_real_address : 1;
-   unsigned   : 3;
+   unsigned   : 3;
unsigned branch_addr_ctl   : 1;
-   unsigned   : 1;
+   unsigned   : 1;
unsigned storage_alt_space_ctl : 1;
-   unsigned   : 21;
+   unsigned   : 21;
unsigned long starting_addr;
unsigned long ending_addr;
 } per_cr_bits;
 
-typedef struct
-{
+typedef struct {
unsigned short perc_atmid;
unsigned long address;
unsigned char access_id;
 } per_lowcore_words;
 
-typedef struct
-{
-   unsigned perc_branching  : 1;
+typedef struct {
+   unsigned perc_branching  : 1;
unsigned perc_instruction_fetch  : 1;
unsigned perc_storage_alteration : 1;
-   unsigned perc_gpr_alt_unused : 1;
+   unsigned perc_gpr_alt_unused : 1;
unsigned perc_store_real_address : 1;
-   unsigned : 3;
-   unsigned atmid_psw_bit_31: 1;
-   unsigned atmid_validity_bit  : 1;
-   unsigned atmid_psw_bit_32: 1;
-   unsigned atmid_psw_bit_5 : 1;
-   unsigned atmid_psw_bit_16: 1;
-   unsigned atmid_psw_bit_17: 1;
-   unsigned si  : 2;
+   unsigned : 3;
+   unsigned atmid_psw_bit_31: 1;
+   unsigned atmid_validity_bit  : 1;
+   unsigned atmid_psw_bit_32: 1;
+   unsigned atmid_psw_bit_5  

[PATCH v2 4/6] s390/uapi: correct whitespace & coding style in asm/ptrace.h

2017-12-04 Thread Hendrik Brueckner
Correct whitespace and coding style issues in the s390 asm/ptrace.h
uapi header file.  This is preparatory work to copy it to the tools/
directory for inclusion by selftests and perf.

Signed-off-by: Hendrik Brueckner 
---
 arch/s390/include/uapi/asm/ptrace.h | 118 
 1 file changed, 52 insertions(+), 66 deletions(-)

diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 70f7cb2..543dd70 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -162,7 +162,7 @@
 #define GPR_SIZE   8
 #define CR_SIZE8
 
-#define STACK_FRAME_OVERHEAD160  /* size of minimum stack frame */
+#define STACK_FRAME_OVERHEAD   160  /* size of minimum stack frame */
 
 #endif /* __s390x__ */
 
@@ -179,17 +179,16 @@
 #define ACR_SIZE   4
 
 
-#define PTRACE_OLDSETOPTIONS 21
+#define PTRACE_OLDSETOPTIONS21
 
 #ifndef __ASSEMBLY__
 #include 
 #include 
 
-typedef union
-{
-   float   f;
-   double  d;
-__u64   ui;
+typedef union {
+   float   f;
+   double  d;
+   __u64   ui;
struct
{
__u32 hi;
@@ -197,23 +196,21 @@
} fp;
 } freg_t;
 
-typedef struct
-{
-   __u32   fpc;
+typedef struct {
+   __u32   fpc;
__u32   pad;
-   freg_t  fprs[NUM_FPRS];  
+   freg_t  fprs[NUM_FPRS];
 } s390_fp_regs;
 
-#define FPC_EXCEPTION_MASK  0xF800
-#define FPC_FLAGS_MASK  0x00F8
-#define FPC_DXC_MASK0xFF00
-#define FPC_RM_MASK 0x0003
+#define FPC_EXCEPTION_MASK 0xF800
+#define FPC_FLAGS_MASK 0x00F8
+#define FPC_DXC_MASK   0xFF00
+#define FPC_RM_MASK0x0003
 
 /* this typedef defines how a Program Status Word looks like */
-typedef struct 
-{
-unsigned long mask;
-unsigned long addr;
+typedef struct {
+   unsigned long mask;
+   unsigned long addr;
 } __attribute__ ((aligned(8))) psw_t;
 
 #ifndef __s390x__
@@ -282,8 +279,7 @@
 /*
  * The s390_regs structure is used to define the elf_gregset_t.
  */
-typedef struct
-{
+typedef struct {
psw_t psw;
unsigned long gprs[NUM_GPRS];
unsigned int  acrs[NUM_ACRS];
@@ -294,8 +290,7 @@
  * The user_pt_regs structure exports the beginning of
  * the in-kernel pt_regs structure to user space.
  */
-typedef struct
-{
+typedef struct {
unsigned long args[1];
psw_t psw;
unsigned long gprs[NUM_GPRS];
@@ -307,19 +302,17 @@
  * touch or even look at it if you don't want to modify the user-space
  * ptrace interface. In particular stay away from it for in-kernel PER.
  */
-typedef struct
-{
+typedef struct {
unsigned long cr[NUM_CR_WORDS];
 } per_cr_words;
 
 #define PER_EM_MASK 0xE800UL
 
-typedefstruct
-{
+typedef struct {
 #ifdef __s390x__
-   unsigned   : 32;
+   unsigned   : 32;
 #endif /* __s390x__ */
-   unsigned em_branching  : 1;
+   unsigned em_branching  : 1;
unsigned em_instruction_fetch  : 1;
/*
 * Switching on storage alteration automatically fixes
@@ -328,44 +321,41 @@
unsigned em_storage_alteration : 1;
unsigned em_gpr_alt_unused : 1;
unsigned em_store_real_address : 1;
-   unsigned   : 3;
+   unsigned   : 3;
unsigned branch_addr_ctl   : 1;
-   unsigned   : 1;
+   unsigned   : 1;
unsigned storage_alt_space_ctl : 1;
-   unsigned   : 21;
+   unsigned   : 21;
unsigned long starting_addr;
unsigned long ending_addr;
 } per_cr_bits;
 
-typedef struct
-{
+typedef struct {
unsigned short perc_atmid;
unsigned long address;
unsigned char access_id;
 } per_lowcore_words;
 
-typedef struct
-{
-   unsigned perc_branching  : 1;
+typedef struct {
+   unsigned perc_branching  : 1;
unsigned perc_instruction_fetch  : 1;
unsigned perc_storage_alteration : 1;
-   unsigned perc_gpr_alt_unused : 1;
+   unsigned perc_gpr_alt_unused : 1;
unsigned perc_store_real_address : 1;
-   unsigned : 3;
-   unsigned atmid_psw_bit_31: 1;
-   unsigned atmid_validity_bit  : 1;
-   unsigned atmid_psw_bit_32: 1;
-   unsigned atmid_psw_bit_5 : 1;
-   unsigned atmid_psw_bit_16: 1;
-   unsigned atmid_psw_bit_17: 1;
-   unsigned si  : 2;
+   unsigned : 3;
+   unsigned atmid_psw_bit_31: 1;
+   unsigned atmid_validity_bit  : 1;
+   unsigned atmid_psw_bit_32: 1;
+   unsigned atmid_psw_bit_5 : 1;
+   unsigned atmid_psw_bit_16

[PATCH v2 6/6] perf s390: add regs_query_register_offset()

2017-12-04 Thread Hendrik Brueckner
The regs_query_register_offset() helper function converts
register name like "%r0" to an offset of a register in user_pt_regs
It is required by the BPF prologue generator.

The user_pt_regs structure was recently added to "asm/ptrace.h".
Hence, update tools/perf/check-headers.sh to keep the header file
in sync with kernel changes.

Suggested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <a...@kernel.org>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
---
 tools/perf/arch/s390/Makefile  |  1 +
 tools/perf/arch/s390/util/dwarf-regs.c | 32 +---
 tools/perf/check-headers.sh|  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 21322e0..09ba923 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
+PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
diff --git a/tools/perf/arch/s390/util/dwarf-regs.c 
b/tools/perf/arch/s390/util/dwarf-regs.c
index f47576c..a8ace5c 100644
--- a/tools/perf/arch/s390/util/dwarf-regs.c
+++ b/tools/perf/arch/s390/util/dwarf-regs.c
@@ -2,17 +2,43 @@
 /*
  * Mapping of DWARF debug register numbers into register names.
  *
- *Copyright IBM Corp. 2010
- *Author(s): Heiko Carstens <heiko.carst...@de.ibm.com>,
+ * Copyright IBM Corp. 2010, 2017
+ * Author(s): Heiko Carstens <heiko.carst...@de.ibm.com>,
+ *   Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
  *
  */
 
+#include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include "dwarf-regs-table.h"
 
 const char *get_arch_regstr(unsigned int n)
 {
return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n];
 }
+
+/*
+ * Convert the register name into an offset to struct pt_regs (kernel).
+ * This is required by the BPF prologue generator.  The BPF
+ * program is called in the BPF overflow handler in the perf
+ * core.
+ */
+int regs_query_register_offset(const char *name)
+{
+   unsigned long gpr;
+
+   if (!name || strncmp(name, "%r", 2))
+   return -EINVAL;
+
+   errno = 0;
+   gpr = strtoul(name + 2, NULL, 10);
+   if (errno || gpr >= 16)
+   return -EINVAL;
+
+   return offsetof(user_pt_regs, gprs) + 8 * gpr;
+}
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 77406d2..6db9d80 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -30,6 +30,7 @@ arch/x86/include/uapi/asm/vmx.h
 arch/powerpc/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
+arch/s390/include/uapi/asm/ptrace.h
 arch/s390/include/uapi/asm/sie.h
 arch/arm/include/uapi/asm/kvm.h
 arch/arm64/include/uapi/asm/kvm.h
-- 
1.8.3.1



[PATCH v2 6/6] perf s390: add regs_query_register_offset()

2017-12-04 Thread Hendrik Brueckner
The regs_query_register_offset() helper function converts
register name like "%r0" to an offset of a register in user_pt_regs
It is required by the BPF prologue generator.

The user_pt_regs structure was recently added to "asm/ptrace.h".
Hence, update tools/perf/check-headers.sh to keep the header file
in sync with kernel changes.

Suggested-by: Thomas Richter 
Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Acked-by: Alexei Starovoitov 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Heiko Carstens 
---
 tools/perf/arch/s390/Makefile  |  1 +
 tools/perf/arch/s390/util/dwarf-regs.c | 32 +---
 tools/perf/check-headers.sh|  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 21322e0..09ba923 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
+PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
diff --git a/tools/perf/arch/s390/util/dwarf-regs.c 
b/tools/perf/arch/s390/util/dwarf-regs.c
index f47576c..a8ace5c 100644
--- a/tools/perf/arch/s390/util/dwarf-regs.c
+++ b/tools/perf/arch/s390/util/dwarf-regs.c
@@ -2,17 +2,43 @@
 /*
  * Mapping of DWARF debug register numbers into register names.
  *
- *Copyright IBM Corp. 2010
- *Author(s): Heiko Carstens ,
+ * Copyright IBM Corp. 2010, 2017
+ * Author(s): Heiko Carstens ,
+ *   Hendrik Brueckner 
  *
  */
 
+#include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include "dwarf-regs-table.h"
 
 const char *get_arch_regstr(unsigned int n)
 {
return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n];
 }
+
+/*
+ * Convert the register name into an offset to struct pt_regs (kernel).
+ * This is required by the BPF prologue generator.  The BPF
+ * program is called in the BPF overflow handler in the perf
+ * core.
+ */
+int regs_query_register_offset(const char *name)
+{
+   unsigned long gpr;
+
+   if (!name || strncmp(name, "%r", 2))
+   return -EINVAL;
+
+   errno = 0;
+   gpr = strtoul(name + 2, NULL, 10);
+   if (errno || gpr >= 16)
+   return -EINVAL;
+
+   return offsetof(user_pt_regs, gprs) + 8 * gpr;
+}
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 77406d2..6db9d80 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -30,6 +30,7 @@ arch/x86/include/uapi/asm/vmx.h
 arch/powerpc/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
+arch/s390/include/uapi/asm/ptrace.h
 arch/s390/include/uapi/asm/sie.h
 arch/arm/include/uapi/asm/kvm.h
 arch/arm64/include/uapi/asm/kvm.h
-- 
1.8.3.1



[PATCH v2 0/6] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Perf tool bpf selftests revealed a broken uapi for s390 and arm64.
With the BPF_PROG_TYPE_PERF_EVENT program type the bpf_perf_event
structure exports the pt_regs structure for all architectures.

This fails for s390 and arm64 because pt_regs are not part of the
user api and kept in-kernel only.  To mitigate the broken uapi,
introduce a wrapper that exports pt_regs in an asm-generic way.
For arm64, export the exising user_pt_regs structure.  For s390,
introduce a user_pt_regs structure that exports the beginning of
pt_regs.

Note that user_pt_regs must export from the beginning of pt_regs
as BPF_PROG_TYPE_PERF_EVENT program type is not the only type for
running BPF programs.

Some more background:
For the bpf_perf_event, there is a uapi definition that is
passed to the BPF program.  For other "probe" points like
trace points, kprobes, and uprobes, there is no uapi and the
BPF program is always passed pt_regs (which is OK as the BPF
program runs in the kernel context).  The perf tool can attach
BPF programs to all of these "probe" points and, optionally,
can create a BPF prologue to access particular arguments
(passed as registers).  For this, it uses DWARF/CFI
information to obtain the register and calls a perf-arch
backend function, regs_query_register_offset().  This function
returns the index into (user_)pt_regs for a particular
register.  Then, perf creates a BPF prologue that accesses
this register based on the passed stucture from the "probe"
point.

Part of this series, are also updates to the testing and bpf selftest
to deal with asm-specifics.  To complete the bpf support in perf, the
the regs_query_register_offset function is added for s390 to support
BPF prologue creation.

Changelog v1 -> v2:
- Correct kbuild test bot issues by including
  asm-generic/bpf_perf_event.h for archictectures that do not have
  their own asm version.
- Added patch to clean-up whitespace and coding style issues in s390
  asm/ptrace.h (#4/6) as suggested by Alexei.


Hendrik Brueckner (6):
  bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type
  s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  s390/uapi: correct whitespace & coding style in asm/ptrace.h
  selftests/bpf: sync kernel headers and introduce arch support in
Makefile
  perf s390: add regs_query_register_offset()

 arch/alpha/include/uapi/asm/Kbuild |   2 +
 arch/arc/include/uapi/asm/Kbuild   |   1 +
 arch/arm/include/uapi/asm/Kbuild   |   1 +
 arch/arm64/include/asm/perf_event.h|   2 +
 arch/arm64/include/uapi/asm/bpf_perf_event.h   |   9 +
 arch/blackfin/include/uapi/asm/Kbuild  |   1 +
 arch/c6x/include/uapi/asm/Kbuild   |   1 +
 arch/cris/include/uapi/asm/Kbuild  |   1 +
 arch/frv/include/uapi/asm/Kbuild   |   2 +
 arch/h8300/include/uapi/asm/Kbuild |   1 +
 arch/hexagon/include/uapi/asm/Kbuild   |   1 +
 arch/ia64/include/uapi/asm/Kbuild  |   1 +
 arch/m32r/include/uapi/asm/Kbuild  |   1 +
 arch/m68k/include/uapi/asm/Kbuild  |   1 +
 arch/metag/include/uapi/asm/Kbuild |   1 +
 arch/microblaze/include/uapi/asm/Kbuild|   1 +
 arch/mips/include/uapi/asm/Kbuild  |   1 +
 arch/mn10300/include/uapi/asm/Kbuild   |   1 +
 arch/nios2/include/uapi/asm/Kbuild |   1 +
 arch/openrisc/include/uapi/asm/Kbuild  |   1 +
 arch/parisc/include/uapi/asm/Kbuild|   1 +
 arch/powerpc/include/uapi/asm/Kbuild   |   1 +
 arch/riscv/include/uapi/asm/Kbuild |   1 +
 arch/s390/include/asm/perf_event.h |   1 +
 arch/s390/include/asm/ptrace.h |  11 +-
 arch/s390/include/uapi/asm/bpf_perf_event.h|   9 +
 arch/s390/include/uapi/asm/ptrace.h| 125 +++---
 arch/score/include/uapi/asm/Kbuild |   1 +
 arch/sh/include/uapi/asm/Kbuild|   1 +
 arch/sparc/include/uapi/asm/Kbuild |   1 +
 arch/tile/include/uapi/asm/Kbuild  |   1 +
 arch/unicore32/include/uapi/asm/Kbuild |   1 +
 arch/x86/include/uapi/asm/Kbuild   |   1 +
 arch/xtensa/include/uapi/asm/Kbuild|   1 +
 include/linux/perf_event.h |   6 +-
 include/uapi/asm-generic/bpf_perf_event.h  |   9 +
 include/uapi/linux/bpf_perf_event.h|   5 +-
 kernel/events/core.c   |   2 +-
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tool

[PATCH v2 0/6] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Perf tool bpf selftests revealed a broken uapi for s390 and arm64.
With the BPF_PROG_TYPE_PERF_EVENT program type the bpf_perf_event
structure exports the pt_regs structure for all architectures.

This fails for s390 and arm64 because pt_regs are not part of the
user api and kept in-kernel only.  To mitigate the broken uapi,
introduce a wrapper that exports pt_regs in an asm-generic way.
For arm64, export the exising user_pt_regs structure.  For s390,
introduce a user_pt_regs structure that exports the beginning of
pt_regs.

Note that user_pt_regs must export from the beginning of pt_regs
as BPF_PROG_TYPE_PERF_EVENT program type is not the only type for
running BPF programs.

Some more background:
For the bpf_perf_event, there is a uapi definition that is
passed to the BPF program.  For other "probe" points like
trace points, kprobes, and uprobes, there is no uapi and the
BPF program is always passed pt_regs (which is OK as the BPF
program runs in the kernel context).  The perf tool can attach
BPF programs to all of these "probe" points and, optionally,
can create a BPF prologue to access particular arguments
(passed as registers).  For this, it uses DWARF/CFI
information to obtain the register and calls a perf-arch
backend function, regs_query_register_offset().  This function
returns the index into (user_)pt_regs for a particular
register.  Then, perf creates a BPF prologue that accesses
this register based on the passed stucture from the "probe"
point.

Part of this series, are also updates to the testing and bpf selftest
to deal with asm-specifics.  To complete the bpf support in perf, the
the regs_query_register_offset function is added for s390 to support
BPF prologue creation.

Changelog v1 -> v2:
- Correct kbuild test bot issues by including
  asm-generic/bpf_perf_event.h for archictectures that do not have
  their own asm version.
- Added patch to clean-up whitespace and coding style issues in s390
  asm/ptrace.h (#4/6) as suggested by Alexei.


Hendrik Brueckner (6):
  bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type
  s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  s390/uapi: correct whitespace & coding style in asm/ptrace.h
  selftests/bpf: sync kernel headers and introduce arch support in
Makefile
  perf s390: add regs_query_register_offset()

 arch/alpha/include/uapi/asm/Kbuild |   2 +
 arch/arc/include/uapi/asm/Kbuild   |   1 +
 arch/arm/include/uapi/asm/Kbuild   |   1 +
 arch/arm64/include/asm/perf_event.h|   2 +
 arch/arm64/include/uapi/asm/bpf_perf_event.h   |   9 +
 arch/blackfin/include/uapi/asm/Kbuild  |   1 +
 arch/c6x/include/uapi/asm/Kbuild   |   1 +
 arch/cris/include/uapi/asm/Kbuild  |   1 +
 arch/frv/include/uapi/asm/Kbuild   |   2 +
 arch/h8300/include/uapi/asm/Kbuild |   1 +
 arch/hexagon/include/uapi/asm/Kbuild   |   1 +
 arch/ia64/include/uapi/asm/Kbuild  |   1 +
 arch/m32r/include/uapi/asm/Kbuild  |   1 +
 arch/m68k/include/uapi/asm/Kbuild  |   1 +
 arch/metag/include/uapi/asm/Kbuild |   1 +
 arch/microblaze/include/uapi/asm/Kbuild|   1 +
 arch/mips/include/uapi/asm/Kbuild  |   1 +
 arch/mn10300/include/uapi/asm/Kbuild   |   1 +
 arch/nios2/include/uapi/asm/Kbuild |   1 +
 arch/openrisc/include/uapi/asm/Kbuild  |   1 +
 arch/parisc/include/uapi/asm/Kbuild|   1 +
 arch/powerpc/include/uapi/asm/Kbuild   |   1 +
 arch/riscv/include/uapi/asm/Kbuild |   1 +
 arch/s390/include/asm/perf_event.h |   1 +
 arch/s390/include/asm/ptrace.h |  11 +-
 arch/s390/include/uapi/asm/bpf_perf_event.h|   9 +
 arch/s390/include/uapi/asm/ptrace.h| 125 +++---
 arch/score/include/uapi/asm/Kbuild |   1 +
 arch/sh/include/uapi/asm/Kbuild|   1 +
 arch/sparc/include/uapi/asm/Kbuild |   1 +
 arch/tile/include/uapi/asm/Kbuild  |   1 +
 arch/unicore32/include/uapi/asm/Kbuild |   1 +
 arch/x86/include/uapi/asm/Kbuild   |   1 +
 arch/xtensa/include/uapi/asm/Kbuild|   1 +
 include/linux/perf_event.h |   6 +-
 include/uapi/asm-generic/bpf_perf_event.h  |   9 +
 include/uapi/linux/bpf_perf_event.h|   5 +-
 kernel/events/core.c   |   2 +-
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tool

[PATCH v2 3/6] arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT program type
by exporting the user_pt_regs structure instead of the pt_regs structure
that is in-kernel only.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Acked-by: Alexei Starovoitov <a...@kernel.org>
Cc: Will Deacon <will.dea...@arm.com>
Cc: Mark Rutland <mark.rutl...@arm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
---
 arch/arm64/include/asm/perf_event.h  | 2 ++
 arch/arm64/include/uapi/asm/bpf_perf_event.h | 9 +
 2 files changed, 11 insertions(+)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/arm64/include/asm/perf_event.h 
b/arch/arm64/include/asm/perf_event.h
index 8d5cbec..f9ccc36 100644
--- a/arch/arm64/include/asm/perf_event.h
+++ b/arch/arm64/include/asm/perf_event.h
@@ -18,6 +18,7 @@
 #define __ASM_PERF_EVENT_H
 
 #include 
+#include 
 
 #defineARMV8_PMU_MAX_COUNTERS  32
 #defineARMV8_PMU_COUNTER_MASK  (ARMV8_PMU_MAX_COUNTERS - 1)
@@ -79,6 +80,7 @@
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs)  perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 #endif
 
 #define perf_arch_fetch_caller_regs(regs, __ip) { \
diff --git a/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
-- 
1.8.3.1



[PATCH v2 3/6] arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT program type
by exporting the user_pt_regs structure instead of the pt_regs structure
that is in-kernel only.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Acked-by: Alexei Starovoitov 
Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Arnaldo Carvalho de Melo 
---
 arch/arm64/include/asm/perf_event.h  | 2 ++
 arch/arm64/include/uapi/asm/bpf_perf_event.h | 9 +
 2 files changed, 11 insertions(+)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/arm64/include/asm/perf_event.h 
b/arch/arm64/include/asm/perf_event.h
index 8d5cbec..f9ccc36 100644
--- a/arch/arm64/include/asm/perf_event.h
+++ b/arch/arm64/include/asm/perf_event.h
@@ -18,6 +18,7 @@
 #define __ASM_PERF_EVENT_H
 
 #include 
+#include 
 
 #defineARMV8_PMU_MAX_COUNTERS  32
 #defineARMV8_PMU_COUNTER_MASK  (ARMV8_PMU_MAX_COUNTERS - 1)
@@ -79,6 +80,7 @@
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs)  perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 #endif
 
 #define perf_arch_fetch_caller_regs(regs, __ip) { \
diff --git a/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
-- 
1.8.3.1



Re: [PATCH 1/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Hi Alexei,

On Sun, Dec 03, 2017 at 09:51:10AM -0800, Alexei Starovoitov wrote:
> On Fri, Dec 01, 2017 at 03:19:04PM +0100, Hendrik Brueckner wrote:
> > --- a/include/uapi/linux/bpf_perf_event.h
> > +++ b/include/uapi/linux/bpf_perf_event.h
> > @@ -8,11 +8,10 @@
> >  #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
> >  #define _UAPI__LINUX_BPF_PERF_EVENT_H__
> >  
> > -#include 
> > -#include 
> > +#include 
> >  
> >  struct bpf_perf_event_data {
> > -   struct pt_regs regs;
> > +   bpf_user_pt_regs_t regs;
> > __u64 sample_period;
> >  };
> 
> Thank you for working on this problem.
> The fix looks great to me.

Thank you.

> While applying it I noticed few nits:
> Applying: selftests/bpf: sync kernel headers and introduce arch support in 
> Makefile
> /w/bpf/.git/rebase-apply/patch:253: trailing whitespace.
> freg_t  fprs[NUM_FPRS];
> /w/bpf/.git/rebase-apply/patch:262: trailing whitespace.
> typedef struct
> /w/bpf/.git/rebase-apply/patch:439: trailing whitespace.
> } lowcore;
> /w/bpf/.git/rebase-apply/patch:490: trailing whitespace.
> } ptprot_area;
> warning: 4 lines add whitespace errors.
> 
> Could you please fix those and resubmit ?

Sure will do.  For that I have to add a clean-up patch for the s390 ptrace.h
uapi header.

> With that fixed feel free to add my
> Acked-by: Alexei Starovoitov <a...@kernel.org>
> to the patches.

Thank you very much, will do!

> I've tested it on arm64 and don't see any issues.

I got a nice message from the build bot, I have some more work on that.
So will respin the series, add you Acked-by, and sent a v2 around.

> When resubmitting could you please reduce cc-list, since this set
> went into spam folder for me and I noticed it only in patchworks.

Will do... I just used what get_maintainers.pl told me :)



Re: [PATCH 1/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-04 Thread Hendrik Brueckner
Hi Alexei,

On Sun, Dec 03, 2017 at 09:51:10AM -0800, Alexei Starovoitov wrote:
> On Fri, Dec 01, 2017 at 03:19:04PM +0100, Hendrik Brueckner wrote:
> > --- a/include/uapi/linux/bpf_perf_event.h
> > +++ b/include/uapi/linux/bpf_perf_event.h
> > @@ -8,11 +8,10 @@
> >  #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
> >  #define _UAPI__LINUX_BPF_PERF_EVENT_H__
> >  
> > -#include 
> > -#include 
> > +#include 
> >  
> >  struct bpf_perf_event_data {
> > -   struct pt_regs regs;
> > +   bpf_user_pt_regs_t regs;
> > __u64 sample_period;
> >  };
> 
> Thank you for working on this problem.
> The fix looks great to me.

Thank you.

> While applying it I noticed few nits:
> Applying: selftests/bpf: sync kernel headers and introduce arch support in 
> Makefile
> /w/bpf/.git/rebase-apply/patch:253: trailing whitespace.
> freg_t  fprs[NUM_FPRS];
> /w/bpf/.git/rebase-apply/patch:262: trailing whitespace.
> typedef struct
> /w/bpf/.git/rebase-apply/patch:439: trailing whitespace.
> } lowcore;
> /w/bpf/.git/rebase-apply/patch:490: trailing whitespace.
> } ptprot_area;
> warning: 4 lines add whitespace errors.
> 
> Could you please fix those and resubmit ?

Sure will do.  For that I have to add a clean-up patch for the s390 ptrace.h
uapi header.

> With that fixed feel free to add my
> Acked-by: Alexei Starovoitov 
> to the patches.

Thank you very much, will do!

> I've tested it on arm64 and don't see any issues.

I got a nice message from the build bot, I have some more work on that.
So will respin the series, add you Acked-by, and sent a v2 around.

> When resubmitting could you please reduce cc-list, since this set
> went into spam folder for me and I noticed it only in patchworks.

Will do... I just used what get_maintainers.pl told me :)



[PATCH 2/5] s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
To mitigate and correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT
program type, introduce a user_pt_regs structure (similar to arm64) that
exports parts from the beginnig of the pt_regs structure.

The export must start with the beginning of the pt_regs structure because
to correctly calculate BPF prologues for perf (regs_query_register_offset()).

For BPF_PROG_TYPE_PERF_EVENT program types, the BPF program is then passed
a user_pt_regs structure.

Note: Depending on future changes to the s390 pt_regs structure, consider
the user_pt_regs structure to be stable for a particular kernel version
only. (Of course, s390 tries to ensure keep it stable as much as possible.)

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Martin Schwidefsky <schwidef...@de.ibm.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Daniel Borkmann <dan...@iogearbox.net>
---
 arch/s390/include/asm/perf_event.h  |  1 +
 arch/s390/include/asm/ptrace.h  | 11 ---
 arch/s390/include/uapi/asm/bpf_perf_event.h |  9 +
 arch/s390/include/uapi/asm/ptrace.h | 11 +++
 4 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/s390/include/asm/perf_event.h 
b/arch/s390/include/asm/perf_event.h
index d6c9d1e..b9c0e36 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -40,6 +40,7 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev,
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs) perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 
 /* Perf pt_regs extension for sample-data-entry indicators */
 struct perf_sf_sde_regs {
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index a3788da..6f70d81 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -74,9 +74,14 @@ enum {
  */
 struct pt_regs 
 {
-   unsigned long args[1];
-   psw_t psw;
-   unsigned long gprs[NUM_GPRS];
+   union {
+   user_pt_regs user_regs;
+   struct {
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+   };
+   };
unsigned long orig_gpr2;
unsigned int int_code;
unsigned int int_parm;
diff --git a/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 0d23c8f..70f7cb2 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -291,6 +291,17 @@
 } s390_regs;
 
 /*
+ * The user_pt_regs structure exports the beginning of
+ * the in-kernel pt_regs structure to user space.
+ */
+typedef struct
+{
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+} user_pt_regs;
+
+/*
  * Now for the user space program event recording (trace) definitions.
  * The following structures are used only for the ptrace interface, don't
  * touch or even look at it if you don't want to modify the user-space
-- 
1.8.3.1



[PATCH 2/5] s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
To mitigate and correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT
program type, introduce a user_pt_regs structure (similar to arm64) that
exports parts from the beginnig of the pt_regs structure.

The export must start with the beginning of the pt_regs structure because
to correctly calculate BPF prologues for perf (regs_query_register_offset()).

For BPF_PROG_TYPE_PERF_EVENT program types, the BPF program is then passed
a user_pt_regs structure.

Note: Depending on future changes to the s390 pt_regs structure, consider
the user_pt_regs structure to be stable for a particular kernel version
only. (Of course, s390 tries to ensure keep it stable as much as possible.)

Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Cc: Martin Schwidefsky 
Cc: Heiko Carstens 
Cc: Arnaldo Carvalho de Melo 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
---
 arch/s390/include/asm/perf_event.h  |  1 +
 arch/s390/include/asm/ptrace.h  | 11 ---
 arch/s390/include/uapi/asm/bpf_perf_event.h |  9 +
 arch/s390/include/uapi/asm/ptrace.h | 11 +++
 4 files changed, 29 insertions(+), 3 deletions(-)
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/s390/include/asm/perf_event.h 
b/arch/s390/include/asm/perf_event.h
index d6c9d1e..b9c0e36 100644
--- a/arch/s390/include/asm/perf_event.h
+++ b/arch/s390/include/asm/perf_event.h
@@ -40,6 +40,7 @@ extern ssize_t cpumf_events_sysfs_show(struct device *dev,
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs) perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 
 /* Perf pt_regs extension for sample-data-entry indicators */
 struct perf_sf_sde_regs {
diff --git a/arch/s390/include/asm/ptrace.h b/arch/s390/include/asm/ptrace.h
index a3788da..6f70d81 100644
--- a/arch/s390/include/asm/ptrace.h
+++ b/arch/s390/include/asm/ptrace.h
@@ -74,9 +74,14 @@ enum {
  */
 struct pt_regs 
 {
-   unsigned long args[1];
-   psw_t psw;
-   unsigned long gprs[NUM_GPRS];
+   union {
+   user_pt_regs user_regs;
+   struct {
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+   };
+   };
unsigned long orig_gpr2;
unsigned int int_code;
unsigned int int_parm;
diff --git a/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/arch/s390/include/uapi/asm/ptrace.h 
b/arch/s390/include/uapi/asm/ptrace.h
index 0d23c8f..70f7cb2 100644
--- a/arch/s390/include/uapi/asm/ptrace.h
+++ b/arch/s390/include/uapi/asm/ptrace.h
@@ -291,6 +291,17 @@
 } s390_regs;
 
 /*
+ * The user_pt_regs structure exports the beginning of
+ * the in-kernel pt_regs structure to user space.
+ */
+typedef struct
+{
+   unsigned long args[1];
+   psw_t psw;
+   unsigned long gprs[NUM_GPRS];
+} user_pt_regs;
+
+/*
  * Now for the user space program event recording (trace) definitions.
  * The following structures are used only for the ptrace interface, don't
  * touch or even look at it if you don't want to modify the user-space
-- 
1.8.3.1



[PATCH 0/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Perf tool bpf selftests revealed a broken uapi for s390 and arm64.
With the BPF_PROG_TYPE_PERF_EVENT program type the bpf_perf_event
structure exports the pt_regs structure for all architectures.

This fails for s390 and arm64 because pt_regs are not part of the
user api and kept in-kernel only.  To mitigate the broken uapi,
introduce a wrapper that exports pt_regs in an asm-generic way.
For arm64, export the exising user_pt_regs structure.  For s390,
introduce a user_pt_regs structure that exports the beginning of
pt_regs.

Note that user_pt_regs must export from the beginning of pt_regs
as BPF_PROG_TYPE_PERF_EVENT program type is not the only type for
running BPF programs.

Some more background:
For the bpf_perf_event, there is a uapi definition that is
passed to the BPF program.  For other "probe" points like
trace points, kprobes, and uprobes, there is no uapi and the
BPF program is always passed pt_regs (which is OK as the BPF
program runs in the kernel context).  The perf tool can attach
BPF programs to all of these "probe" points and, optionally,
can create a BPF prologue to access particular arguments
(passed as registers).  For this, it uses DWARF/CFI
information to obtain the register and calls a perf-arch
backend function, regs_query_register_offset().  This function
returns the index into (user_)pt_regs for a particular
register.  Then, perf creates a BPF prologue that accesses
this register based on the passed stucture from the "probe"
point.

Part of this series, are also updates to the testing and bpf selftest
to deal with asm-specifics.  To complete the bpf support in perf, the
the regs_query_register_offset function is added for s390 to support
BPF prologue creation.

Hendrik Brueckner (5):
  bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type
  s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  selftests/bpf: sync kernel headers and introduce arch support in
Makefile
  perf s390: add regs_query_register_offset()

 arch/arm64/include/asm/perf_event.h|   2 +
 arch/arm64/include/uapi/asm/bpf_perf_event.h   |   9 +
 arch/s390/include/asm/perf_event.h |   1 +
 arch/s390/include/asm/ptrace.h |  11 +-
 arch/s390/include/uapi/asm/bpf_perf_event.h|   9 +
 arch/s390/include/uapi/asm/ptrace.h|  11 +
 include/linux/perf_event.h |   6 +-
 include/uapi/asm-generic/bpf_perf_event.h  |   9 +
 include/uapi/linux/bpf_perf_event.h|   5 +-
 kernel/events/core.c   |   2 +-
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 471 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/perf/arch/s390/Makefile  |   1 +
 tools/perf/arch/s390/util/dwarf-regs.c |  32 +-
 tools/perf/check-headers.sh|   1 +
 tools/testing/selftests/bpf/Makefile   |  14 +-
 19 files changed, 602 insertions(+), 15 deletions(-)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

-- 
1.8.3.1



[PATCH 0/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Perf tool bpf selftests revealed a broken uapi for s390 and arm64.
With the BPF_PROG_TYPE_PERF_EVENT program type the bpf_perf_event
structure exports the pt_regs structure for all architectures.

This fails for s390 and arm64 because pt_regs are not part of the
user api and kept in-kernel only.  To mitigate the broken uapi,
introduce a wrapper that exports pt_regs in an asm-generic way.
For arm64, export the exising user_pt_regs structure.  For s390,
introduce a user_pt_regs structure that exports the beginning of
pt_regs.

Note that user_pt_regs must export from the beginning of pt_regs
as BPF_PROG_TYPE_PERF_EVENT program type is not the only type for
running BPF programs.

Some more background:
For the bpf_perf_event, there is a uapi definition that is
passed to the BPF program.  For other "probe" points like
trace points, kprobes, and uprobes, there is no uapi and the
BPF program is always passed pt_regs (which is OK as the BPF
program runs in the kernel context).  The perf tool can attach
BPF programs to all of these "probe" points and, optionally,
can create a BPF prologue to access particular arguments
(passed as registers).  For this, it uses DWARF/CFI
information to obtain the register and calls a perf-arch
backend function, regs_query_register_offset().  This function
returns the index into (user_)pt_regs for a particular
register.  Then, perf creates a BPF prologue that accesses
this register based on the passed stucture from the "probe"
point.

Part of this series, are also updates to the testing and bpf selftest
to deal with asm-specifics.  To complete the bpf support in perf, the
the regs_query_register_offset function is added for s390 to support
BPF prologue creation.

Hendrik Brueckner (5):
  bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type
  s390/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program
type
  selftests/bpf: sync kernel headers and introduce arch support in
Makefile
  perf s390: add regs_query_register_offset()

 arch/arm64/include/asm/perf_event.h|   2 +
 arch/arm64/include/uapi/asm/bpf_perf_event.h   |   9 +
 arch/s390/include/asm/perf_event.h |   1 +
 arch/s390/include/asm/ptrace.h |  11 +-
 arch/s390/include/uapi/asm/bpf_perf_event.h|   9 +
 arch/s390/include/uapi/asm/ptrace.h|  11 +
 include/linux/perf_event.h |   6 +-
 include/uapi/asm-generic/bpf_perf_event.h  |   9 +
 include/uapi/linux/bpf_perf_event.h|   5 +-
 kernel/events/core.c   |   2 +-
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 471 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/perf/arch/s390/Makefile  |   1 +
 tools/perf/arch/s390/util/dwarf-regs.c |  32 +-
 tools/perf/check-headers.sh|   1 +
 tools/testing/selftests/bpf/Makefile   |  14 +-
 19 files changed, 602 insertions(+), 15 deletions(-)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

-- 
1.8.3.1



[PATCH 1/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Commit 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT
program type") introduced the bpf_perf_event_data structure which
exports the pt_regs structure.  This is OK for multiple architectures
but fail for s390 and arm64 which do not export pt_regs.  Programs
using them, for example, the bpf selftest fail to compile on these
architectures.

For s390, exporting the pt_regs is not an option because s390 wants
to allow changes to it.  For arm64, there is a user_pt_regs structure
that covers parts of the pt_regs structure for use by user space.

To solve the broken uapi for s390 and arm64, introduce an abstract
type for pt_regs and add an asm/bpf_perf_event.h file that concretes
the type.  An asm-generic header file covers the architectures that
export pt_regs today.

The arch-specific enablement for s390 and arm64 follows in separate
commits.

Reported-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Fixes: 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type")
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Ingo Molnar <mi...@redhat.com>
Cc: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Arnd Bergmann <a...@arndb.de>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Daniel Borkmann <dan...@iogearbox.net>
---
 include/linux/perf_event.h| 6 +-
 include/uapi/asm-generic/bpf_perf_event.h | 9 +
 include/uapi/linux/bpf_perf_event.h   | 5 ++---
 kernel/events/core.c  | 2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2c9c87d..7546822 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -15,6 +15,7 @@
 #define _LINUX_PERF_EVENT_H
 
 #include 
+#include 
 
 /*
  * Kernel-internal data types and definitions:
@@ -787,7 +788,7 @@ struct perf_output_handle {
 };
 
 struct bpf_perf_event_data_kern {
-   struct pt_regs *regs;
+   bpf_user_pt_regs_t *regs;
struct perf_sample_data *data;
struct perf_event *event;
 };
@@ -1177,6 +1178,9 @@ extern void perf_tp_event(u16 event_type, u64 count, void 
*record,
(user_mode(regs) ? PERF_RECORD_MISC_USER : 
PERF_RECORD_MISC_KERNEL)
 # define perf_instruction_pointer(regs)instruction_pointer(regs)
 #endif
+#ifndef perf_arch_bpf_user_pt_regs
+# define perf_arch_bpf_user_pt_regs(regs) regs
+#endif
 
 static inline bool has_branch_stack(struct perf_event *event)
 {
diff --git a/include/uapi/asm-generic/bpf_perf_event.h 
b/include/uapi/asm-generic/bpf_perf_event.h
new file mode 100644
index 000..53815d2
--- /dev/null
+++ b/include/uapi/asm-generic/bpf_perf_event.h
@@ -0,0 +1,9 @@
+#ifndef _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__
+
+#include 
+
+/* Export kernel pt_regs structure */
+typedef struct pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__ */
diff --git a/include/uapi/linux/bpf_perf_event.h 
b/include/uapi/linux/bpf_perf_event.h
index af549d4..8f95303 100644
--- a/include/uapi/linux/bpf_perf_event.h
+++ b/include/uapi/linux/bpf_perf_event.h
@@ -8,11 +8,10 @@
 #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
 #define _UAPI__LINUX_BPF_PERF_EVENT_H__
 
-#include 
-#include 
+#include 
 
 struct bpf_perf_event_data {
-   struct pt_regs regs;
+   bpf_user_pt_regs_t regs;
__u64 sample_period;
 };
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 16beab4..ba957b9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7987,11 +7987,11 @@ static void bpf_overflow_handler(struct perf_event 
*event,
 {
struct bpf_perf_event_data_kern ctx = {
.data = data,
-   .regs = regs,
.event = event,
};
int ret = 0;
 
+   ctx.regs = perf_arch_bpf_user_pt_regs(regs);
preempt_disable();
if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1))
goto out;
-- 
1.8.3.1



[PATCH 1/5] bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Commit 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT
program type") introduced the bpf_perf_event_data structure which
exports the pt_regs structure.  This is OK for multiple architectures
but fail for s390 and arm64 which do not export pt_regs.  Programs
using them, for example, the bpf selftest fail to compile on these
architectures.

For s390, exporting the pt_regs is not an option because s390 wants
to allow changes to it.  For arm64, there is a user_pt_regs structure
that covers parts of the pt_regs structure for use by user space.

To solve the broken uapi for s390 and arm64, introduce an abstract
type for pt_regs and add an asm/bpf_perf_event.h file that concretes
the type.  An asm-generic header file covers the architectures that
export pt_regs today.

The arch-specific enablement for s390 and arm64 follows in separate
commits.

Reported-by: Thomas Richter 
Fixes: 0515e5999a466dfe ("bpf: introduce BPF_PROG_TYPE_PERF_EVENT program type")
Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Cc: Arnaldo Carvalho de Melo 
Cc: Peter Zijlstra 
Cc: Ingo Molnar 
Cc: Alexander Shishkin 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Cc: Arnd Bergmann 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
---
 include/linux/perf_event.h| 6 +-
 include/uapi/asm-generic/bpf_perf_event.h | 9 +
 include/uapi/linux/bpf_perf_event.h   | 5 ++---
 kernel/events/core.c  | 2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)
 create mode 100644 include/uapi/asm-generic/bpf_perf_event.h

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 2c9c87d..7546822 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -15,6 +15,7 @@
 #define _LINUX_PERF_EVENT_H
 
 #include 
+#include 
 
 /*
  * Kernel-internal data types and definitions:
@@ -787,7 +788,7 @@ struct perf_output_handle {
 };
 
 struct bpf_perf_event_data_kern {
-   struct pt_regs *regs;
+   bpf_user_pt_regs_t *regs;
struct perf_sample_data *data;
struct perf_event *event;
 };
@@ -1177,6 +1178,9 @@ extern void perf_tp_event(u16 event_type, u64 count, void 
*record,
(user_mode(regs) ? PERF_RECORD_MISC_USER : 
PERF_RECORD_MISC_KERNEL)
 # define perf_instruction_pointer(regs)instruction_pointer(regs)
 #endif
+#ifndef perf_arch_bpf_user_pt_regs
+# define perf_arch_bpf_user_pt_regs(regs) regs
+#endif
 
 static inline bool has_branch_stack(struct perf_event *event)
 {
diff --git a/include/uapi/asm-generic/bpf_perf_event.h 
b/include/uapi/asm-generic/bpf_perf_event.h
new file mode 100644
index 000..53815d2
--- /dev/null
+++ b/include/uapi/asm-generic/bpf_perf_event.h
@@ -0,0 +1,9 @@
+#ifndef _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__
+
+#include 
+
+/* Export kernel pt_regs structure */
+typedef struct pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_GENERIC_BPF_PERF_EVENT_H__ */
diff --git a/include/uapi/linux/bpf_perf_event.h 
b/include/uapi/linux/bpf_perf_event.h
index af549d4..8f95303 100644
--- a/include/uapi/linux/bpf_perf_event.h
+++ b/include/uapi/linux/bpf_perf_event.h
@@ -8,11 +8,10 @@
 #ifndef _UAPI__LINUX_BPF_PERF_EVENT_H__
 #define _UAPI__LINUX_BPF_PERF_EVENT_H__
 
-#include 
-#include 
+#include 
 
 struct bpf_perf_event_data {
-   struct pt_regs regs;
+   bpf_user_pt_regs_t regs;
__u64 sample_period;
 };
 
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 16beab4..ba957b9 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -7987,11 +7987,11 @@ static void bpf_overflow_handler(struct perf_event 
*event,
 {
struct bpf_perf_event_data_kern ctx = {
.data = data,
-   .regs = regs,
.event = event,
};
int ret = 0;
 
+   ctx.regs = perf_arch_bpf_user_pt_regs(regs);
preempt_disable();
if (unlikely(__this_cpu_inc_return(bpf_prog_active) != 1))
goto out;
-- 
1.8.3.1



[PATCH 4/5] selftests/bpf: sync kernel headers and introduce arch support in Makefile

2017-12-01 Thread Hendrik Brueckner
Synchronize the uapi kernel header files which solves the broken
uapi export of pt_regs.  Because of arch-specific uapi headers,
extended the include path in the Makefile.

With this change, the test_verifier program compiles and runs successfully
on s390.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Alexei Starovoitov <a...@kernel.org>
Cc: Daniel Borkmann <dan...@iogearbox.net>
Cc: Shuah Khan <sh...@kernel.org>
---
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 471 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/testing/selftests/bpf/Makefile   |  14 +-
 6 files changed, 514 insertions(+), 4 deletions(-)
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

diff --git a/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/ptrace.h 
b/tools/arch/s390/include/uapi/asm/ptrace.h
new file mode 100644
index 000..70f7cb2
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/ptrace.h
@@ -0,0 +1,471 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ *  S390 version
+ *Copyright IBM Corp. 1999, 2000
+ *Author(s): Denis Joseph Barrow (djbar...@de.ibm.com,barrow...@yahoo.com)
+ */
+
+#ifndef _UAPI_S390_PTRACE_H
+#define _UAPI_S390_PTRACE_H
+
+/*
+ * Offsets in the user_regs_struct. They are used for the ptrace
+ * system call and in entry.S
+ */
+#ifndef __s390x__
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x04
+#define PT_GPR0 0x08
+#define PT_GPR1 0x0C
+#define PT_GPR2 0x10
+#define PT_GPR3 0x14
+#define PT_GPR4 0x18
+#define PT_GPR5 0x1C
+#define PT_GPR6 0x20
+#define PT_GPR7 0x24
+#define PT_GPR8 0x28
+#define PT_GPR9 0x2C
+#define PT_GPR100x30
+#define PT_GPR110x34
+#define PT_GPR120x38
+#define PT_GPR130x3C
+#define PT_GPR140x40
+#define PT_GPR150x44
+#define PT_ACR0 0x48
+#define PT_ACR1 0x4C
+#define PT_ACR2 0x50
+#define PT_ACR3 0x54
+#define PT_ACR40x58
+#define PT_ACR50x5C
+#define PT_ACR60x60
+#define PT_ACR70x64
+#define PT_ACR80x68
+#define PT_ACR90x6C
+#define PT_ACR100x70
+#define PT_ACR110x74
+#define PT_ACR120x78
+#define PT_ACR130x7C
+#define PT_ACR140x80
+#define PT_ACR150x84
+#define PT_ORIGGPR2 0x88
+#define PT_FPC 0x90
+/*
+ * A nasty fact of life that the ptrace api
+ * only supports passing of longs.
+ */
+#define PT_FPR0_HI  0x98
+#define PT_FPR0_LO  0x9C
+#define PT_FPR1_HI  0xA0
+#define PT_FPR1_LO  0xA4
+#define PT_FPR2_HI  0xA8
+#define PT_FPR2_LO  0xAC
+#define PT_FPR3_HI  0xB0
+#define PT_FPR3_LO  0xB4
+#define PT_FPR4_HI  0xB8
+#define PT_FPR4_LO  0xBC
+#define PT_FPR5_HI  0xC0
+#define PT_FPR5_LO  0xC4
+#define PT_FPR6_HI  0xC8
+#define PT_FPR6_LO  0xCC
+#define PT_FPR7_HI  0xD0
+#define PT_FPR7_LO  0xD4
+#define PT_FPR8_HI  0xD8
+#define PT_FPR8_LO  0XDC
+#define PT_FPR9_HI  0xE0
+#define PT_FPR9_LO  0xE4
+#define PT_FPR10_HI 0xE8
+#define PT_FPR10_LO 0xEC
+#define PT_FPR11_HI 0xF0
+#define PT_FPR11_LO 0xF4
+#define PT_FPR12_HI 0xF8
+#define PT_FPR12_LO 0xFC
+#define PT_FPR13_HI 0x100
+#define PT_FPR13_LO 0x104
+#define PT_FPR14_HI 0x108
+#define PT_FPR14_LO 0x10C
+#define PT_FPR15_HI 0x110
+#define PT_FPR15_LO 0x114
+#define PT_CR_90x118
+#define PT_CR_100x11C
+#define PT_CR_110x120
+#define PT_IEEE_IP  0x13C
+#define PT_LASTOFF  PT_IEEE_IP
+#define PT_ENDREGS  0x140-1
+
+#define GPR_SIZE   4
+#define CR_SIZE4
+
+#define STACK_FRAME_OVERHEAD   96

[PATCH 4/5] selftests/bpf: sync kernel headers and introduce arch support in Makefile

2017-12-01 Thread Hendrik Brueckner
Synchronize the uapi kernel header files which solves the broken
uapi export of pt_regs.  Because of arch-specific uapi headers,
extended the include path in the Makefile.

With this change, the test_verifier program compiles and runs successfully
on s390.

Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Cc: Alexei Starovoitov 
Cc: Daniel Borkmann 
Cc: Shuah Khan 
---
 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h |   9 +
 tools/arch/s390/include/uapi/asm/bpf_perf_event.h  |   9 +
 tools/arch/s390/include/uapi/asm/ptrace.h  | 471 +
 tools/include/uapi/asm-generic/bpf_perf_event.h|   9 +
 tools/include/uapi/linux/bpf_perf_event.h  |   6 +-
 tools/testing/selftests/bpf/Makefile   |  14 +-
 6 files changed, 514 insertions(+), 4 deletions(-)
 create mode 100644 tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/bpf_perf_event.h
 create mode 100644 tools/arch/s390/include/uapi/asm/ptrace.h
 create mode 100644 tools/include/uapi/asm-generic/bpf_perf_event.h

diff --git a/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/tools/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/bpf_perf_event.h 
b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..cefe7c7
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
diff --git a/tools/arch/s390/include/uapi/asm/ptrace.h 
b/tools/arch/s390/include/uapi/asm/ptrace.h
new file mode 100644
index 000..70f7cb2
--- /dev/null
+++ b/tools/arch/s390/include/uapi/asm/ptrace.h
@@ -0,0 +1,471 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ *  S390 version
+ *Copyright IBM Corp. 1999, 2000
+ *Author(s): Denis Joseph Barrow (djbar...@de.ibm.com,barrow...@yahoo.com)
+ */
+
+#ifndef _UAPI_S390_PTRACE_H
+#define _UAPI_S390_PTRACE_H
+
+/*
+ * Offsets in the user_regs_struct. They are used for the ptrace
+ * system call and in entry.S
+ */
+#ifndef __s390x__
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x04
+#define PT_GPR0 0x08
+#define PT_GPR1 0x0C
+#define PT_GPR2 0x10
+#define PT_GPR3 0x14
+#define PT_GPR4 0x18
+#define PT_GPR5 0x1C
+#define PT_GPR6 0x20
+#define PT_GPR7 0x24
+#define PT_GPR8 0x28
+#define PT_GPR9 0x2C
+#define PT_GPR100x30
+#define PT_GPR110x34
+#define PT_GPR120x38
+#define PT_GPR130x3C
+#define PT_GPR140x40
+#define PT_GPR150x44
+#define PT_ACR0 0x48
+#define PT_ACR1 0x4C
+#define PT_ACR2 0x50
+#define PT_ACR3 0x54
+#define PT_ACR40x58
+#define PT_ACR50x5C
+#define PT_ACR60x60
+#define PT_ACR70x64
+#define PT_ACR80x68
+#define PT_ACR90x6C
+#define PT_ACR100x70
+#define PT_ACR110x74
+#define PT_ACR120x78
+#define PT_ACR130x7C
+#define PT_ACR140x80
+#define PT_ACR150x84
+#define PT_ORIGGPR2 0x88
+#define PT_FPC 0x90
+/*
+ * A nasty fact of life that the ptrace api
+ * only supports passing of longs.
+ */
+#define PT_FPR0_HI  0x98
+#define PT_FPR0_LO  0x9C
+#define PT_FPR1_HI  0xA0
+#define PT_FPR1_LO  0xA4
+#define PT_FPR2_HI  0xA8
+#define PT_FPR2_LO  0xAC
+#define PT_FPR3_HI  0xB0
+#define PT_FPR3_LO  0xB4
+#define PT_FPR4_HI  0xB8
+#define PT_FPR4_LO  0xBC
+#define PT_FPR5_HI  0xC0
+#define PT_FPR5_LO  0xC4
+#define PT_FPR6_HI  0xC8
+#define PT_FPR6_LO  0xCC
+#define PT_FPR7_HI  0xD0
+#define PT_FPR7_LO  0xD4
+#define PT_FPR8_HI  0xD8
+#define PT_FPR8_LO  0XDC
+#define PT_FPR9_HI  0xE0
+#define PT_FPR9_LO  0xE4
+#define PT_FPR10_HI 0xE8
+#define PT_FPR10_LO 0xEC
+#define PT_FPR11_HI 0xF0
+#define PT_FPR11_LO 0xF4
+#define PT_FPR12_HI 0xF8
+#define PT_FPR12_LO 0xFC
+#define PT_FPR13_HI 0x100
+#define PT_FPR13_LO 0x104
+#define PT_FPR14_HI 0x108
+#define PT_FPR14_LO 0x10C
+#define PT_FPR15_HI 0x110
+#define PT_FPR15_LO 0x114
+#define PT_CR_90x118
+#define PT_CR_100x11C
+#define PT_CR_110x120
+#define PT_IEEE_IP  0x13C
+#define PT_LASTOFF  PT_IEEE_IP
+#define PT_ENDREGS  0x140-1
+
+#define GPR_SIZE   4
+#define CR_SIZE4
+
+#define STACK_FRAME_OVERHEAD   96  /* size of minimum stack frame */
+
+#else /* __s390x__ */
+
+#define PT_PSWMASK  0x00
+#define PT_PSWADDR  0x08
+#define PT_GPR0 0x10

[PATCH 5/5] perf s390: add regs_query_register_offset()

2017-12-01 Thread Hendrik Brueckner
The regs_query_register_offset() helper function converts
register name like "%r0" to an offset of a register in user_pt_regs
It is required by the BPF prologue generator.

The user_pt_regs structure was recently added to "asm/ptrace.h".
Hence, update tools/perf/check-headers.sh to keep the header file
in sync with kernel changes.

Suggested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-and-tested-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
Cc: Jiri Olsa <jo...@redhat.com>
Cc: Heiko Carstens <heiko.carst...@de.ibm.com>
---
 tools/perf/arch/s390/Makefile  |  1 +
 tools/perf/arch/s390/util/dwarf-regs.c | 32 +---
 tools/perf/check-headers.sh|  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 21322e0..09ba923 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
+PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
diff --git a/tools/perf/arch/s390/util/dwarf-regs.c 
b/tools/perf/arch/s390/util/dwarf-regs.c
index f47576c..a8ace5c 100644
--- a/tools/perf/arch/s390/util/dwarf-regs.c
+++ b/tools/perf/arch/s390/util/dwarf-regs.c
@@ -2,17 +2,43 @@
 /*
  * Mapping of DWARF debug register numbers into register names.
  *
- *Copyright IBM Corp. 2010
- *Author(s): Heiko Carstens <heiko.carst...@de.ibm.com>,
+ * Copyright IBM Corp. 2010, 2017
+ * Author(s): Heiko Carstens <heiko.carst...@de.ibm.com>,
+ *   Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
  *
  */
 
+#include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include "dwarf-regs-table.h"
 
 const char *get_arch_regstr(unsigned int n)
 {
return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n];
 }
+
+/*
+ * Convert the register name into an offset to struct pt_regs (kernel).
+ * This is required by the BPF prologue generator.  The BPF
+ * program is called in the BPF overflow handler in the perf
+ * core.
+ */
+int regs_query_register_offset(const char *name)
+{
+   unsigned long gpr;
+
+   if (!name || strncmp(name, "%r", 2))
+   return -EINVAL;
+
+   errno = 0;
+   gpr = strtoul(name + 2, NULL, 10);
+   if (errno || gpr >= 16)
+   return -EINVAL;
+
+   return offsetof(user_pt_regs, gprs) + 8 * gpr;
+}
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 77406d2..6db9d80 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -30,6 +30,7 @@ arch/x86/include/uapi/asm/vmx.h
 arch/powerpc/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
+arch/s390/include/uapi/asm/ptrace.h
 arch/s390/include/uapi/asm/sie.h
 arch/arm/include/uapi/asm/kvm.h
 arch/arm64/include/uapi/asm/kvm.h
-- 
1.8.3.1



[PATCH 5/5] perf s390: add regs_query_register_offset()

2017-12-01 Thread Hendrik Brueckner
The regs_query_register_offset() helper function converts
register name like "%r0" to an offset of a register in user_pt_regs
It is required by the BPF prologue generator.

The user_pt_regs structure was recently added to "asm/ptrace.h".
Hence, update tools/perf/check-headers.sh to keep the header file
in sync with kernel changes.

Suggested-by: Thomas Richter 
Signed-off-by: Hendrik Brueckner 
Reviewed-and-tested-by: Thomas Richter 
Cc: Arnaldo Carvalho de Melo 
Cc: Jiri Olsa 
Cc: Heiko Carstens 
---
 tools/perf/arch/s390/Makefile  |  1 +
 tools/perf/arch/s390/util/dwarf-regs.c | 32 +---
 tools/perf/check-headers.sh|  1 +
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/tools/perf/arch/s390/Makefile b/tools/perf/arch/s390/Makefile
index 21322e0..09ba923 100644
--- a/tools/perf/arch/s390/Makefile
+++ b/tools/perf/arch/s390/Makefile
@@ -2,3 +2,4 @@ ifndef NO_DWARF
 PERF_HAVE_DWARF_REGS := 1
 endif
 HAVE_KVM_STAT_SUPPORT := 1
+PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
diff --git a/tools/perf/arch/s390/util/dwarf-regs.c 
b/tools/perf/arch/s390/util/dwarf-regs.c
index f47576c..a8ace5c 100644
--- a/tools/perf/arch/s390/util/dwarf-regs.c
+++ b/tools/perf/arch/s390/util/dwarf-regs.c
@@ -2,17 +2,43 @@
 /*
  * Mapping of DWARF debug register numbers into register names.
  *
- *Copyright IBM Corp. 2010
- *Author(s): Heiko Carstens ,
+ * Copyright IBM Corp. 2010, 2017
+ * Author(s): Heiko Carstens ,
+ *   Hendrik Brueckner 
  *
  */
 
+#include 
 #include 
-#include 
+#include 
 #include 
+#include 
+#include 
+#include 
 #include "dwarf-regs-table.h"
 
 const char *get_arch_regstr(unsigned int n)
 {
return (n >= ARRAY_SIZE(s390_dwarf_regs)) ? NULL : s390_dwarf_regs[n];
 }
+
+/*
+ * Convert the register name into an offset to struct pt_regs (kernel).
+ * This is required by the BPF prologue generator.  The BPF
+ * program is called in the BPF overflow handler in the perf
+ * core.
+ */
+int regs_query_register_offset(const char *name)
+{
+   unsigned long gpr;
+
+   if (!name || strncmp(name, "%r", 2))
+   return -EINVAL;
+
+   errno = 0;
+   gpr = strtoul(name + 2, NULL, 10);
+   if (errno || gpr >= 16)
+   return -EINVAL;
+
+   return offsetof(user_pt_regs, gprs) + 8 * gpr;
+}
diff --git a/tools/perf/check-headers.sh b/tools/perf/check-headers.sh
index 77406d2..6db9d80 100755
--- a/tools/perf/check-headers.sh
+++ b/tools/perf/check-headers.sh
@@ -30,6 +30,7 @@ arch/x86/include/uapi/asm/vmx.h
 arch/powerpc/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm.h
 arch/s390/include/uapi/asm/kvm_perf.h
+arch/s390/include/uapi/asm/ptrace.h
 arch/s390/include/uapi/asm/sie.h
 arch/arm/include/uapi/asm/kvm.h
 arch/arm64/include/uapi/asm/kvm.h
-- 
1.8.3.1



[PATCH 3/5] arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT program type
by exporting the user_pt_regs structure instead of the pt_regs structure
that is in-kernel only.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Reviewed-by: Thomas Richter <tmri...@linux.vnet.ibm.com>
Cc: Will Deacon <will.dea...@arm.com>
Cc: Mark Rutland <mark.rutl...@arm.com>
Cc: Arnaldo Carvalho de Melo <a...@kernel.org>
---
 arch/arm64/include/asm/perf_event.h  | 2 ++
 arch/arm64/include/uapi/asm/bpf_perf_event.h | 9 +
 2 files changed, 11 insertions(+)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/arm64/include/asm/perf_event.h 
b/arch/arm64/include/asm/perf_event.h
index 8d5cbec..f9ccc36 100644
--- a/arch/arm64/include/asm/perf_event.h
+++ b/arch/arm64/include/asm/perf_event.h
@@ -18,6 +18,7 @@
 #define __ASM_PERF_EVENT_H
 
 #include 
+#include 
 
 #defineARMV8_PMU_MAX_COUNTERS  32
 #defineARMV8_PMU_COUNTER_MASK  (ARMV8_PMU_MAX_COUNTERS - 1)
@@ -79,6 +80,7 @@
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs)  perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 #endif
 
 #define perf_arch_fetch_caller_regs(regs, __ip) { \
diff --git a/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
-- 
1.8.3.1



[PATCH 3/5] arm64/bpf: correct broken uapi for BPF_PROG_TYPE_PERF_EVENT program type

2017-12-01 Thread Hendrik Brueckner
Correct the broken uapi for the BPF_PROG_TYPE_PERF_EVENT program type
by exporting the user_pt_regs structure instead of the pt_regs structure
that is in-kernel only.

Signed-off-by: Hendrik Brueckner 
Reviewed-by: Thomas Richter 
Cc: Will Deacon 
Cc: Mark Rutland 
Cc: Arnaldo Carvalho de Melo 
---
 arch/arm64/include/asm/perf_event.h  | 2 ++
 arch/arm64/include/uapi/asm/bpf_perf_event.h | 9 +
 2 files changed, 11 insertions(+)
 create mode 100644 arch/arm64/include/uapi/asm/bpf_perf_event.h

diff --git a/arch/arm64/include/asm/perf_event.h 
b/arch/arm64/include/asm/perf_event.h
index 8d5cbec..f9ccc36 100644
--- a/arch/arm64/include/asm/perf_event.h
+++ b/arch/arm64/include/asm/perf_event.h
@@ -18,6 +18,7 @@
 #define __ASM_PERF_EVENT_H
 
 #include 
+#include 
 
 #defineARMV8_PMU_MAX_COUNTERS  32
 #defineARMV8_PMU_COUNTER_MASK  (ARMV8_PMU_MAX_COUNTERS - 1)
@@ -79,6 +80,7 @@
 extern unsigned long perf_instruction_pointer(struct pt_regs *regs);
 extern unsigned long perf_misc_flags(struct pt_regs *regs);
 #define perf_misc_flags(regs)  perf_misc_flags(regs)
+#define perf_arch_bpf_user_pt_regs(regs) >user_regs
 #endif
 
 #define perf_arch_fetch_caller_regs(regs, __ip) { \
diff --git a/arch/arm64/include/uapi/asm/bpf_perf_event.h 
b/arch/arm64/include/uapi/asm/bpf_perf_event.h
new file mode 100644
index 000..b551b74
--- /dev/null
+++ b/arch/arm64/include/uapi/asm/bpf_perf_event.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _UAPI__ASM_BPF_PERF_EVENT_H__
+#define _UAPI__ASM_BPF_PERF_EVENT_H__
+
+#include 
+
+typedef struct user_pt_regs bpf_user_pt_regs_t;
+
+#endif /* _UAPI__ASM_BPF_PERF_EVENT_H__ */
-- 
1.8.3.1



Re: [PATCH] HID: rmi: Check that a device is a RMI device before calling RMI functions

2017-10-18 Thread Hendrik Langer
On 18/10/17 16:13, Jiri Kosina wrote:
> On Wed, 18 Oct 2017, Benjamin Tissoires wrote:
> 
>>> The hid-rmi driver may handle non rmi devices on composite USB devices.
>>> Callbacks need to make sure that the current device is a RMI device before
>>> calling RMI specific functions. Most callbacks already have this check, but
>>> this patch adds checks to the remaining callbacks.
>>>
>>> Signed-off-by: Andrew Duggan <adug...@synaptics.com>
>>> ---
>>> This is the patch which hopefully will address the X1 tablet dock freeze:
>>> http://www.spinics.net/lists/linux-input/msg53582.html
>>>
>>> I was not able to test on a composite USB device so I have not tested 
>>> confirmed
>>> this will fix the reported issues. But, based on the description I think it 
>>> will.
>>> I also added a check for rmi_raw_event() since it could be possible that 
>>> another
>>> hid device using one of the same report IDs as an RMI device could result 
>>> in calling
>>> into unitialized RMI functions. It was also the only callbacl left not 
>>> checking the
>>> RMI_DEVICE flag. I wonder if this explains the attach crash.
>>>
>>> Anyway, I would appriciate it if Hendrik or someone else with the device 
>>> could test this
>>> patch to confirm it fixes the reported behavior.
>>
>> Shouldn't rmi_hid_reset() also get the same check?
> 
> I think so as well.
> 
>>
>> From what I can see, even if the patch doesn't fix the immediate issue, 
>> such a patch should definitively go in as those checks are clearly 
>> missing.
> 
> Agreed; however I'd like to get Hendrik's Tested-by: if possible in case 
> this really fixes the issue, so I am not merging it right away.
> 
> Hendrik, are you by any chance able to test this patch in a reasonable 
> timeframe please?
> 
> Thanks!
> 

Tested-by: Hendrik Langer <hendrik.lan...@gmx.de>

Confirmed, the patch fixes the probem for me.
All freezes/Oops and rmi or input related error messages are gone. Even
keyboard and touchpad are working now!

Tested 4.13 and 4.14.0-rc3 (Debian) with the patch, repeated (un)docking
and booting with/without keyboard dock attached.

Thank you very much!
Hendrik


Re: [PATCH] HID: rmi: Check that a device is a RMI device before calling RMI functions

2017-10-18 Thread Hendrik Langer
On 18/10/17 16:13, Jiri Kosina wrote:
> On Wed, 18 Oct 2017, Benjamin Tissoires wrote:
> 
>>> The hid-rmi driver may handle non rmi devices on composite USB devices.
>>> Callbacks need to make sure that the current device is a RMI device before
>>> calling RMI specific functions. Most callbacks already have this check, but
>>> this patch adds checks to the remaining callbacks.
>>>
>>> Signed-off-by: Andrew Duggan 
>>> ---
>>> This is the patch which hopefully will address the X1 tablet dock freeze:
>>> http://www.spinics.net/lists/linux-input/msg53582.html
>>>
>>> I was not able to test on a composite USB device so I have not tested 
>>> confirmed
>>> this will fix the reported issues. But, based on the description I think it 
>>> will.
>>> I also added a check for rmi_raw_event() since it could be possible that 
>>> another
>>> hid device using one of the same report IDs as an RMI device could result 
>>> in calling
>>> into unitialized RMI functions. It was also the only callbacl left not 
>>> checking the
>>> RMI_DEVICE flag. I wonder if this explains the attach crash.
>>>
>>> Anyway, I would appriciate it if Hendrik or someone else with the device 
>>> could test this
>>> patch to confirm it fixes the reported behavior.
>>
>> Shouldn't rmi_hid_reset() also get the same check?
> 
> I think so as well.
> 
>>
>> From what I can see, even if the patch doesn't fix the immediate issue, 
>> such a patch should definitively go in as those checks are clearly 
>> missing.
> 
> Agreed; however I'd like to get Hendrik's Tested-by: if possible in case 
> this really fixes the issue, so I am not merging it right away.
> 
> Hendrik, are you by any chance able to test this patch in a reasonable 
> timeframe please?
> 
> Thanks!
> 

Tested-by: Hendrik Langer 

Confirmed, the patch fixes the probem for me.
All freezes/Oops and rmi or input related error messages are gone. Even
keyboard and touchpad are working now!

Tested 4.13 and 4.14.0-rc3 (Debian) with the patch, repeated (un)docking
and booting with/without keyboard dock attached.

Thank you very much!
Hendrik


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

2017-06-21 Thread tip-bot for Hendrik Brueckner
Commit-ID:  8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Gitweb: http://git.kernel.org/tip/8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Author: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
AuthorDate: Tue, 20 Jun 2017 12:26:39 +0200
Committer:  Ingo Molnar <mi...@kernel.org>
CommitDate: Wed, 21 Jun 2017 11:58:30 +0200

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

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

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

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

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

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

With this commit, the perf tool then reports:

  failed to mmap with 95 (Operation not supported)

which is more clear.

Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
Acked-by: Alexander Shishkin <alexander.shish...@linux.intel.com>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Pu Hou <bjho...@linux.vnet.ibm.com>
Cc: Thomas Gleixner <t...@linutronix.de>
Cc: Thomas-Mich Richter <tmri...@linux.vnet.ibm.com>
Cc: a...@kernel.org
Cc: linux-s...@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1497954399-6355-1-git-send-email-brueck...@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 2831480..ee97196 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event 
*event,
int ret = -ENOMEM, max_order = 0;
 
if (!has_aux(event))
-   return -ENOTSUPP;
+   return -EOPNOTSUPP;
 
if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
/*


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

2017-06-21 Thread tip-bot for Hendrik Brueckner
Commit-ID:  8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Gitweb: http://git.kernel.org/tip/8a1898db51a3390241cd5fae267dc8aaa9db0f8b
Author: Hendrik Brueckner 
AuthorDate: Tue, 20 Jun 2017 12:26:39 +0200
Committer:  Ingo Molnar 
CommitDate: Wed, 21 Jun 2017 11:58:30 +0200

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

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

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

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

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

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

With this commit, the perf tool then reports:

  failed to mmap with 95 (Operation not supported)

which is more clear.

Signed-off-by: Hendrik Brueckner 
Acked-by: Alexander Shishkin 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Pu Hou 
Cc: Thomas Gleixner 
Cc: Thomas-Mich Richter 
Cc: a...@kernel.org
Cc: linux-s...@vger.kernel.org
Link: 
http://lkml.kernel.org/r/1497954399-6355-1-git-send-email-brueck...@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar 
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 2831480..ee97196 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event 
*event,
int ret = -ENOMEM, max_order = 0;
 
if (!has_aux(event))
-   return -ENOTSUPP;
+   return -EOPNOTSUPP;
 
if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
/*


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

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

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

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

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

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

With this commit, the perf tool then reports:

  failed to mmap with 95 (Operation not supported)

which is more clear.

Cc: Pu Hou <bjho...@linux.vnet.ibm.com>
Cc: Thomas-Mich Richter <tmri...@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 2831480..ee97196 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event 
*event,
int ret = -ENOMEM, max_order = 0;
 
if (!has_aux(event))
-   return -ENOTSUPP;
+   return -EOPNOTSUPP;
 
if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
/*
-- 
1.8.3.1



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

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

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

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

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

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

With this commit, the perf tool then reports:

  failed to mmap with 95 (Operation not supported)

which is more clear.

Cc: Pu Hou 
Cc: Thomas-Mich Richter 
Signed-off-by: Hendrik Brueckner 
---
 kernel/events/ring_buffer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c
index 2831480..ee97196 100644
--- a/kernel/events/ring_buffer.c
+++ b/kernel/events/ring_buffer.c
@@ -580,7 +580,7 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event 
*event,
int ret = -ENOMEM, max_order = 0;
 
if (!has_aux(event))
-   return -ENOTSUPP;
+   return -EOPNOTSUPP;
 
if (event->pmu->capabilities & PERF_PMU_CAP_AUX_NO_SG) {
/*
-- 
1.8.3.1



Re: [PATCH v1 3/8] clk: meson: add audio clock divider support

2017-03-28 Thread Hendrik v. Raven
On Tue, Mar 28, 2017 at 04:46:00PM +0200, Jerome Brunet wrote:
> The audio divider needs a specific clock divider driver.
> With am mpll parent clock, which is able to provide a fairly precise rate,
> the generic divider tends to select low value of the divider. In such case
> the quality of the clock is very poor. For the same final rate, maximizing
> the audio clock divider value and selecting the corresponding mpll rate
> gives better results. This is what this driver aims to acheive. So far, so
> good.
> 
> Signed-off-by: Jerome Brunet 
> ---
>  drivers/clk/meson/Makefile|   2 +-
>  drivers/clk/meson/clk-audio-divider.c | 149 
> ++
>  drivers/clk/meson/clkc.h  |  10 +++
>  3 files changed, 160 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/clk/meson/clk-audio-divider.c
> 
> diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
> index 349583405b7c..83b6d9d65aa1 100644
> --- a/drivers/clk/meson/Makefile
> +++ b/drivers/clk/meson/Makefile
> @@ -2,6 +2,6 @@
>  # Makefile for Meson specific clk
>  #
>  
> -obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o
> +obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o 
> clk-audio-divider.o
>  obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
>  obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o
> diff --git a/drivers/clk/meson/clk-audio-divider.c 
> b/drivers/clk/meson/clk-audio-divider.c
> new file mode 100644
> index ..ac713b9ea84a
> --- /dev/null
> +++ b/drivers/clk/meson/clk-audio-divider.c
> @@ -0,0 +1,149 @@
> +/*
> + * Copyright (c) 2017 AmLogic, Inc.
> + * Author: Jerome Brunet 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +/*
> + * i2s master clock divider: The algorithm of the generic clk-divider used 
> with
> + * a very precise clock parent such as the mpll tends to select a low divider
> + * factor. This gives very results with this particular divider, especially 
> with
a "poor" appears to be missing here

> + * high frequencies (> 100 MHz)
> + *
> + * This driver try to select the maximum possible divider with the rate the
> + * upstream clock can provide.
> + */
> +
> +#include 
> +#include "clkc.h"
> +
> +#define to_meson_clk_audio_divider(_hw) container_of(_hw, \
> + struct meson_clk_audio_divider, hw)
> +
> +static int _div_round(unsigned long parent_rate, unsigned long rate,
> +   unsigned long flags)
> +{
> + if (flags & CLK_DIVIDER_ROUND_CLOSEST)
> + return DIV_ROUND_CLOSEST_ULL((u64)parent_rate, rate);
> +
> + return DIV_ROUND_UP_ULL((u64)parent_rate, rate);
> +}
> +
> +static int _get_val(unsigned long parent_rate, unsigned long rate)
> +{
> + return DIV_ROUND_UP_ULL((u64)parent_rate, rate) - 1;
> +}
> +
> +static int _valid_divider(struct clk_hw *hw, int divider)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + int max_divider;
> + u8 width;
> +
> + width = adiv->div.width;
> + max_divider = 1 << width;
> +
> + if (divider < 1)
> + return 1;
> + else if (divider > max_divider)
> + return max_divider;
> +
> + return divider;
This can be replaced by 
return clamp(divider, 1, max_divider);

> +}
> +
> +static unsigned long audio_divider_recalc_rate(struct clk_hw *hw,
> +unsigned long parent_rate)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + struct parm *p;
> + unsigned long reg, divider;
> +
> + p = >div;
> + reg = readl(adiv->base + p->reg_off);
> + divider = PARM_GET(p->width, p->shift, reg) + 1;
> +
> + return DIV_ROUND_UP_ULL((u64)parent_rate, divider);
> +}
> +
> +static long audio_divider_round_rate(struct clk_hw *hw,
> +  unsigned long rate,
> +  unsigned long *parent_rate)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + unsigned long max_prate;
> + int divider;
> +
> + if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
> + divider = _div_round(*parent_rate, rate, adiv->flags);
> + divider = _valid_divider(hw, 

Re: [PATCH v1 3/8] clk: meson: add audio clock divider support

2017-03-28 Thread Hendrik v. Raven
On Tue, Mar 28, 2017 at 04:46:00PM +0200, Jerome Brunet wrote:
> The audio divider needs a specific clock divider driver.
> With am mpll parent clock, which is able to provide a fairly precise rate,
> the generic divider tends to select low value of the divider. In such case
> the quality of the clock is very poor. For the same final rate, maximizing
> the audio clock divider value and selecting the corresponding mpll rate
> gives better results. This is what this driver aims to acheive. So far, so
> good.
> 
> Signed-off-by: Jerome Brunet 
> ---
>  drivers/clk/meson/Makefile|   2 +-
>  drivers/clk/meson/clk-audio-divider.c | 149 
> ++
>  drivers/clk/meson/clkc.h  |  10 +++
>  3 files changed, 160 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/clk/meson/clk-audio-divider.c
> 
> diff --git a/drivers/clk/meson/Makefile b/drivers/clk/meson/Makefile
> index 349583405b7c..83b6d9d65aa1 100644
> --- a/drivers/clk/meson/Makefile
> +++ b/drivers/clk/meson/Makefile
> @@ -2,6 +2,6 @@
>  # Makefile for Meson specific clk
>  #
>  
> -obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o
> +obj-$(CONFIG_COMMON_CLK_AMLOGIC) += clk-pll.o clk-cpu.o clk-mpll.o 
> clk-audio-divider.o
>  obj-$(CONFIG_COMMON_CLK_MESON8B) += meson8b.o
>  obj-$(CONFIG_COMMON_CLK_GXBB) += gxbb.o gxbb-aoclk.o
> diff --git a/drivers/clk/meson/clk-audio-divider.c 
> b/drivers/clk/meson/clk-audio-divider.c
> new file mode 100644
> index ..ac713b9ea84a
> --- /dev/null
> +++ b/drivers/clk/meson/clk-audio-divider.c
> @@ -0,0 +1,149 @@
> +/*
> + * Copyright (c) 2017 AmLogic, Inc.
> + * Author: Jerome Brunet 
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms and conditions of the GNU General Public License,
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope it will be useful, but WITHOUT
> + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
> + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
> + * more details.
> + *
> + * You should have received a copy of the GNU General Public License along 
> with
> + * this program.  If not, see .
> + */
> +
> +/*
> + * i2s master clock divider: The algorithm of the generic clk-divider used 
> with
> + * a very precise clock parent such as the mpll tends to select a low divider
> + * factor. This gives very results with this particular divider, especially 
> with
a "poor" appears to be missing here

> + * high frequencies (> 100 MHz)
> + *
> + * This driver try to select the maximum possible divider with the rate the
> + * upstream clock can provide.
> + */
> +
> +#include 
> +#include "clkc.h"
> +
> +#define to_meson_clk_audio_divider(_hw) container_of(_hw, \
> + struct meson_clk_audio_divider, hw)
> +
> +static int _div_round(unsigned long parent_rate, unsigned long rate,
> +   unsigned long flags)
> +{
> + if (flags & CLK_DIVIDER_ROUND_CLOSEST)
> + return DIV_ROUND_CLOSEST_ULL((u64)parent_rate, rate);
> +
> + return DIV_ROUND_UP_ULL((u64)parent_rate, rate);
> +}
> +
> +static int _get_val(unsigned long parent_rate, unsigned long rate)
> +{
> + return DIV_ROUND_UP_ULL((u64)parent_rate, rate) - 1;
> +}
> +
> +static int _valid_divider(struct clk_hw *hw, int divider)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + int max_divider;
> + u8 width;
> +
> + width = adiv->div.width;
> + max_divider = 1 << width;
> +
> + if (divider < 1)
> + return 1;
> + else if (divider > max_divider)
> + return max_divider;
> +
> + return divider;
This can be replaced by 
return clamp(divider, 1, max_divider);

> +}
> +
> +static unsigned long audio_divider_recalc_rate(struct clk_hw *hw,
> +unsigned long parent_rate)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + struct parm *p;
> + unsigned long reg, divider;
> +
> + p = >div;
> + reg = readl(adiv->base + p->reg_off);
> + divider = PARM_GET(p->width, p->shift, reg) + 1;
> +
> + return DIV_ROUND_UP_ULL((u64)parent_rate, divider);
> +}
> +
> +static long audio_divider_round_rate(struct clk_hw *hw,
> +  unsigned long rate,
> +  unsigned long *parent_rate)
> +{
> + struct meson_clk_audio_divider *adiv =
> + to_meson_clk_audio_divider(hw);
> + unsigned long max_prate;
> + int divider;
> +
> + if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) {
> + divider = _div_round(*parent_rate, rate, adiv->flags);
> + divider = _valid_divider(hw, divider);
> + return 

[PATCH v2] staging: bcm2835-audio: remove unused macro

2017-02-14 Thread Hendrik v. Raven
The VC_AUDIO_MAX_MSG_LEN macro is not used by anything in the
bcm2835-audio driver.

Signed-off-by: Hendrik v. Raven <hend...@consetetur.de>
---
v2:
 - rebased against next-20170214

---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 928dd6009510..da96f1bc2516 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -21,9 +21,6 @@
 /* FourCC code used for VCHI connection */
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
-/* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof(VC_AUDIO_MSG_T))
-
 /*
  *  List of screens that are currently supported
  *  All message types supported for HOST->VC direction
-- 
2.11.0



[PATCH v2] staging: bcm2835-audio: remove unused macro

2017-02-14 Thread Hendrik v. Raven
The VC_AUDIO_MAX_MSG_LEN macro is not used by anything in the
bcm2835-audio driver.

Signed-off-by: Hendrik v. Raven 
---
v2:
 - rebased against next-20170214

---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 928dd6009510..da96f1bc2516 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -21,9 +21,6 @@
 /* FourCC code used for VCHI connection */
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
-/* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof(VC_AUDIO_MSG_T))
-
 /*
  *  List of screens that are currently supported
  *  All message types supported for HOST->VC direction
-- 
2.11.0



[PATCH] staging: bcm2835-audio: remove unused macro

2017-02-03 Thread Hendrik v. Raven
The VC_AUDIO_MAX_MSG_LEN macro is not used anywhere and has coding style
violations.

Signed-off-by: Hendrik v. Raven <hend...@consetetur.de>
---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 09f07fd891bb..da96f1bc2516 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -21,9 +21,6 @@
 /* FourCC code used for VCHI connection */
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
-/* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
-
 /*
  *  List of screens that are currently supported
  *  All message types supported for HOST->VC direction
-- 
2.11.0



[PATCH] staging: bcm2835-audio: remove unused macro

2017-02-03 Thread Hendrik v. Raven
The VC_AUDIO_MAX_MSG_LEN macro is not used anywhere and has coding style
violations.

Signed-off-by: Hendrik v. Raven 
---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 09f07fd891bb..da96f1bc2516 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -21,9 +21,6 @@
 /* FourCC code used for VCHI connection */
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
-/* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
-
 /*
  *  List of screens that are currently supported
  *  All message types supported for HOST->VC direction
-- 
2.11.0



[PATCH] staging: bcm2835-audio: fix spacing of macro

2017-02-03 Thread Hendrik v. Raven
removes the unwanted spaces inside of sizeof( ), removing a complaint of
checkpatch.pl. Also removes the second space behind the macro name.

Signed-off-by: Hendrik v. Raven <hend...@consetetur.de>
---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 09f07fd891bb..dd2f162b1ccb 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -22,7 +22,7 @@
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
 /* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
+#define VC_AUDIO_MAX_MSG_LEN (sizeof(VC_AUDIO_MSG_T))
 
 /*
  *  List of screens that are currently supported
-- 
2.11.0



[PATCH] staging: bcm2835-audio: fix spacing of macro

2017-02-03 Thread Hendrik v. Raven
removes the unwanted spaces inside of sizeof( ), removing a complaint of
checkpatch.pl. Also removes the second space behind the macro name.

Signed-off-by: Hendrik v. Raven 
---
 drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h 
b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
index 09f07fd891bb..dd2f162b1ccb 100644
--- a/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
+++ b/drivers/staging/bcm2835-audio/vc_vchi_audioserv_defs.h
@@ -22,7 +22,7 @@
 #define VC_AUDIO_SERVER_NAME  MAKE_FOURCC("AUDS")
 
 /* Maximum message length */
-#define VC_AUDIO_MAX_MSG_LEN  (sizeof( VC_AUDIO_MSG_T ))
+#define VC_AUDIO_MAX_MSG_LEN (sizeof(VC_AUDIO_MSG_T))
 
 /*
  *  List of screens that are currently supported
-- 
2.11.0



Re: [PATCH] s390/cpum_cf: Use kmalloc_array() in merge_attr()

2016-09-05 Thread Hendrik Brueckner
On Sat, Sep 03, 2016 at 03:27:42PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfr...@users.sourceforge.net>
> Date: Sat, 3 Sep 2016 15:17:45 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus reuse the corresponding function "kmalloc_array".
> 
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring <elfr...@users.sourceforge.net>
> ---
>  arch/s390/kernel/perf_cpum_cf_events.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kernel/perf_cpum_cf_events.c 
> b/arch/s390/kernel/perf_cpum_cf_events.c
> index 4554a4b..0d6340b 100644
> --- a/arch/s390/kernel/perf_cpum_cf_events.c
> +++ b/arch/s390/kernel/perf_cpum_cf_events.c
> @@ -274,7 +274,7 @@ static __init struct attribute **merge_attr(struct 
> attribute **a,
>   j++;
>   j++;
> 
> - new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
> + new = kmalloc_array(j, sizeof(*new), GFP_KERNEL);
>   if (!new)
>   return NULL;
>   j = 0;
> -- 

Looks good to me. Thanks.

Acked-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>



Re: [PATCH] s390/cpum_cf: Use kmalloc_array() in merge_attr()

2016-09-05 Thread Hendrik Brueckner
On Sat, Sep 03, 2016 at 03:27:42PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Sat, 3 Sep 2016 15:17:45 +0200
> 
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus reuse the corresponding function "kmalloc_array".
> 
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
> 
> Signed-off-by: Markus Elfring 
> ---
>  arch/s390/kernel/perf_cpum_cf_events.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kernel/perf_cpum_cf_events.c 
> b/arch/s390/kernel/perf_cpum_cf_events.c
> index 4554a4b..0d6340b 100644
> --- a/arch/s390/kernel/perf_cpum_cf_events.c
> +++ b/arch/s390/kernel/perf_cpum_cf_events.c
> @@ -274,7 +274,7 @@ static __init struct attribute **merge_attr(struct 
> attribute **a,
>   j++;
>   j++;
> 
> - new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
> + new = kmalloc_array(j, sizeof(*new), GFP_KERNEL);
>   if (!new)
>   return NULL;
>   j = 0;
> -- 

Looks good to me. Thanks.

Acked-by: Hendrik Brueckner 



Re: [PATCH] s390/oprofile: Remove deprecated create_workqueue

2016-06-17 Thread Hendrik Brueckner
On Tue, Jun 14, 2016 at 05:56:09PM +0200, Heiko Carstens wrote:
> On Tue, Jun 14, 2016 at 03:28:23PM +0200, Robert Richter wrote:
> > > 
> > >  Documentation/kernel-parameters.txt |2 -
> > >  arch/s390/oprofile/Makefile |1 -
> > >  arch/s390/oprofile/hwsampler.c  | 1178 
> > > 
> > >  arch/s390/oprofile/hwsampler.h  |   63 --
> > >  arch/s390/oprofile/init.c   |  489 -
> > >  arch/s390/oprofile/op_counter.h |   21 -
> > >  6 files changed, 1754 deletions(-)
> > 
> > Could you send the patch for review anyway?
> 
> Yes, of course. I added it below, hope that's ok.
> [I did not yet add your Ack]
> 
> From 74ab0aefe07573358cc6a0c462ddc62ccba4c0cf Mon Sep 17 00:00:00 2001
> From: Heiko Carstens <heiko.carst...@de.ibm.com>
> Date: Fri, 10 Jun 2016 10:40:06 +0200
> Subject: [PATCH] s390/oprofile: remove hardware sampler support
> 
> Remove hardware sampler support from oprofile module.
> 
> The oprofile user space utilty has been switched to use the kernel
> perf interface, for which we also provide hardware sampling support.
> 
> In addition the hardware sampling support is also slightly broken: it
> supports only 16 bits for the pid and therefore would generate wrong
> results on machines which have a pid >64k.
> 
> Also the pt_regs structure which was passed to oprofile common code
> cannot necessarily be used to generate sane backtraces, since the
> task(s) in question may run while the samples are fed to oprofile.
> So the result would be more or less random.
> 
> However given that the only user space tools switched to the perf
> interface already four years ago the hardware sampler code seems to be
> unused code, and therefore it should be reasonable to remove it.
> 
> The timer based oprofile support continues to work.
> 
> Signed-off-by: Heiko Carstens <heiko.carst...@de.ibm.com>
> ---
>  Documentation/kernel-parameters.txt |2 -
>  arch/s390/oprofile/Makefile |1 -
>  arch/s390/oprofile/hwsampler.c  | 1178 
> ---
>  arch/s390/oprofile/hwsampler.h  |   63 --
>  arch/s390/oprofile/init.c   |  489 ---
>  arch/s390/oprofile/op_counter.h |   21 -
>  6 files changed, 1754 deletions(-)
>  delete mode 100644 arch/s390/oprofile/hwsampler.c
>  delete mode 100644 arch/s390/oprofile/hwsampler.h
>  delete mode 100644 arch/s390/oprofile/op_counter.h
> 

Reviewed-by: Hendrik Brueckner <brueck...@linux.vnet.ibm.com>



Re: [PATCH] s390/oprofile: Remove deprecated create_workqueue

2016-06-17 Thread Hendrik Brueckner
On Tue, Jun 14, 2016 at 05:56:09PM +0200, Heiko Carstens wrote:
> On Tue, Jun 14, 2016 at 03:28:23PM +0200, Robert Richter wrote:
> > > 
> > >  Documentation/kernel-parameters.txt |2 -
> > >  arch/s390/oprofile/Makefile |1 -
> > >  arch/s390/oprofile/hwsampler.c  | 1178 
> > > 
> > >  arch/s390/oprofile/hwsampler.h  |   63 --
> > >  arch/s390/oprofile/init.c   |  489 -
> > >  arch/s390/oprofile/op_counter.h |   21 -
> > >  6 files changed, 1754 deletions(-)
> > 
> > Could you send the patch for review anyway?
> 
> Yes, of course. I added it below, hope that's ok.
> [I did not yet add your Ack]
> 
> From 74ab0aefe07573358cc6a0c462ddc62ccba4c0cf Mon Sep 17 00:00:00 2001
> From: Heiko Carstens 
> Date: Fri, 10 Jun 2016 10:40:06 +0200
> Subject: [PATCH] s390/oprofile: remove hardware sampler support
> 
> Remove hardware sampler support from oprofile module.
> 
> The oprofile user space utilty has been switched to use the kernel
> perf interface, for which we also provide hardware sampling support.
> 
> In addition the hardware sampling support is also slightly broken: it
> supports only 16 bits for the pid and therefore would generate wrong
> results on machines which have a pid >64k.
> 
> Also the pt_regs structure which was passed to oprofile common code
> cannot necessarily be used to generate sane backtraces, since the
> task(s) in question may run while the samples are fed to oprofile.
> So the result would be more or less random.
> 
> However given that the only user space tools switched to the perf
> interface already four years ago the hardware sampler code seems to be
> unused code, and therefore it should be reasonable to remove it.
> 
> The timer based oprofile support continues to work.
> 
> Signed-off-by: Heiko Carstens 
> ---
>  Documentation/kernel-parameters.txt |2 -
>  arch/s390/oprofile/Makefile |1 -
>  arch/s390/oprofile/hwsampler.c  | 1178 
> ---
>  arch/s390/oprofile/hwsampler.h  |   63 --
>  arch/s390/oprofile/init.c   |  489 ---
>  arch/s390/oprofile/op_counter.h |   21 -
>  6 files changed, 1754 deletions(-)
>  delete mode 100644 arch/s390/oprofile/hwsampler.c
>  delete mode 100644 arch/s390/oprofile/hwsampler.h
>  delete mode 100644 arch/s390/oprofile/op_counter.h
> 

Reviewed-by: Hendrik Brueckner 



Re: select on non-existing Kconfig option CRC32C

2016-06-15 Thread Hendrik Brueckner
Hi Andreas,

On Wed, Jun 15, 2016 at 12:00:59PM +0200, Andreas Ziegler wrote:
> 
> your patch "s390/crc32-vx: add crypto API module for optimized CRC-32
> algorithms" showed up in linux-next today (next-20160615) as commit   
> 364148e0b195.
> 
> The patch defines the Kconfig option CRYPTO_CRC32_S390 which 'select's CRC32C.
> However, this should probably have been CRYPTO_CRC32C, as CRC32C does not 
> exist.

Thanks for informing me.  Actually, the crc32-vx driver requires the
__crc32c_le() function which is available by selecting CONFIG_CRC32. There is
no need for CRYPTO_CRC32C.  So this can be safely removed.

> Should I prepare a trivial patch to fix this up or would you like to do that 
> on
> your side?

Martin have already corrected the patch.

Thanks and kind regards,
  Hendrik



  1   2   >