perf/urgent fixes
Subsystems (4)
Arnaldo Carvalho de Melo
maintainerHi Ingo, Thomas,
Some fixes plus syncronization of kernel header copies to have
the perf build without warnings,
- Arnaldo
The following changes since commit 8c7ae38d1ce12a0eaeba655df8562552b3596c7f:
afs: Fix StoreData op marshalling (2019-03-28 08:54:20 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git tags/perf-urgent-for-mingo-5.1-20190329
for you to fetch changes up to e94d6b7f615e6dfbaf9fba7db6011db561461d0c:
perf pmu: Fix parser error for uncore event alias (2019-03-28 15:53:27 -0300)
----------------------------------------------------------------
perf/urgent fixes:
Core libraries:
Jiri Olsa:
- Fix max perf_event_attr.precise_ip detection.
Kan Liang:
- Fix parser error for uncore event alias
Wei Lin:
- Fixup ordering of kernel maps after obtaining the main kernel map address.
Intel PT:
Adrian Hunter:
- Fix TSC slip where A TSC packet can slip past MTC packets so that the timestamp appears to go backwards.
- Fixes for exported-sql-viewer GUI conversion to python3.
ARM coresight:
Solomon Tan:
- Fix the build by adding a missing case value for enumeration value introduced in newer library, that now is the required one.
tool headers:
Arnaldo Carvalho de Melo:
- Syncronize kernel headers with the kernel, getting new io_uring and pidfd_send_signal syscalls so that 'perf trace' can handle them.
----------------------------------------------------------------
Adrian Hunter (3):
perf intel-pt: Fix TSC slip
perf scripts python: exported-sql-viewer.py: Fix never-ending loop perf scripts python: exported-sql-viewer.py: Fix python3 support
Arnaldo Carvalho de Melo (6):
tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h tools headers uapi: Sync linux/fcntl.h to get the F_SEAL_FUTURE_WRITE addition tools arch x86: Sync asm/cpufeatures.h with the kernel sources tools headers uapi: Update drm/i915_drm.h
tools headers: Update x86's syscall_64.tbl and uapi/asm-generic/unistd tools headers uapi: Sync powerpc's asm/kvm.h copy with the kernel sources
Jiri Olsa (1):
perf evsel: Fix max perf_event_attr.precise_ip detection
Kan Liang (1):
perf pmu: Fix parser error for uncore event alias
Solomon Tan (1):
perf cs-etm: Add missing case value
Wei Li (1):
perf machine: Update kernel map address and re-order properly
tools/arch/alpha/include/uapi/asm/mman.h | 2 - tools/arch/mips/include/uapi/asm/mman.h | 2 - tools/arch/parisc/include/uapi/asm/mman.h | 2 - tools/arch/powerpc/include/uapi/asm/kvm.h | 2 + tools/arch/x86/include/asm/cpufeatures.h | 1 + tools/arch/xtensa/include/uapi/asm/mman.h | 2 - tools/build/feature/test-libopencsd.c | 4 +- tools/include/uapi/asm-generic/mman-common-tools.h | 23 +++++++ tools/include/uapi/asm-generic/mman-common.h | 4 +- tools/include/uapi/asm-generic/mman.h | 2 +- tools/include/uapi/asm-generic/unistd.h | 11 +++- tools/include/uapi/drm/i915_drm.h | 64 ++++++++++++++++++ tools/include/uapi/linux/fcntl.h | 1 + tools/include/uapi/linux/mman.h | 4 ++ tools/perf/Makefile.perf | 4 +- tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 4 ++ tools/perf/check-headers.sh | 2 +- tools/perf/scripts/python/exported-sql-viewer.py | 77 ++++++++++++++++++---- tools/perf/trace/beauty/mmap_flags.sh | 14 +++- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 1 + tools/perf/util/evlist.c | 29 -------- tools/perf/util/evlist.h | 2 - tools/perf/util/evsel.c | 72 ++++++++++++++++---- .../perf/util/intel-pt-decoder/intel-pt-decoder.c | 20 +++--- tools/perf/util/machine.c | 32 +++++---- tools/perf/util/pmu.c | 10 +++ 26 files changed, 288 insertions(+), 103 deletions(-) create mode 100644 tools/include/uapi/asm-generic/mman-common-tools.h
Arnaldo Carvalho de Melo
maintainerPATCH 1/13 perf cs-etm: Add missing case value
From: Solomon Tan <[email protected]>
The following error was thrown when compiling tools/perf using OpenCSD v0.11.1. This patch fixes said error.
CC util/intel-pt-decoder/intel-pt-log.o
CC util/cs-etm-decoder/cs-etm-decoder.o
util/cs-etm-decoder/cs-etm-decoder.c: In function ‘cs_etm_decoder__buffer_range’:
util/cs-etm-decoder/cs-etm-decoder.c:370:2: error: enumeration value ‘OCSD_INSTR_WFI_WFE’ not handled in switch [-Werror=switch-enum]
switch (elem->last_i_type) {
^~~~~~
CC util/intel-pt-decoder/intel-pt-decoder.occ1: all warnings being treated as errors
Because OCSD_INSTR_WFI_WFE case was added only in v0.11.0, the minimum required OpenCSD library version for this patch is no longer v0.10.0.
--- tools/build/feature/test-libopencsd.c | 4 ++-- tools/perf/util/cs-etm-decoder/cs-etm-decoder.c | 1 + 2 files changed, 3 insertions(+), 2 deletions(-)
tools/build/feature/test-libopencsd.c +2 -2
@@ -4,9 +4,9 @@/* * Check OpenCSD library version is sufficient to provide required features */ -#define OCSD_MIN_VER ((0 << 16) | (10 << 8) | (0)) +#define OCSD_MIN_VER ((0 << 16) | (11 << 8) | (0))#if !defined(OCSD_VER_NUM ) || (OCSD_VER_NUM <OCSD_MIN_VER ) -#error "OpenCSD >= 0.10.0 is required" +#error "OpenCSD >= 0.11.0 is required"#endif int main (void )
tools/perf/util/cs-etm-decoder/cs-etm-decoder.c +1 -0
@@ -387,6 +387,7 @@ cs_etm_decoder__buffer_range(struct cs_etm_decoder *decoder,break ;case OCSD_INSTR_ISB :case OCSD_INSTR_DSB_DMB : +case OCSD_INSTR_WFI_WFE :case OCSD_INSTR_OTHER :default : packet->last_instr_taken_branch = false;
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Arnaldo Carvalho de Melo
maintainerPATCH 2/13 perf intel-pt: Fix TSC slip
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
A TSC packet can slip past MTC packets so that the timestamp appears to go backwards. One estimate is that can be up to about 40 CPU cycles, which is certainly less than 0x1000 TSC ticks, but accept slippage an order of magnitude more to be on the safe side.
--- .../util/intel-pt-decoder/intel-pt-decoder.c | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-)
tools/perf/util/intel-pt-decoder/intel-pt-decoder.c +8 -12
@@ -251,19 +251,15 @@ struct intel_pt_decoder *intel_pt_decoder_new(struct intel_pt_params *params)if (!(decoder->tsc_ctc_ratio_n % decoder->tsc_ctc_ratio_d)) decoder->tsc_ctc_mult = decoder->tsc_ctc_ratio_n / decoder->tsc_ctc_ratio_d; - -/* -* Allow for timestamps appearing to backwards because a TSC -* packet has slipped past a MTC packet, so allow 2 MTC ticks -* or ... -*/ - decoder->tsc_slip =multdiv (2 << decoder->mtc_shift, - decoder->tsc_ctc_ratio_n, - decoder->tsc_ctc_ratio_d); } -/* ... or 0x100 paranoia */ -if (decoder->tsc_slip <0x100 ) - decoder->tsc_slip =0x100 ; + +/* +* A TSC packet can slip past MTC packets so that the timestamp appears +* to go backwards. One estimate is that can be up to about 40 CPU +* cycles, which is certainly less than 0x1000 TSC ticks, but accept +* slippage an order of magnitude more to be on the safe side. +*/ + decoder->tsc_slip =0x10000 ;intel_pt_log ("timestamp: mtc_shift %u\n" , decoder->mtc_shift);intel_pt_log ("timestamp: tsc_ctc_ratio_n %u\n" , decoder->tsc_ctc_ratio_n);
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 3/13 perf evsel: Fix max perf_event_attr.precise_ip detection
In reply to Arnaldo Carvalho de MeloFrom: Jiri Olsa <[email protected]>
After a discussion with Andi, move the perf_event_attr.precise_ip detection for maximum precise config (via :P modifier or for default cycles event) to perf_evsel__open().
The current detection in perf_event_attr__set_max_precise_ip() is tricky, because precise_ip config is specific for given event and it currently checks only hw cycles.
We now check for valid precise_ip value right after failing sys_perf_event_open() for specific event, before any of the perf_event_attr fallback code gets executed.
This way we get the proper config in perf_event_attr together with allowed precise_ip settings.
We can see that code activity with -vv, like:
$ perf record -vv ls
...
------------------------------------------------------------
perf_event_attr:
size 112
{ sample_period, sample_freq } 4000
...
precise_ip 3
sample_id_all 1
exclude_guest 1
mmap2 1
comm_exec 1
ksymbol 1
------------------------------------------------------------
sys_perf_event_open: pid 9926 cpu 0 group_fd -1 flags 0x8
sys_perf_event_open failed, error -95
decreasing precise_ip by one (2)
------------------------------------------------------------
perf_event_attr:
size 112
{ sample_period, sample_freq } 4000
...
precise_ip 2
sample_id_all 1
exclude_guest 1
mmap2 1
comm_exec 1
ksymbol 1
------------------------------------------------------------
sys_perf_event_open: pid 9926 cpu 0 group_fd -1 flags 0x8 = 4
...--- tools/perf/util/evlist.c | 29 ---------------- tools/perf/util/evlist.h | 2 -- tools/perf/util/evsel.c | 72 ++++++++++++++++++++++++++++++++-------- 3 files changed, 59 insertions(+), 44 deletions(-)
tools/perf/util/evlist.c +0 -29
@@ -231,35 +231,6 @@ void perf_evlist__set_leader(struct perf_evlist *evlist) } } -void perf_event_attr__set_max_precise_ip (struct perf_event_attr *pattr) -{ -struct perf_event_attr attr = { - .type =PERF_TYPE_HARDWARE , - .config =PERF_COUNT_HW_CPU_CYCLES , - .exclude_kernel =1 , - .precise_ip =3 , - }; - -event_attr_init (&attr); - -/* -* Unnamed union member, not supported as struct member named -* initializer in older compilers such as gcc 4.4.7 -*/ - attr.sample_period =1 ; - -while (attr.precise_ip !=0 ) { -int fd =sys_perf_event_open (&attr,0 ,-1 ,-1 ,0 ); -if (fd !=-1 ) { -close (fd); -break ; - } - --attr.precise_ip; - } - - pattr->precise_ip = attr.precise_ip; -} -int __perf_evlist__add_default (struct perf_evlist *evlist,bool precise) {struct perf_evsel *evsel =perf_evsel__new_cycles (precise);
tools/perf/util/evlist.h +0 -2
@@ -315,8 +315,6 @@ void perf_evlist__to_front(struct perf_evlist *evlist,void perf_evlist__set_tracking_event (struct perf_evlist *evlist,struct perf_evsel *tracking_evsel); -void perf_event_attr__set_max_precise_ip (struct perf_event_attr *attr); -struct perf_evsel *perf_evlist__find_evsel_by_str (struct perf_evlist *evlist,const char *str);
tools/perf/util/evsel.c +59 -13
110 lines not on this page · raw message
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 4/13 tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To deal with the move of some defines from asm-generic/mmap-common.h to linux/mman.h done in:
746c9398f5ac ("arch: move common mmap flags to linux/mman.h")
The generated mmap_flags array stays the same:
$ tools/perf/trace/beauty/mmap_flags.sh
static const char *mmap_flags[] = {
[ilog2(0x40) + 1] = "32BIT",
[ilog2(0x01) + 1] = "SHARED",
[ilog2(0x02) + 1] = "PRIVATE",
[ilog2(0x10) + 1] = "FIXED",
[ilog2(0x20) + 1] = "ANONYMOUS",
[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
[ilog2(0x0100) + 1] = "GROWSDOWN",
[ilog2(0x0800) + 1] = "DENYWRITE",
[ilog2(0x1000) + 1] = "EXECUTABLE",
[ilog2(0x2000) + 1] = "LOCKED",
[ilog2(0x4000) + 1] = "NORESERVE",
[ilog2(0x8000) + 1] = "POPULATE",
[ilog2(0x10000) + 1] = "NONBLOCK",
[ilog2(0x20000) + 1] = "STACK",
[ilog2(0x40000) + 1] = "HUGETLB",
[ilog2(0x80000) + 1] = "SYNC",
};
$And to have the system's sys/mman.h find the definition of MAP_SHARED and MAP_PRIVATE, make sure they are defined in the tools/ mman-common.h in a way that keeps it the same as the kernel's, need for keeping the Android's NDK cross build working.
This silences these perf build warnings:
Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h' diff -u tools/include/uapi/asm-generic/mman-common.h include/uapi/asm-generic/mman-common.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h' differs from latest version at 'include/uapi/linux/mman.h' diff -u tools/include/uapi/linux/mman.h include/uapi/linux/mman.h
--- tools/arch/alpha/include/uapi/asm/mman.h | 2 -- tools/arch/mips/include/uapi/asm/mman.h | 2 -- tools/arch/parisc/include/uapi/asm/mman.h | 2 -- tools/arch/xtensa/include/uapi/asm/mman.h | 2 -- .../uapi/asm-generic/mman-common-tools.h | 23 +++++++++++++++++++ tools/include/uapi/asm-generic/mman-common.h | 4 +--- tools/include/uapi/asm-generic/mman.h | 2 +- tools/include/uapi/linux/mman.h | 4 ++++ tools/perf/Makefile.perf | 4 ++-- tools/perf/check-headers.sh | 2 +- tools/perf/trace/beauty/mmap_flags.sh | 14 ++++++++--- 11 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 tools/include/uapi/asm-generic/mman-common-tools.h
tools/arch/alpha/include/uapi/asm/mman.h +0 -2
@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x40000#define MAP_NORESERVE 0x10000#define MAP_POPULATE 0x20000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x80000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000
tools/arch/mips/include/uapi/asm/mman.h +0 -2
@@ -28,8 +28,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x04#define PROT_GROWSDOWN 0x01000000
tools/arch/parisc/include/uapi/asm/mman.h +0 -2
@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x4000#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000
tools/arch/xtensa/include/uapi/asm/mman.h +0 -2
@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000
tools/include/uapi/asm-generic/mman-common-tools.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H +#define __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H + +#include <asm-generic/mman-common.h> + +/* We need this because we need to have tools/include/uapi/ included in the tools +* header search path to get access to stuff that is not yet in the system's +* copy of the files in that directory, but since this cset: +* +* 746c9398f5ac ("arch: move common mmap flags to linux/mman.h") +* +* We end up making sys/mman.h, that is in the system headers, to not find the +* MAP_SHARED and MAP_PRIVATE defines because they are not anymore in our copy +* of asm-generic/mman-common.h. So we define them here and include this header +* from each of the per arch mman.h headers. +*/ +#ifndef MAP_SHARED +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +#endif +#endif // __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H
tools/include/uapi/asm-generic/mman-common.h +1 -3
@@ -15,9 +15,7 @@#define PROT_GROWSDOWN 0x01000000/* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000/* mprotect flag: extend change to end of growsup vma */ -#define MAP_SHARED 0x01/* Share changes */ -#define MAP_PRIVATE 0x02/* Changes are private */ -#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x0f/* Mask for type of mapping */ #define MAP_FIXED 0x10/* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20/* don't use a file */
tools/include/uapi/asm-generic/mman.h +1 -1
@@ -2,7 +2,7 @@#ifndef __ASM_GENERIC_MMAN_H#define __ASM_GENERIC_MMAN_H -#include <asm-generic/mman-common.h> +#include <asm-generic/mman-common-tools.h> #define MAP_GROWSDOWN 0x0100/* stack-like segment */ #define MAP_DENYWRITE 0x0800/* ETXTBSY */
tools/include/uapi/linux/mman.h +4 -0
@@ -12,6 +12,10 @@#define OVERCOMMIT_ALWAYS 1#define OVERCOMMIT_NEVER 2 +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* * Huge page size encoding when MAP_HUGETLB is specified, and a huge page * size other than the default is desired. See hugetlb_encode.h.
tools/perf/Makefile.perf +2 -2
@@ -481,8 +481,8 @@ $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_t mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh -$(mmap_flags_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) - $(Q)$(SHELL) '$(mmap_flags_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ +$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) + $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ mount_flags_array := $(beauty_outdir)/mount_flags_array.c mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.sh
tools/perf/check-headers.sh +1 -1
@@ -103,7 +103,7 @@ done # diff with extra ignore lines check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' -check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"' +check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' # diff non-symmetric files
tools/perf/trace/beauty/mmap_flags.sh +11 -3
@@ -1,15 +1,18 @@ #!/bin/sh # SPDX-License-Identifier: LGPL-2.1 -if [ $# -ne 2 ] ; then +if [ $# -ne 3 ] ; then [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` + linux_header_dir=tools/include/uapi/linux header_dir=tools/include/uapi/asm-generic arch_header_dir=tools/arch/${hostarch}/include/uapi/asm else - header_dir=$1 - arch_header_dir=$2 + linux_header_dir=$1 + header_dir=$2 + arch_header_dir=$3 fi +linux_mman=${linux_header_dir}/mman.h arch_mman=${arch_header_dir}/mman.h # those in egrep -vw are flags, we want just the bits
@@ -20,6 +23,11 @@ egrep -q $regex ${arch_mman} && \ (egrep $regex ${arch_mman} | \ sed -r "s/$regex/\2 \1/g" | \ xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") +egrep -q $regex ${linux_mman} && \ +(egrep $regex ${linux_mman} | \ + egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && (egrep $regex ${header_dir}/mman-common.h | \ egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \
Signature · 1 line
2.20.1
Re: [PATCH 04/13] tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h
Quoted 127 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
To deal with the move of some defines from
asm-generic/mmap-common.htolinux/mman.hdone in:
746c9398f5ac("arch: move common mmap flags tolinux/mman.h")The generated
mmap_flagsarray stays the same:$ tools/perf/trace/beauty/mmap_flags.sh static const char *mmap_flags[] = { [ilog2(0x40) + 1] = "32BIT", [ilog2(0x01) + 1] = "SHARED", [ilog2(0x02) + 1] = "PRIVATE", [ilog2(0x10) + 1] = "FIXED", [ilog2(0x20) + 1] = "ANONYMOUS", [ilog2(0x100000) + 1] = "FIXED_NOREPLACE", [ilog2(0x0100) + 1] = "GROWSDOWN", [ilog2(0x0800) + 1] = "DENYWRITE", [ilog2(0x1000) + 1] = "EXECUTABLE", [ilog2(0x2000) + 1] = "LOCKED", [ilog2(0x4000) + 1] = "NORESERVE", [ilog2(0x8000) + 1] = "POPULATE", [ilog2(0x10000) + 1] = "NONBLOCK", [ilog2(0x20000) + 1] = "STACK", [ilog2(0x40000) + 1] = "HUGETLB", [ilog2(0x80000) + 1] = "SYNC", }; $And to have the system's
sys/mman.hfind the definition ofMAP_SHAREDandMAP_PRIVATE, make sure they are defined in thetools/mman-common.hin a way that keeps it the same as the kernel's, need for keeping the Android's NDK cross build working.This silences these perf build warnings:
Warning: Kernel ABI header at '
tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h' diff -utools/include/uapi/asm-generic/mman-common.hinclude/uapi/asm-generic/mman-common.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h' differs from latest version at 'include/uapi/linux/mman.h' diff -utools/include/uapi/linux/mman.hinclude/uapi/linux/mman.hCc Adrian Hunter <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Jiri Olsa <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/arch/alpha/include/uapi/asm/mman.h | 2 -- tools/arch/mips/include/uapi/asm/mman.h | 2 -- tools/arch/parisc/include/uapi/asm/mman.h | 2 -- tools/arch/xtensa/include/uapi/asm/mman.h | 2 -- .../uapi/asm-generic/mman-common-tools.h | 23 +++++++++++++++++++ tools/include/uapi/asm-generic/mman-common.h | 4 +--- tools/include/uapi/asm-generic/mman.h | 2 +- tools/include/uapi/linux/mman.h | 4 ++++ tools/perf/Makefile.perf | 4 ++-- tools/perf/check-headers.sh | 2 +- tools/perf/trace/beauty/mmap_flags.sh | 14 ++++++++--- 11 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 tools/include/uapi/asm-generic/mman-common-tools.htools/arch/alpha/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x40000#define MAP_NORESERVE 0x10000#define MAP_POPULATE 0x20000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x80000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/arch/mips/include/uapi/asm/mman.h +0
-2@@ -28,8 +28,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x04#define PROT_GROWSDOWN 0x01000000tools/arch/parisc/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x4000#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/arch/xtensa/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/include/uapi/asm-generic/mman-common-tools.h new file +5
-0@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H +#define __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H + +#include <asm-generic/mman-common.h>
tools/include/uapi/asm-generic/mman-common-tools.h line 15
Quoted 10 lines
tools/include/uapi/asm-generic/mman-common-tools.h new file +10
-0+ +/* We need this because we need to have tools/include/uapi/ included in the tools +* header search path to get access to stuff that is not yet in the system's +* copy of the files in that directory, but since this cset: +* +* 746c9398f5ac ("arch: move common mmap flags to linux/mman.h") +* +* We end up making sys/mman.h, that is in the system headers, to not find the +* MAP_SHARED and MAP_PRIVATE defines because they are not anymore in our copy +* of asm-generic/mman-common.h.
Isn't the reason they are not found there that you moved them out of there in the chunk below?
Quoted 121 lines
So we define them here and include this header
+ * from each of the per archmman.hheaders.
+ */tools/include/uapi/asm-generic/mman-common-tools.h new file +6
-0+#ifndef MAP_SHARED +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +#endif +#endif // __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H tools/include/uapi/asm-generic/mman-common.h +1
-3@@ -15,9 +15,7 @@#define PROT_GROWSDOWN 0x01000000/* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000/* mprotect flag: extend change to end of growsup vma */ -#define MAP_SHARED 0x01/* Share changes */ -#define MAP_PRIVATE 0x02/* Changes are private */ -#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x0f/* Mask for type of mapping */ #define MAP_FIXED 0x10/* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20/* don't use a file */ tools/include/uapi/asm-generic/mman.h +1
-1@@ -2,7 +2,7 @@#ifndef __ASM_GENERIC_MMAN_H#define __ASM_GENERIC_MMAN_H -#include <asm-generic/mman-common.h> +#include <asm-generic/mman-common-tools.h> #define MAP_GROWSDOWN 0x0100/* stack-like segment */ #define MAP_DENYWRITE 0x0800/* ETXTBSY */ tools/include/uapi/linux/mman.h +4
-0@@ -12,6 +12,10 @@#define OVERCOMMIT_ALWAYS 1#define OVERCOMMIT_NEVER 2 +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* * Huge page size encoding when MAP_HUGETLB is specified, and a huge page * size other than the default is desired. See hugetlb_encode.h. tools/perf/Makefile.perf +2
-2@@ -481,8 +481,8 @@ $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_t mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh -$(mmap_flags_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) - $(Q)$(SHELL) '$(mmap_flags_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ +$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) + $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ mount_flags_array := $(beauty_outdir)/mount_flags_array.c mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.shtools/perf/check-headers.sh +1
-1@@ -103,7 +103,7 @@ done # diff with extra ignore lines check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' -check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"' +check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' # diff non-symmetric filestools/perf/trace/beauty/mmap_flags.sh +11
-3@@ -1,15 +1,18 @@ #!/bin/sh # SPDX-License-Identifier: LGPL-2.1 -if [ $# -ne 2 ] ; then +if [ $# -ne 3 ] ; then [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` + linux_header_dir=tools/include/uapi/linux header_dir=tools/include/uapi/asm-generic arch_header_dir=tools/arch/${hostarch}/include/uapi/asm else - header_dir=$1 - arch_header_dir=$2 + linux_header_dir=$1 + header_dir=$2 + arch_header_dir=$3 fi +linux_mman=${linux_header_dir}/mman.h arch_mman=${arch_header_dir}/mman.h # those in egrep -vw are flags, we want just the bits@@ -20,6 +23,11 @@ egrep -q $regex ${arch_mman} && \ (egrep $regex ${arch_mman} | \ sed -r "s/$regex/\2 \1/g" | \ xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") +egrep -q $regex ${linux_mman} && \ +(egrep $regex ${linux_mman} | \ + egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && (egrep $regex ${header_dir}/mman-common.h | \ egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \Signature · 1 line
2.20.1
Re: [PATCH 04/13] tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h
Em Fri, Mar 29, 2019 at 10:20:06AM -0400, Michael S. Tsirkin escreveu:
Quoted 133 lines · Arnaldo Carvalho de Melo
Quoted 132 lines
From: Arnaldo Carvalho de Melo <[email protected]>
To deal with the move of some defines from
asm-generic/mmap-common.htolinux/mman.hdone in:
746c9398f5ac("arch: move common mmap flags tolinux/mman.h")The generated
mmap_flagsarray stays the same:$ tools/perf/trace/beauty/mmap_flags.sh static const char *mmap_flags[] = { [ilog2(0x40) + 1] = "32BIT", [ilog2(0x01) + 1] = "SHARED", [ilog2(0x02) + 1] = "PRIVATE", [ilog2(0x10) + 1] = "FIXED", [ilog2(0x20) + 1] = "ANONYMOUS", [ilog2(0x100000) + 1] = "FIXED_NOREPLACE", [ilog2(0x0100) + 1] = "GROWSDOWN", [ilog2(0x0800) + 1] = "DENYWRITE", [ilog2(0x1000) + 1] = "EXECUTABLE", [ilog2(0x2000) + 1] = "LOCKED", [ilog2(0x4000) + 1] = "NORESERVE", [ilog2(0x8000) + 1] = "POPULATE", [ilog2(0x10000) + 1] = "NONBLOCK", [ilog2(0x20000) + 1] = "STACK", [ilog2(0x40000) + 1] = "HUGETLB", [ilog2(0x80000) + 1] = "SYNC", }; $And to have the system's
sys/mman.hfind the definition ofMAP_SHAREDandMAP_PRIVATE, make sure they are defined in thetools/mman-common.hin a way that keeps it the same as the kernel's, need for keeping the Android's NDK cross build working.This silences these perf build warnings:
Warning: Kernel ABI header at '
tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h' diff -utools/include/uapi/asm-generic/mman-common.hinclude/uapi/asm-generic/mman-common.h
Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h' differs from latest version at 'include/uapi/linux/mman.h' diff -utools/include/uapi/linux/mman.hinclude/uapi/linux/mman.hCc Adrian Hunter <[email protected]>Cc Arnd Bergmann <[email protected]>Cc Jiri Olsa <[email protected]>Cc Michael S. Tsirkin <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>--- tools/arch/alpha/include/uapi/asm/mman.h | 2 -- tools/arch/mips/include/uapi/asm/mman.h | 2 -- tools/arch/parisc/include/uapi/asm/mman.h | 2 -- tools/arch/xtensa/include/uapi/asm/mman.h | 2 -- .../uapi/asm-generic/mman-common-tools.h | 23 +++++++++++++++++++ tools/include/uapi/asm-generic/mman-common.h | 4 +--- tools/include/uapi/asm-generic/mman.h | 2 +- tools/include/uapi/linux/mman.h | 4 ++++ tools/perf/Makefile.perf | 4 ++-- tools/perf/check-headers.sh | 2 +- tools/perf/trace/beauty/mmap_flags.sh | 14 ++++++++--- 11 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 tools/include/uapi/asm-generic/mman-common-tools.htools/arch/alpha/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x40000#define MAP_NORESERVE 0x10000#define MAP_POPULATE 0x20000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x80000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/arch/mips/include/uapi/asm/mman.h +0
-2@@ -28,8 +28,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x04#define PROT_GROWSDOWN 0x01000000tools/arch/parisc/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x4000#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x02 -#define MAP_SHARED 0x01#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/arch/xtensa/include/uapi/asm/mman.h +0
-2@@ -27,8 +27,6 @@#define MAP_NONBLOCK 0x20000#define MAP_NORESERVE 0x0400#define MAP_POPULATE 0x10000 -#define MAP_PRIVATE 0x002 -#define MAP_SHARED 0x001#define MAP_STACK 0x40000#define PROT_EXEC 0x4#define PROT_GROWSDOWN 0x01000000tools/include/uapi/asm-generic/mman-common-tools.h new file +10
-0@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H +#define __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H + +#include <asm-generic/mman-common.h> + +/* We need this because we need to have tools/include/uapi/ included in the tools +* header search path to get access to stuff that is not yet in the system's +* copy of the files in that directory, but since this cset: +*
Quoted 8 lines
tools/include/uapi/asm-generic/mman-common-tools.h
Quoted 5 lines
tools/include/uapi/asm-generic/mman-common-tools.h new file +5
-0+* 746c9398f5ac ("arch: move common mmap flags to linux/mman.h") +* +* We end up making sys/mman.h, that is in the system headers, to not find the +* MAP_SHARED and MAP_PRIVATE defines because they are not anymore in our copy +* of asm-generic/mman-common.h. Isn't the reason they are not found there that you moved them out of there in the chunk below?
Which chunk? The one for tools/include/uapi/asm-generic/mman-common.h? Yes, that is the reason, and it was removed so that tools/include/uapi/asm-generic/mman-common.h gets in sync with include/uapi/asm-generic/mman-common.h, so that when changes are made to that file the perf build process points this out to perf developers so that we check if the changes made in the kernel sources should entail some changes in tooling, sometimes automatically, see the output of tools/perf/trace/beauty/mmap_flags.sh above, it is made by processing the contents of he tools/include/uapi/asm-generic/mman-common.h file.
- Arnaldo
Quoted 121 lines
Quoted 121 lines
So we define them here and include this header
+ * from each of the per archmman.hheaders.
+ */tools/include/uapi/asm-generic/mman-common-tools.h new file +6
-0+#ifndef MAP_SHARED +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +#endif +#endif // __ASM_GENERIC_MMAN_COMMON_TOOLS_ONLY_H tools/include/uapi/asm-generic/mman-common.h +1
-3@@ -15,9 +15,7 @@#define PROT_GROWSDOWN 0x01000000/* mprotect flag: extend change to start of growsdown vma */ #define PROT_GROWSUP 0x02000000/* mprotect flag: extend change to end of growsup vma */ -#define MAP_SHARED 0x01/* Share changes */ -#define MAP_PRIVATE 0x02/* Changes are private */ -#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* 0x01 - 0x03 are defined in linux/mman.h */ #define MAP_TYPE 0x0f/* Mask for type of mapping */ #define MAP_FIXED 0x10/* Interpret addr exactly */ #define MAP_ANONYMOUS 0x20/* don't use a file */ tools/include/uapi/asm-generic/mman.h +1
-1@@ -2,7 +2,7 @@#ifndef __ASM_GENERIC_MMAN_H#define __ASM_GENERIC_MMAN_H -#include <asm-generic/mman-common.h> +#include <asm-generic/mman-common-tools.h> #define MAP_GROWSDOWN 0x0100/* stack-like segment */ #define MAP_DENYWRITE 0x0800/* ETXTBSY */ tools/include/uapi/linux/mman.h +4
-0@@ -12,6 +12,10 @@#define OVERCOMMIT_ALWAYS 1#define OVERCOMMIT_NEVER 2 +#define MAP_SHARED 0x01/* Share changes */ +#define MAP_PRIVATE 0x02/* Changes are private */ +#define MAP_SHARED_VALIDATE 0x03/* share + validate extension flags */ +/* * Huge page size encoding when MAP_HUGETLB is specified, and a huge page * size other than the default is desired. See hugetlb_encode.h. tools/perf/Makefile.perf +2
-2@@ -481,8 +481,8 @@ $(madvise_behavior_array): $(madvise_hdr_dir)/mman-common.h $(madvise_behavior_t mmap_flags_array := $(beauty_outdir)/mmap_flags_array.c mmap_flags_tbl := $(srctree)/tools/perf/trace/beauty/mmap_flags.sh -$(mmap_flags_array): $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) - $(Q)$(SHELL) '$(mmap_flags_tbl)' $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ +$(mmap_flags_array): $(linux_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman.h $(asm_generic_uapi_dir)/mman-common.h $(mmap_flags_tbl) + $(Q)$(SHELL) '$(mmap_flags_tbl)' $(linux_uapi_dir) $(asm_generic_uapi_dir) $(arch_asm_uapi_dir) > $@ mount_flags_array := $(beauty_outdir)/mount_flags_array.c mount_flags_tbl := $(srctree)/tools/perf/trace/beauty/mount_flags.shtools/perf/check-headers.sh +1
-1@@ -103,7 +103,7 @@ done # diff with extra ignore lines check arch/x86/lib/memcpy_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' check arch/x86/lib/memset_64.S '-I "^EXPORT_SYMBOL" -I "^#include <asm/export.h>"' -check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common.h>"' +check include/uapi/asm-generic/mman.h '-I "^#include <\(uapi/\)*asm-generic/mman-common\(-tools\)*.h>"' check include/uapi/linux/mman.h '-I "^#include <\(uapi/\)*asm/mman.h>"' # diff non-symmetric filestools/perf/trace/beauty/mmap_flags.sh +11
-3@@ -1,15 +1,18 @@ #!/bin/sh # SPDX-License-Identifier: LGPL-2.1 -if [ $# -ne 2 ] ; then +if [ $# -ne 3 ] ; then [ $# -eq 1 ] && hostarch=$1 || hostarch=`uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/` + linux_header_dir=tools/include/uapi/linux header_dir=tools/include/uapi/asm-generic arch_header_dir=tools/arch/${hostarch}/include/uapi/asm else - header_dir=$1 - arch_header_dir=$2 + linux_header_dir=$1 + header_dir=$2 + arch_header_dir=$3 fi +linux_mman=${linux_header_dir}/mman.h arch_mman=${arch_header_dir}/mman.h # those in egrep -vw are flags, we want just the bits@@ -20,6 +23,11 @@ egrep -q $regex ${arch_mman} && \ (egrep $regex ${arch_mman} | \ sed -r "s/$regex/\2 \1/g" | \ xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") +egrep -q $regex ${linux_mman} && \ +(egrep $regex ${linux_mman} | \ + egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \ + sed -r "s/$regex/\2 \1/g" | \ + xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n") ([ ! -f ${arch_mman} ] || egrep -q '#[[:space:]]*include[[:space:]]+<uapi/asm-generic/mman.*' ${arch_mman}) && (egrep $regex ${header_dir}/mman-common.h | \ egrep -vw 'MAP_(UNINITIALIZED|TYPE|SHARED_VALIDATE)' | \Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 5/13 tools headers uapi: Sync linux/fcntl.h to get the F_SEAL_FUTURE_WRITE addition
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in:
ab3948f58ff8 ("mm/memfd: add an F_SEAL_FUTURE_WRITE seal to memfd")
And silence this perf build warning:
Warning: Kernel ABI header at 'tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h' diff -u tools/include/uapi/linux/fcntl.h include/uapi/linux/fcntl.h
--- tools/include/uapi/linux/fcntl.h | 1 + 1 file changed, 1 insertion(+)
tools/include/uapi/linux/fcntl.h +1 -0
@@ -41,6 +41,7 @@#define F_SEAL_SHRINK 0x0002/* prevent file from shrinking */ #define F_SEAL_GROW 0x0004/* prevent file from growing */ #define F_SEAL_WRITE 0x0008/* prevent writes */ +#define F_SEAL_FUTURE_WRITE 0x0010/* prevent future writes while mapped */ /* (1U << 31) is reserved for signed error codes */ /*
Signature · 1 line
2.20.1
Re: [PATCH 05/13] tools headers uapi: Sync linux/fcntl.h to get the F_SEAL_FUTURE_WRITE addition
Quoted 11 lines · Arnaldo Carvalho de Melo
From: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in:
ab3948f58ff8("mm/memfd: add anF_SEAL_FUTURE_WRITEseal to memfd")And silence this perf build warning:
Warning: Kernel ABI header at '
tools/include/uapi/linux/fcntl.h' differs from latest version at 'include/uapi/linux/fcntl.h' diff -utools/include/uapi/linux/fcntl.hinclude/uapi/linux/fcntl.h
Quoted 7 lines
Cc Adrian Hunter <[email protected]>Cc Jiri Olsa <[email protected]>Cc Joel Fernandes (Google) <[email protected]>Cc Linus Torvalds <[email protected]>Cc Namhyung Kim <[email protected]>Signed-off-by Arnaldo Carvalho de Melo <[email protected]>
thanks!
- Joel
Quoted 19 lines
--- tools/include/uapi/linux/fcntl.h | 1 + 1 file changed, 1 insertion(+)tools/include/uapi/linux/fcntl.h +1
-0@@ -41,6 +41,7 @@#define F_SEAL_SHRINK 0x0002/* prevent file from shrinking */ #define F_SEAL_GROW 0x0004/* prevent file from growing */ #define F_SEAL_WRITE 0x0008/* prevent writes */ +#define F_SEAL_FUTURE_WRITE 0x0010/* prevent future writes while mapped */ /* (1U << 31) is reserved for signed error codes */ /* Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 6/13 tools arch x86: Sync asm/cpufeatures.h with the kernel sources
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To get the changes from:
52f64909409c ("x86: Add TSX Force Abort CPUID/MSR")
That don't cause any changes in the generated perf binaries.
And silence this perf build warning:
Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h' diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
--- tools/arch/x86/include/asm/cpufeatures.h | 1 + 1 file changed, 1 insertion(+)
tools/arch/x86/include/asm/cpufeatures.h +1 -0
@@ -344,6 +344,7 @@/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */ #define X86_FEATURE_AVX512_4VNNIW (18*32+ 2)/* AVX-512 Neural Network Instructions */ #define X86_FEATURE_AVX512_4FMAPS (18*32+ 3)/* AVX-512 Multiply Accumulation Single precision */ +#define X86_FEATURE_TSX_FORCE_ABORT (18*32+13)/* "" TSX_FORCE_ABORT */ #define X86_FEATURE_PCONFIG (18*32+18)/* Intel PCONFIG */ #define X86_FEATURE_SPEC_CTRL (18*32+26)/* "" Speculation Control (IBRS + IBPB) */ #define X86_FEATURE_INTEL_STIBP (18*32+27)/* "" Single Thread Indirect Branch Predictors */
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 7/13 tools headers uapi: Update drm/i915_drm.h
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To get the changes in:
e46c2e99f600 ("drm/i915: Expose RPCS (SSEU) configuration to userspace (Gen11 only)")
That don't cause changes in the generated perf binaries.
To silence this perf build warning:
Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h' diff -u tools/include/uapi/drm/i915_drm.h include/uapi/drm/i915_drm.h
--- tools/include/uapi/drm/i915_drm.h | 64 +++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
tools/include/uapi/drm/i915_drm.h +64 -0
@@ -1486,9 +1486,73 @@ struct drm_i915_gem_context_param {#define I915_CONTEXT_MAX_USER_PRIORITY 1023/* inclusive */ #define I915_CONTEXT_DEFAULT_PRIORITY 0#define I915_CONTEXT_MIN_USER_PRIORITY -1023/* inclusive */ +/* +* When using the following param, value should be a pointer to +* drm_i915_gem_context_param_sseu. +*/ +#define I915_CONTEXT_PARAM_SSEU 0x7__u64 value; }; +/** +* Context SSEU programming +* +* It may be necessary for either functional or performance reason to configure +* a context to run with a reduced number of SSEU (where SSEU stands for Slice/ +* Sub-slice/EU). +* +* This is done by configuring SSEU configuration using the below +* @struct drm_i915_gem_context_param_sseu for every supported engine which +* userspace intends to use. +* +* Not all GPUs or engines support this functionality in which case an error +* code -ENODEV will be returned. +* +* Also, flexibility of possible SSEU configuration permutations varies between +* GPU generations and software imposed limitations. Requesting such a +* combination will return an error code of -EINVAL. +* +* NOTE: When perf/OA is active the context's SSEU configuration is ignored in +* favour of a single global setting. +*/ +struct drm_i915_gem_context_param_sseu { +/* +* Engine class & instance to be configured or queried. +*/ +__u16 engine_class; +__u16 engine_instance; + +/* +* Unused for now. Must be cleared to zero. +*/ +__u32 flags; + +/* +* Mask of slices to enable for the context. Valid values are a subset +* of the bitmask value returned for I915_PARAM_SLICE_MASK. +*/ +__u64 slice_mask; + +/* +* Mask of subslices to enable for the context. Valid values are a +* subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK. +*/ +__u64 subslice_mask; + +/* +* Minimum/Maximum number of EUs to enable per subslice for the +* context. min_eus_per_subslice must be inferior or equal to +* max_eus_per_subslice. +*/ +__u16 min_eus_per_subslice; +__u16 max_eus_per_subslice; + +/* +* Unused for now. Must be cleared to zero. +*/ +__u32 rsvd; +}; +enum drm_i915_oa_format {I915_OA_FORMAT_A13 =1 ,/* HSW only */ I915_OA_FORMAT_A29 ,/* HSW only */
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 8/13 tools headers: Update x86's syscall_64.tbl and uapi/asm-generic/unistd
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To pick up the changes introduced in the following csets:
2b188cc1bb85 ("Add io_uring IO interface")
edafccee56ff ("io_uring: add support for pre-mapped user IO buffers") 3eb39f47934f ("signal: add pidfd_send_signal() syscall")
This makes 'perf trace' to become aware of these new syscalls, so that one can use them like 'perf trace -e ui_uring*,*signal' to do a system wide strace-like session looking at those syscalls, for instance.
For example:
# perf trace -s io_uring-cp ~acme/isos/RHEL-x86_64-dvd1.iso ~/bla
Summary of events:
io_uring-cp (383), 1208866 events, 100.0%
syscall calls total min avg max stddev
(msec) (msec) (msec) (msec) (%)
-------------- ------ -------- ------ ------- ------- ------
io_uring_enter 605780 2955.615 0.000 0.005 33.804 1.94%
openat 4 459.446 0.004 114.861 459.435 100.00%
munmap 4 0.073 0.009 0.018 0.042 44.03%
mmap 10 0.054 0.002 0.005 0.026 43.24%
brk 28 0.038 0.001 0.001 0.003 7.51%
io_uring_setup 1 0.030 0.030 0.030 0.030 0.00%
mprotect 4 0.014 0.002 0.004 0.005 14.32%
close 5 0.012 0.001 0.002 0.004 28.87%
fstat 3 0.006 0.001 0.002 0.003 35.83%
read 4 0.004 0.001 0.001 0.002 13.58%
access 1 0.003 0.003 0.003 0.003 0.00%
lseek 3 0.002 0.001 0.001 0.001 9.00%
arch_prctl 2 0.002 0.001 0.001 0.001 0.69%
execve 1 0.000 0.000 0.000 0.000 0.00%
#
# perf trace -e io_uring* -s io_uring-cp ~acme/isos/RHEL-x86_64-dvd1.iso ~/blaSummary of events:
io_uring-cp (390), 1191250 events, 100.0%
syscall calls total min avg max stddev
(msec) (msec) (msec) (msec) (%)
-------------- ------ -------- ------ ------ ------ ------
io_uring_enter 597093 2706.060 0.001 0.005 14.761 1.10%
io_uring_setup 1 0.038 0.038 0.038 0.038 0.00%#
More work needed to make the tools/perf/examples/bpf/augmented_raw_syscalls.c BPF program to copy the 'struct io_uring_params' arguments to perf's ring buffer so that 'perf trace' can use the BTF info put in place by pahole's conversion of the kernel DWARF and then auto-beautify those arguments.
This patch produces the expected change in the generated syscalls table for x86_64:
--- /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c.before 2019-03-26 13:37:46.679057774 -0300
+++ /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c 2019-03-26 13:38:12.755990383 -0300
@@ -334,5 +334,9 @@ static const char *syscalltbl_x86_64[] =
[332] = "statx",
[333] = "io_pgetevents",
[334] = "rseq",
+ [424] = "pidfd_send_signal",
+ [425] = "io_uring_setup",
+ [426] = "io_uring_enter",
+ [427] = "io_uring_register",
};
-#define SYSCALLTBL_x86_64_MAX_ID 334
+#define SYSCALLTBL_x86_64_MAX_ID 427
This silences these perf build warnings:
Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h' diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl' diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
--- tools/include/uapi/asm-generic/unistd.h | 11 ++++++++++- tools/perf/arch/x86/entry/syscalls/syscall_64.tbl | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-)
tools/include/uapi/asm-generic/unistd.h +10 -1
@@ -824,8 +824,17 @@ __SYSCALL(__NR_futex_time64, sys_futex) __SYSCALL(__NR_sched_rr_get_interval_time64, sys_sched_rr_get_interval)#endif +#define __NR_pidfd_send_signal 424 +__SYSCALL(__NR_pidfd_send_signal, sys_pidfd_send_signal) +#define __NR_io_uring_setup 425 +__SYSCALL(__NR_io_uring_setup, sys_io_uring_setup) +#define __NR_io_uring_enter 426 +__SYSCALL(__NR_io_uring_enter, sys_io_uring_enter) +#define __NR_io_uring_register 427 +__SYSCALL(__NR_io_uring_register, sys_io_uring_register) +#undef __NR_syscalls -#define __NR_syscalls 424 +#define __NR_syscalls 428/* * 32 bit systems traditionally used different
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl +4 -0
@@ -345,6 +345,10 @@ 334 common rseq __x64_sys_rseq # don't use numbers 387 through 423, add new calls after the last # 'common' entry +424 common pidfd_send_signal __x64_sys_pidfd_send_signal +425 common io_uring_setup __x64_sys_io_uring_setup +426 common io_uring_enter __x64_sys_io_uring_enter +427 common io_uring_register __x64_sys_io_uring_register # # x32-specific system call numbers start at 512 to avoid cache impact
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 9/13 tools headers uapi: Sync powerpc's asm/kvm.h copy with the kernel sources
In reply to Arnaldo Carvalho de MeloFrom: Arnaldo Carvalho de Melo <[email protected]>
To pick up the changes in:
2b57ecd0208f ("KVM: PPC: Book3S: Add count cache flush parameters to kvmppc_get_cpu_char()")
That don't cause any changes in the tools.
This silences this perf build warning:
Warning: Kernel ABI header at 'tools/arch/powerpc/include/uapi/asm/kvm.h' differs from latest version at 'arch/powerpc/include/uapi/asm/kvm.h' diff -u tools/arch/powerpc/include/uapi/asm/kvm.h arch/powerpc/include/uapi/asm/kvm.h
--- tools/arch/powerpc/include/uapi/asm/kvm.h | 2 ++ 1 file changed, 2 insertions(+)
tools/arch/powerpc/include/uapi/asm/kvm.h +2 -0
@@ -463,10 +463,12 @@ struct kvm_ppc_cpu_char {#define KVM_PPC_CPU_CHAR_BR_HINT_HONOURED (1ULL << 58)#define KVM_PPC_CPU_CHAR_MTTRIG_THR_RECONF (1ULL << 57)#define KVM_PPC_CPU_CHAR_COUNT_CACHE_DIS (1ULL << 56) +#define KVM_PPC_CPU_CHAR_BCCTR_FLUSH_ASSIST (1ull << 54)#define KVM_PPC_CPU_BEHAV_FAVOUR_SECURITY (1ULL << 63)#define KVM_PPC_CPU_BEHAV_L1D_FLUSH_PR (1ULL << 62)#define KVM_PPC_CPU_BEHAV_BNDS_CHK_SPEC_BAR (1ULL << 61) +#define KVM_PPC_CPU_BEHAV_FLUSH_COUNT_CACHE (1ull << 58)/* Per-vcpu XICS interrupt controller state */ #define KVM_REG_PPC_ICP_STATE (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0x8c)
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 10/13 perf machine: Update kernel map address and re-order properly
In reply to Arnaldo Carvalho de MeloFrom: Wei Li <[email protected]>
Since commit 1fb87b8e9599 ("perf machine: Don't search for active kernel start in __machine__create_kernel_maps"), the __machine__create_kernel_maps() just create a map what start and end are both zero. Though the address will be updated later, the order of map in the rbtree may be incorrect.
The commit ee05d21791db ("perf machine: Set main kernel end address properly") fixed the logic in machine__create_kernel_maps(), but it's still wrong in function machine__process_kernel_mmap_event().
To reproduce this issue, we need an environment which the module address is before the kernel text segment. I tested it on an aarch64 machine with kernel 4.19.25:
[root@localhost hulk]# grep _stext /proc/kallsyms ffff000008081000 T _stext
[root@localhost hulk]# grep _etext /proc/kallsyms ffff000009780000 R _etext
[root@localhost hulk]# tail /proc/modules hisi_sas_v2_hw 77824 0 - Live 0xffff00000191d000 nvme_core 126976 7 nvme, Live 0xffff0000018b6000
mdio 20480 1 ixgbe, Live 0xffff0000018ab000 hisi_sas_main 106496 1 hisi_sas_v2_hw, Live 0xffff000001861000 hns_mdio 20480 2 - Live 0xffff000001822000
hnae 28672 3 hns_dsaf,hns_enet_drv, Live 0xffff000001815000 dm_mirror 40960 0 - Live 0xffff000001804000 dm_region_hash 32768 1 dm_mirror, Live 0xffff0000017f5000 dm_log 32768 2 dm_mirror,dm_region_hash, Live 0xffff0000017e7000 dm_mod 315392 17 dm_mirror,dm_log, Live 0xffff000001780000 [root@localhost hulk]#
Before fix:
[root@localhost bin]# perf record sleep 3
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.011 MB perf.data (9 samples) ] [root@localhost bin]# perf buildid-list -i perf.data 4c4e46c971ca935f781e603a09b52a92e8bdfee8 [vdso] [root@localhost bin]# perf buildid-list -i perf.data -H 0000000000000000000000000000000000000000 /proc/kcore [root@localhost bin]#
After fix:
[root@localhost tools]# ./perf/perf record sleep 3
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.011 MB perf.data (9 samples) ] [root@localhost tools]# ./perf/perf buildid-list -i perf.data 28a6c690262896dbd1b5e1011ed81623e6db0610 [kernel.kallsyms] 106c14ce6e4acea3453e484dc604d66666f08a2f [vdso] [root@localhost tools]# ./perf/perf buildid-list -i perf.data -H 28a6c690262896dbd1b5e1011ed81623e6db0610 /proc/kcore
--- tools/perf/util/machine.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-)
tools/perf/util/machine.c +20 -12
@@ -1421,6 +1421,20 @@ static void machine__set_kernel_mmap(struct machine *machine, machine->vmlinux_map->end = ~0ULL ; } +static void machine__update_kernel_mmap (struct machine *machine, +u64 start,u64 end) +{ +struct map *map =machine__kernel_map (machine); + +map__get (map); +map_groups__remove (&machine->kmaps, map); + +machine__set_kernel_mmap (machine, start, end); + +map_groups__insert (&machine->kmaps, map); +map__put (map); +} +int machine__create_kernel_maps (struct machine *machine) {struct dso *kernel =machine__get_kernel (machine);
@@ -1453,17 +1467,11 @@ int machine__create_kernel_maps(struct machine *machine) goto out_put; } -/* we have a real start address now, so re-order the kmaps */ - map =machine__kernel_map (machine); - -map__get (map); -map_groups__remove (&machine->kmaps, map); - -/* assume it's the last in the kmaps */ -machine__set_kernel_mmap (machine, addr, ~0ULL ); - -map_groups__insert (&machine->kmaps, map); -map__put (map); +/* +* we have a real start address now, so re-order the kmaps +* assume it's the last in the kmaps +*/ +machine__update_kernel_mmap (machine, addr, ~0ULL ); }if (machine__create_extra_kernel_maps (machine, kernel))
@@ -1599,7 +1607,7 @@ static int machine__process_kernel_mmap_event(struct machine *machine,if (strstr (kernel->long_name,"vmlinux" ))dso__set_short_name (kernel,"[kernel.vmlinux]" , false); -machine__set_kernel_mmap (machine, event->mmap.start, +machine__update_kernel_mmap (machine, event->mmap.start, event->mmap.start + event->mmap.len);/*
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 11/13 perf scripts python: exported-sql-viewer.py: Fix never-ending loop
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
pyside version 1 fails to handle python3 large integers in some cases, resulting in Qt getting into a never-ending loop. This affects:
samples Table
samples_view Table
All branches Report
Selected branches Report
Add workarounds for those cases.
--- .../scripts/python/exported-sql-viewer.py | 60 +++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +50 -10
@@ -107,6 +107,7 @@ import os from PySide.QtCore import * from PySide.QtGui import * from PySide.QtSql import * +pyside_version_1 = True from decimal import * from ctypes import * from multiprocessing import Process, Array, Value, Event
@@ -1526,6 +1527,19 @@ def BranchDataPrep(query): " (" + dsoname(query.value(15)) + ")") return data +def BranchDataPrepWA(query): + data = [] + data.append(query.value(0)) + # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string + data.append("{:>19}".format(query.value(1))) + for i in xrange(2, 8): + data.append(query.value(i)) + data.append(tohex(query.value(8)).rjust(16) + " " + query.value(9) + offstr(query.value(10)) + + " (" + dsoname(query.value(11)) + ")" + " -> " + + tohex(query.value(12)) + " " + query.value(13) + offstr(query.value(14)) + + " (" + dsoname(query.value(15)) + ")") + return data + # Branch data model class BranchModel(TreeModel):
@@ -1553,7 +1567,11 @@ class BranchModel(TreeModel): " AND evsel_id = " + str(self.event_id) + " ORDER BY samples.id" " LIMIT " + str(glb_chunk_sz)) - self.fetcher = SQLFetcher(glb, sql, BranchDataPrep, self.AddSample) + if pyside_version_1 and sys.version_info[0] == 3: + prep = BranchDataPrepWA + else: + prep = BranchDataPrep + self.fetcher = SQLFetcher(glb, sql, prep, self.AddSample) self.fetcher.done.connect(self.Update) self.fetcher.Fetch(glb_chunk_sz)
@@ -2079,14 +2097,6 @@ def IsSelectable(db, table, sql = ""): return False return True -# SQL data preparation - -def SQLTableDataPrep(query, count): - data = [] - for i in xrange(count): - data.append(query.value(i)) - return data - # SQL table data model item class SQLTableItem():
@@ -2110,7 +2120,7 @@ class SQLTableModel(TableModel): self.more = True self.populated = 0 self.column_headers = column_headers - self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): SQLTableDataPrep(x, y), self.AddSample) + self.fetcher = SQLFetcher(glb, sql, lambda x, y=len(column_headers): self.SQLTableDataPrep(x, y), self.AddSample) self.fetcher.done.connect(self.Update) self.fetcher.Fetch(glb_chunk_sz)
@@ -2154,6 +2164,12 @@ class SQLTableModel(TableModel): def columnHeader(self, column): return self.column_headers[column] + def SQLTableDataPrep(self, query, count): + data = [] + for i in xrange(count): + data.append(query.value(i)) + return data + # SQL automatic table data model class SQLAutoTableModel(SQLTableModel):
@@ -2182,8 +2198,32 @@ class SQLAutoTableModel(SQLTableModel): QueryExec(query, "SELECT column_name FROM information_schema.columns WHERE table_schema = '" + schema + "' and table_name = '" + select_table_name + "'") while query.next(): column_headers.append(query.value(0)) + if pyside_version_1 and sys.version_info[0] == 3: + if table_name == "samples_view": + self.SQLTableDataPrep = self.samples_view_DataPrep + if table_name == "samples": + self.SQLTableDataPrep = self.samples_DataPrep super(SQLAutoTableModel, self).__init__(glb, sql, column_headers, parent) + def samples_view_DataPrep(self, query, count): + data = [] + data.append(query.value(0)) + # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string + data.append("{:>19}".format(query.value(1))) + for i in xrange(2, count): + data.append(query.value(i)) + return data + + def samples_DataPrep(self, query, count): + data = [] + for i in xrange(9): + data.append(query.value(i)) + # Workaround pyside failing to handle large integers (i.e. time) in python3 by converting to a string + data.append("{:>19}".format(query.value(9))) + for i in xrange(10, count): + data.append(query.value(i)) + return data + # Base class for custom ResizeColumnsToContents class ResizeColumnsToContentsBase(QObject):
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 12/13 perf scripts python: exported-sql-viewer.py: Fix python3 support
In reply to Arnaldo Carvalho de MeloFrom: Adrian Hunter <[email protected]>
Unlike python2, python3 strings are not compatible with byte strings. That results in disassembly not working for the branches reports. Fixup those places overlooked in the port to python3.
--- .../perf/scripts/python/exported-sql-viewer.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
tools/perf/scripts/python/exported-sql-viewer.py +13 -4
@@ -2908,9 +2908,13 @@ class LibXED(): ok = self.xed_format_context(2, inst.xedp, inst.bufferp, sizeof(inst.buffer), ip, 0, 0) if not ok: return 0, "" + if sys.version_info[0] == 2: + result = inst.buffer.value + else: + result = inst.buffer.value.decode() # Return instruction length and the disassembled instruction text # For now, assume the length is in byte 166 - return inst.xedd[166], inst.buffer.value + return inst.xedd[166], result def TryOpen(file_name): try:
@@ -2926,9 +2930,14 @@ def Is64Bit(f): header = f.read(7) f.seek(pos) magic = header[0:4] - eclass = ord(header[4]) - encoding = ord(header[5]) - version = ord(header[6]) + if sys.version_info[0] == 2: + eclass = ord(header[4]) + encoding = ord(header[5]) + version = ord(header[6]) + else: + eclass = header[4] + encoding = header[5] + version = header[6] if magic == chr(127) + "ELF" and eclass > 0 and eclass < 3 and encoding > 0 and encoding < 3 and version == 1: result = True if eclass == 2 else False return result
Signature · 1 line
2.20.1
Arnaldo Carvalho de Melo
maintainerPATCH 13/13 perf pmu: Fix parser error for uncore event alias
In reply to Arnaldo Carvalho de MeloFrom: Kan Liang <[email protected]>
Perf fails to parse uncore event alias, for example:
# perf stat -e unc_m_clockticks -a --no-merge sleep 1
event syntax error: 'unc_m_clockticks'
\___ parser errorCurrent code assumes that the event alias is from one specific PMU.
To find the PMU, perf strcmps the PMU name of event alias with the real PMU name on the system.
However, the uncore event alias may be from multiple PMUs with common prefix. The PMU name of uncore event alias is the common prefix.
For example, UNC_M_CLOCKTICKS is clock event for iMC, which include 6 PMUs with the same prefix "uncore_imc" on a skylake server.
The real PMU names on the system for iMC are uncore_imc_0 ... uncore_imc_5.
The strncmp is used to only check the common prefix for uncore event alias.
With the patch:
# perf stat -e unc_m_clockticks -a --no-merge sleep 1 Performance counter stats for 'system wide':
723,594,722 unc_m_clockticks [uncore_imc_5]
724,001,954 unc_m_clockticks [uncore_imc_3]
724,042,655 unc_m_clockticks [uncore_imc_1]
724,161,001 unc_m_clockticks [uncore_imc_4]
724,293,713 unc_m_clockticks [uncore_imc_2]
724,340,901 unc_m_clockticks [uncore_imc_0]1.002090060 seconds time elapsed
--- tools/perf/util/pmu.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
tools/perf/util/pmu.c +10 -0
@@ -732,10 +732,20 @@ static void pmu_add_cpu_aliases(struct list_head *head, struct perf_pmu *pmu)if (!is_arm_pmu_core (name)) { pname = pe->pmu ? pe->pmu :"cpu" ; + +/* +* uncore alias may be from different PMU +* with common prefix +*/ +if (pmu_is_uncore (name) && + !strncmp (pname, name,strlen (pname))) + goto new_alias; +if (strcmp (pname, name))continue ; } +new_alias:/* need type casts to override 'const' */ __perf_pmu__new_alias(head, NULL, (char *)pe->name, (char *)pe->desc, (char *)pe->event,
Signature · 1 line
2.20.1