05 Jan, 2020

8 commits

  • [ Upstream commit 746dd4012d215b53152f0001a48856e41ea31730 ]

    When running test_vmalloc.sh smoke the following print out states that
    the fragment is missing.

    # ./test_vmalloc.sh: You must have the following enabled in your kernel:
    # CONFIG_TEST_VMALLOC=m

    Rework to add the fragment 'CONFIG_TEST_VMALLOC=m' to the config file.

    Link: http://lkml.kernel.org/r/20190916095217.19665-1-anders.roxell@linaro.org
    Fixes: a05ef00c9790 ("selftests/vm: add script helper for CONFIG_TEST_VMALLOC_MODULE")
    Signed-off-by: Anders Roxell
    Cc: Shuah Khan
    Cc: "Uladzislau Rezki (Sony)"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Anders Roxell
     
  • [ Upstream commit 5b596e0ff0e1852197d4c82d3314db5e43126bf7 ]

    To avoid breaking the build on arches where this is not wired up, at
    least all the other features should be made available and when using
    this specific routine, the "unknown" should point the user/developer to
    the need to wire this up on this particular hardware architecture.

    Detected in a container mipsel debian cross build environment, where it
    shows up as:

    In file included from /usr/mipsel-linux-gnu/include/stdio.h:867,
    from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
    from util/session.c:13:
    In function 'printf',
    inlined from 'regs_dump__printf' at util/session.c:1103:3,
    inlined from 'regs__printf' at util/session.c:1131:2:
    /usr/mipsel-linux-gnu/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
    107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    cross compiler details:

    mipsel-linux-gnu-gcc (Debian 9.2.1-8) 9.2.1 20190909

    Also on mips64:

    In file included from /usr/mips64-linux-gnuabi64/include/stdio.h:867,
    from /git/linux/tools/perf/lib/include/perf/cpumap.h:6,
    from util/session.c:13:
    In function 'printf',
    inlined from 'regs_dump__printf' at util/session.c:1103:3,
    inlined from 'regs__printf' at util/session.c:1131:2,
    inlined from 'regs_user__printf' at util/session.c:1139:3,
    inlined from 'dump_sample' at util/session.c:1246:3,
    inlined from 'machines__deliver_event' at util/session.c:1421:3:
    /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
    107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    In function 'printf',
    inlined from 'regs_dump__printf' at util/session.c:1103:3,
    inlined from 'regs__printf' at util/session.c:1131:2,
    inlined from 'regs_intr__printf' at util/session.c:1147:3,
    inlined from 'dump_sample' at util/session.c:1249:3,
    inlined from 'machines__deliver_event' at util/session.c:1421:3:
    /usr/mips64-linux-gnuabi64/include/bits/stdio2.h:107:10: error: '%-5s' directive argument is null [-Werror=format-overflow=]
    107 | return __printf_chk (__USE_FORTIFY_LEVEL - 1, __fmt, __va_arg_pack ());
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    cross compiler details:

    mips64-linux-gnuabi64-gcc (Debian 9.2.1-8) 9.2.1 20190909

    Fixes: 2bcd355b71da ("perf tools: Add interface to arch registers sets")
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: https://lkml.kernel.org/n/tip-95wjyv4o65nuaeweq31t7l1s@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Arnaldo Carvalho de Melo
     
  • [ Upstream commit 0cd032d3b5fcebf5454315400ab310746a81ca53 ]

    brstackinsn must be allowed to be set by the user when AUX area data has
    been captured because, in that case, the branch stack might be
    synthesized on the fly. This fixes the following error:

    Before:

    $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
    [ perf record: Woken up 19 times to write data ]
    [ perf record: Captured and wrote 2.274 MB perf.data ]
    $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
    Display of branch stack assembler requested, but non all-branch filter set
    Hint: run 'perf record -b ...'

    After:

    $ perf record -e '{intel_pt//,cpu/mem_inst_retired.all_loads,aux-sample-size=8192/pp}:u' grep -rqs jhgjhg /boot
    [ perf record: Woken up 19 times to write data ]
    [ perf record: Captured and wrote 2.274 MB perf.data ]
    $ perf script -F +brstackinsn --xed --itrace=i1usl100 | head
    grep 13759 [002] 8091.310257: 1862 instructions:uH: 5641d58069eb bmexec+0x86b (/bin/grep)
    bmexec+2485:
    00005641d5806b35 jnz 0x5641d5806bd0 # MISPRED
    00005641d5806bd0 movzxb (%r13,%rdx,1), %eax
    00005641d5806bd6 add %rdi, %rax
    00005641d5806bd9 movzxb -0x1(%rax), %edx
    00005641d5806bdd cmp %rax, %r14
    00005641d5806be0 jnb 0x5641d58069c0 # MISPRED
    mismatch of LBR data and executable
    00005641d58069c0 movzxb (%r13,%rdx,1), %edi

    Fixes: 48d02a1d5c13 ("perf script: Add 'brstackinsn' for branch stacks")
    Reported-by: Andi Kleen
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Link: http://lore.kernel.org/lkml/20191127095322.15417-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Adrian Hunter
     
  • [ Upstream commit 98e93245113d0f5c279ef77f4a9e7d097323ad71 ]

    To fix these build errors on a debian mipsel cross build environment:

    builtin-diff.c: In function 'block_cycles_diff_cmp':
    builtin-diff.c:550:6: error: absolute value function 'labs' given an argument of type 's64' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]
    550 | l = labs(left->diff.cycles);
    | ^~~~
    builtin-diff.c:551:6: error: absolute value function 'labs' given an argument of type 's64' {aka 'long long int'} but has parameter of type 'long int' which may cause truncation of value [-Werror=absolute-value]
    551 | r = labs(right->diff.cycles);
    | ^~~~

    Fixes: 99150a1faab2 ("perf diff: Use hists to manage basic blocks per symbol")
    Cc: Jin Yao
    Cc: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: https://lkml.kernel.org/n/tip-pn7szy5uw384ntjgk6zckh6a@git.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Arnaldo Carvalho de Melo
     
  • [ Upstream commit 20183ccd3e4d01d23b0a01fe9f3ee73fbae312fa ]

    It is possible that certain config levels are not available, even
    if the max level includes the level. There can be missing levels in
    some platforms. So ignore the level when called for information dump
    for all levels and fail if specifically ask for the missing level.

    Here the changes is to continue reading information about other levels
    even if we fail to get information for the current level. But use the
    "processed" flag to indicate the failure. When the "processed" flag is
    not set, don't dump information about that level.

    Signed-off-by: Srinivas Pandruvada
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Sasha Levin

    Srinivas Pandruvada
     
  • [ Upstream commit 505127068d9b705a6cf335143239db91bfe7bbe2 ]

    On systems where TM (Transactional Memory) is disabled the
    tm-signal-sigreturn-nt test causes a SIGILL:

    test: tm_signal_sigreturn_nt
    tags: git_version:7c202575ef63
    !! child died by signal 4
    failure: tm_signal_sigreturn_nt

    We should skip the test if TM is not available.

    Fixes: 34642d70ac7e ("selftests/powerpc: Add checks for transactional sigreturn")
    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20191104233524.24348-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin

    Michael Ellerman
     
  • [ Upstream commit a02cbc7ffe529ed58b6bbe54652104fc2c88bd77 ]

    Some of our TM (Transactional Memory) tests, list "r1" (the stack
    pointer) as a clobbered register.

    GCC >= 9 doesn't accept this, and the build breaks:

    ptrace-tm-spd-tar.c: In function 'tm_spd_tar':
    ptrace-tm-spd-tar.c:31:2: error: listing the stack pointer register 'r1' in a clobber list is deprecated [-Werror=deprecated]
    31 | asm __volatile__(
    | ^~~
    ptrace-tm-spd-tar.c:31:2: note: the value of the stack pointer after an 'asm' statement must be the same as it was before the statement

    We do have some fairly large inline asm blocks in these tests, and
    some of them do change the value of r1. However they should all return
    to C with the value in r1 restored, so I think it's legitimate to say
    r1 is not clobbered.

    As Segher points out, the r1 clobbers may have been added because of
    the use of `or 1,1,1`, however that doesn't actually clobber r1.

    Segher also points out that some of these tests do clobber LR, because
    they call functions, and that is not listed in the clobbers, so add
    that where appropriate.

    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20191029095324.14669-1-mpe@ellerman.id.au
    Signed-off-by: Sasha Levin

    Michael Ellerman
     
  • [ Upstream commit abd120e3bdf3dd72ba1ed9ac077a861e0e3dc43a ]

    Fix warning for:
    isst-config.c: In function ‘set_cpu_online_offline’:
    isst-config.c:221:3: warning: ignoring return value of ‘write’,
    declared with attribute warn_unused_result [-Wunused-result]
    write(fd, "1\n", 2);

    Signed-off-by: Srinivas Pandruvada
    Signed-off-by: Andy Shevchenko
    Signed-off-by: Sasha Levin

    Srinivas Pandruvada
     

31 Dec, 2019

32 commits

  • [ Upstream commit 6dd504b0fd1039c6e5d391e97cf5c4ee592aefcb ]

    This test only works when [1] is applied, which was rejected.

    Basically, the errors are reported and cleared. In this particular case of
    tls sockets, following reads will block.

    The test case was originally submitted with the rejected patch, but, then,
    was included as part of a different patchset, possibly by mistake.

    [1] https://lore.kernel.org/netdev/20191007035323.4360-2-jakub.kicinski@netronome.com/#t

    Thanks Paolo Pisati for pointing out the original patchset where this
    appeared.

    Fixes: 65190f77424d (selftests/tls: add a test for fragmented messages)
    Reported-by: Paolo Pisati
    Signed-off-by: Thadeu Lima de Souza Cascardo
    Signed-off-by: Jakub Kicinski
    Signed-off-by: Sasha Levin

    Thadeu Lima de Souza Cascardo
     
  • [ Upstream commit a89b2cbf71d64b61e79bbe5cb7ff4664797eeaaf ]

    Building selftests with 'make TARGETS=bpf kselftest' was fixed in commit
    55d554f5d140 ("tools: bpf: Use !building_out_of_srctree to determine
    srctree"). However, by updating $(srctree) in tools/bpf/Makefile for
    in-tree builds only, we leave out the case where we pass an output
    directory to build BPF tools, but $(srctree) is not set. This
    typically happens for:

    $ make -s tools/bpf O=/tmp/foo
    Makefile:40: /tools/build/Makefile.feature: No such file or directory

    Fix it by updating $(srctree) in the Makefile not only for out-of-tree
    builds, but also if $(srctree) is empty.

    Detected with test_bpftool_build.sh.

    Fixes: 55d554f5d140 ("tools: bpf: Use !building_out_of_srctree to determine srctree")
    Signed-off-by: Quentin Monnet
    Signed-off-by: Daniel Borkmann
    Acked-by: Jakub Kicinski
    Link: https://lore.kernel.org/bpf/20191119105626.21453-1-quentin.monnet@netronome.com
    Signed-off-by: Sasha Levin

    Quentin Monnet
     
  • [ Upstream commit 10992af6bf46a2048ad964985a5b77464e5563b1 ]

    It is necessary to free the memory that we have allocated when error occurs.

    Fixes: ef3072cd1d5c ("tools lib traceevent: Get rid of die in add_filter_type()")
    Signed-off-by: Hewenliang
    Reviewed-by: Steven Rostedt (VMware)
    Cc: Tzvetomir Stoyanov
    Link: http://lore.kernel.org/lkml/20191119014415.57210-1-hewenliang4@huawei.com
    Signed-off-by: Steven Rostedt (VMware)
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Hewenliang
     
  • commit 91e2f539eeda26ab00bd03fae8dc434c128c85ed upstream.

    Fix die_walk_lines() to list the function entry line correctly. Since
    the dwarf_entrypc() does not return the entry pc if the DIE has only
    range attribute, __die_walk_funclines() fails to list the declaration
    line (entry line) in that case.

    To solve this issue, this introduces die_entrypc() which correctly
    returns the entry PC (the first address range) even if the DIE has only
    range attribute. With this fix die_walk_lines() shows the function entry
    line is able to probe correctly.

    Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface")
    Signed-off-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157190837419.1859.4619125803596816752.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Thomas Backlund
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • [ Upstream commit bb1835a3b86c73aa534ef6430ad40223728dfbc0 ]

    Avoid termination of trace loading in case the last record in the
    decompressed buffer partly resides in the following mmaped
    PERF_RECORD_COMPRESSED record.

    In this case NULL value returned by fetch_mmaped_event() means to
    proceed to the next mmaped record then decompress it and load compressed
    events.

    The issue can be reproduced like this:

    $ perf record -z -- some_long_running_workload
    $ perf report --stdio -vv
    decomp (B): 44519 to 163000
    decomp (B): 48119 to 174800
    decomp (B): 65527 to 131072
    fetch_mmaped_event: head=0x1ffe0 event->header_size=0x28, mmap_size=0x20000: fuzzed perf.data?
    Error:
    failed to process sample
    ...

    Testing:

    71: Zstd perf.data compression/decompression : Ok

    $ tools/perf/perf report -vv --stdio
    decomp (B): 59593 to 262160
    decomp (B): 4438 to 16512
    decomp (B): 285 to 880
    Looking at the vmlinux_path (8 entries long)
    Using vmlinux for symbols
    decomp (B): 57474 to 261248
    prefetch_event: head=0x3fc78 event->header_size=0x28, mmap_size=0x3fc80: fuzzed or compressed perf.data?
    decomp (B): 25 to 32
    decomp (B): 52 to 120
    ...

    Fixes: 57fc032ad643 ("perf session: Avoid infinite loop when seeing invalid header.size")
    Link: https://marc.info/?l=linux-kernel&m=156580812427554&w=2
    Co-developed-by: Jiri Olsa
    Acked-by: Jiri Olsa
    Signed-off-by: Alexey Budankov
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/cf782c34-f3f8-2f9f-d6ab-145cee0d5322@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Alexey Budankov
     
  • [ Upstream commit 3de88c9113f88c04abda339f1aa629397bf89e02 ]

    Drivers use different fields to report the number of channels, so take
    the maximum of all data channels (rx, tx, combined) when determining the
    size of the xsk map. The current code used only 'combined' which was set
    to 0 in some drivers e.g. mlx4.

    Tested: compiled and run xdpsock -q 3 -r -S on mlx4

    Signed-off-by: Luigi Rizzo
    Signed-off-by: Alexei Starovoitov
    Reviewed-by: Jakub Kicinski
    Acked-by: Magnus Karlsson
    Link: https://lore.kernel.org/bpf/20191119001951.92930-1-lrizzo@google.com
    Signed-off-by: Sasha Levin

    Luigi Rizzo
     
  • [ Upstream commit b980be189c9badba50634671e2303e92bf28e35a ]

    Add to the opcode map the following instructions:
    cldemote
    tpause
    umonitor
    umwait
    movdiri
    movdir64b
    enqcmd
    enqcmds
    encls
    enclu
    enclv
    pconfig
    wbnoinvd

    For information about the instructions, refer Intel SDM May 2019
    (325462-070US) and Intel Architecture Instruction Set Extensions
    May 2019 (319433-037).

    The instruction decoding can be tested using the perf tools'
    "x86 instruction decoder - new instructions" test as folllows:

    $ perf test -v "new " 2>&1 | grep -i cldemote
    Decoded ok: 0f 1c 00 cldemote (%eax)
    Decoded ok: 0f 1c 05 78 56 34 12 cldemote 0x12345678
    Decoded ok: 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%eax,%ecx,8)
    Decoded ok: 0f 1c 00 cldemote (%rax)
    Decoded ok: 41 0f 1c 00 cldemote (%r8)
    Decoded ok: 0f 1c 04 25 78 56 34 12 cldemote 0x12345678
    Decoded ok: 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%rax,%rcx,8)
    Decoded ok: 41 0f 1c 84 c8 78 56 34 12 cldemote 0x12345678(%r8,%rcx,8)
    $ perf test -v "new " 2>&1 | grep -i tpause
    Decoded ok: 66 0f ae f3 tpause %ebx
    Decoded ok: 66 0f ae f3 tpause %ebx
    Decoded ok: 66 41 0f ae f0 tpause %r8d
    $ perf test -v "new " 2>&1 | grep -i umonitor
    Decoded ok: 67 f3 0f ae f0 umonitor %ax
    Decoded ok: f3 0f ae f0 umonitor %eax
    Decoded ok: 67 f3 0f ae f0 umonitor %eax
    Decoded ok: f3 0f ae f0 umonitor %rax
    Decoded ok: 67 f3 41 0f ae f0 umonitor %r8d
    $ perf test -v "new " 2>&1 | grep -i umwait
    Decoded ok: f2 0f ae f0 umwait %eax
    Decoded ok: f2 0f ae f0 umwait %eax
    Decoded ok: f2 41 0f ae f0 umwait %r8d
    $ perf test -v "new " 2>&1 | grep -i movdiri
    Decoded ok: 0f 38 f9 03 movdiri %eax,(%ebx)
    Decoded ok: 0f 38 f9 88 78 56 34 12 movdiri %ecx,0x12345678(%eax)
    Decoded ok: 48 0f 38 f9 03 movdiri %rax,(%rbx)
    Decoded ok: 48 0f 38 f9 88 78 56 34 12 movdiri %rcx,0x12345678(%rax)
    $ perf test -v "new " 2>&1 | grep -i movdir64b
    Decoded ok: 66 0f 38 f8 18 movdir64b (%eax),%ebx
    Decoded ok: 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%eax),%ecx
    Decoded ok: 67 66 0f 38 f8 1c movdir64b (%si),%bx
    Decoded ok: 67 66 0f 38 f8 8c 34 12 movdir64b 0x1234(%si),%cx
    Decoded ok: 66 0f 38 f8 18 movdir64b (%rax),%rbx
    Decoded ok: 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%rax),%rcx
    Decoded ok: 67 66 0f 38 f8 18 movdir64b (%eax),%ebx
    Decoded ok: 67 66 0f 38 f8 88 78 56 34 12 movdir64b 0x12345678(%eax),%ecx
    $ perf test -v "new " 2>&1 | grep -i enqcmd
    Decoded ok: f2 0f 38 f8 18 enqcmd (%eax),%ebx
    Decoded ok: f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%eax),%ecx
    Decoded ok: 67 f2 0f 38 f8 1c enqcmd (%si),%bx
    Decoded ok: 67 f2 0f 38 f8 8c 34 12 enqcmd 0x1234(%si),%cx
    Decoded ok: f3 0f 38 f8 18 enqcmds (%eax),%ebx
    Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx
    Decoded ok: 67 f3 0f 38 f8 1c enqcmds (%si),%bx
    Decoded ok: 67 f3 0f 38 f8 8c 34 12 enqcmds 0x1234(%si),%cx
    Decoded ok: f2 0f 38 f8 18 enqcmd (%rax),%rbx
    Decoded ok: f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%rax),%rcx
    Decoded ok: 67 f2 0f 38 f8 18 enqcmd (%eax),%ebx
    Decoded ok: 67 f2 0f 38 f8 88 78 56 34 12 enqcmd 0x12345678(%eax),%ecx
    Decoded ok: f3 0f 38 f8 18 enqcmds (%rax),%rbx
    Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%rax),%rcx
    Decoded ok: 67 f3 0f 38 f8 18 enqcmds (%eax),%ebx
    Decoded ok: 67 f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx
    $ perf test -v "new " 2>&1 | grep -i enqcmds
    Decoded ok: f3 0f 38 f8 18 enqcmds (%eax),%ebx
    Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx
    Decoded ok: 67 f3 0f 38 f8 1c enqcmds (%si),%bx
    Decoded ok: 67 f3 0f 38 f8 8c 34 12 enqcmds 0x1234(%si),%cx
    Decoded ok: f3 0f 38 f8 18 enqcmds (%rax),%rbx
    Decoded ok: f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%rax),%rcx
    Decoded ok: 67 f3 0f 38 f8 18 enqcmds (%eax),%ebx
    Decoded ok: 67 f3 0f 38 f8 88 78 56 34 12 enqcmds 0x12345678(%eax),%ecx
    $ perf test -v "new " 2>&1 | grep -i encls
    Decoded ok: 0f 01 cf encls
    Decoded ok: 0f 01 cf encls
    $ perf test -v "new " 2>&1 | grep -i enclu
    Decoded ok: 0f 01 d7 enclu
    Decoded ok: 0f 01 d7 enclu
    $ perf test -v "new " 2>&1 | grep -i enclv
    Decoded ok: 0f 01 c0 enclv
    Decoded ok: 0f 01 c0 enclv
    $ perf test -v "new " 2>&1 | grep -i pconfig
    Decoded ok: 0f 01 c5 pconfig
    Decoded ok: 0f 01 c5 pconfig
    $ perf test -v "new " 2>&1 | grep -i wbnoinvd
    Decoded ok: f3 0f 09 wbnoinvd
    Decoded ok: f3 0f 09 wbnoinvd

    Signed-off-by: Adrian Hunter
    Reviewed-by: Andi Kleen
    Acked-by: Masami Hiramatsu
    Cc: Borislav Petkov
    Cc: H. Peter Anvin
    Cc: Jiri Olsa
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: x86@kernel.org
    Link: http://lore.kernel.org/lkml/20191115135447.6519-3-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Adrian Hunter
     
  • [ Upstream commit 2ea2612b987ad703235c92be21d4e98ee9c2c67c ]

    Currently, with latest llvm trunk, selftest test_progs failed obj
    file test_seg6_loop.o with the following error in verifier:

    infinite loop detected at insn 76

    The byte code sequence looks like below, and noted that alu32 has been
    turned off by default for better generated codes in general:

    48: w3 = 100
    49: *(u32 *)(r10 - 68) = r3
    ...
    ; if (tlv.type == SR6_TLV_PADDING) {
    76: if w3 == 5 goto -18
    ...
    85: r1 = *(u32 *)(r10 - 68)
    ; for (int i = 0; i < 100; i++) {
    86: w1 += -1
    87: if w1 == 0 goto +5
    88: *(u32 *)(r10 - 68) = r1

    The main reason for verification failure is due to partial spills at
    r10 - 68 for induction variable "i".

    Current verifier only handles spills with 8-byte values. The above 4-byte
    value spill to stack is treated to STACK_MISC and its content is not
    saved. For the above example:

    w3 = 100
    R3_w=inv100 fp-64_w=inv1086626730498
    *(u32 *)(r10 - 68) = r3
    R3_w=inv100 fp-64_w=inv1086626730498
    ...
    r1 = *(u32 *)(r10 - 68)
    R1_w=inv(id=0,umax_value=4294967295,var_off=(0x0; 0xffffffff))
    fp-64=inv1086626730498

    To resolve this issue, verifier needs to be extended to track sub-registers
    in spilling, or llvm needs to enhanced to prevent sub-register spilling
    in register allocation phase. The former will increase verifier complexity
    and the latter will need some llvm "hacking".

    Let us workaround this issue by declaring the induction variable as "long"
    type so spilling will happen at non sub-register level. We can revisit this
    later if sub-register spilling causes similar or other verification issues.

    Signed-off-by: Yonghong Song
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/20191117214036.1309510-1-yhs@fb.com
    Signed-off-by: Sasha Levin

    Yonghong Song
     
  • [ Upstream commit 3b054b7133b4ad93671c82e8d6185258e3f1a7a5 ]

    When run_kselftests.sh is run, it hangs after test_tc_tunnel.sh. The reason
    is test_tc_tunnel.sh ensures the server ('nc -l') is run all the time,
    starting it again every time it is expected to terminate. The exception is
    the final client_connect: the server is not started anymore, which ensures
    no process is kept running after the test is finished.

    For a sit test, though, the script is terminated prematurely without the
    final client_connect and the 'nc' process keeps running. This in turn causes
    the run_one function in kselftest/runner.sh to hang forever, waiting for the
    runaway process to finish.

    Ensure a remaining server is terminated on cleanup.

    Fixes: f6ad6accaa99 ("selftests/bpf: expand test_tc_tunnel with SIT encap")
    Signed-off-by: Jiri Benc
    Signed-off-by: Daniel Borkmann
    Acked-by: Willem de Bruijn
    Link: https://lore.kernel.org/bpf/60919291657a9ee89c708d8aababc28ebe1420be.1573821780.git.jbenc@redhat.com
    Signed-off-by: Sasha Levin

    Jiri Benc
     
  • [ Upstream commit b7a0d65d80a0c5034b366392624397a0915b7556 ]

    With latest llvm compiler, running test_progs will have the following
    verifier failure for test_sysctl_loop1.o:

    libbpf: load bpf program failed: Permission denied
    libbpf: -- BEGIN DUMP LOG ---
    libbpf:
    invalid indirect read from stack var_off (0x0; 0xff)+196 size 7
    ...
    libbpf: -- END LOG --
    libbpf: failed to load program 'cgroup/sysctl'
    libbpf: failed to load object 'test_sysctl_loop1.o'

    The related bytecode looks as below:

    0000000000000308 LBB0_8:
    97: r4 = r10
    98: r4 += -288
    99: r4 += r7
    100: w8 &= 255
    101: r1 = r10
    102: r1 += -488
    103: r1 += r8
    104: r2 = 7
    105: r3 = 0
    106: call 106
    107: w1 = w0
    108: w1 += -1
    109: if w1 > 6 goto -24
    110: w0 += w8
    111: r7 += 8
    112: w8 = w0
    113: if r7 != 224 goto -17

    And source code:

    for (i = 0; i < ARRAY_SIZE(tcp_mem); ++i) {
    ret = bpf_strtoul(value + off, MAX_ULONG_STR_LEN, 0,
    tcp_mem + i);
    if (ret MAX_ULONG_STR_LEN)
    return 0;
    off += ret & MAX_ULONG_STR_LEN;
    }

    Current verifier is not able to conclude that register w0 before '+'
    at insn 110 has a range of 1 to 7 and thinks it is from 0 - 255. This
    leads to more conservative range for w8 at insn 112, and later verifier
    complaint.

    Let us workaround this issue until we found a compiler and/or verifier
    solution. The workaround in this patch is to make variable 'ret' volatile,
    which will force a reload and then '&' operation to ensure better value
    range. With this patch, I got the below byte code for the loop:

    0000000000000328 LBB0_9:
    101: r4 = r10
    102: r4 += -288
    103: r4 += r7
    104: w8 &= 255
    105: r1 = r10
    106: r1 += -488
    107: r1 += r8
    108: r2 = 7
    109: r3 = 0
    110: call 106
    111: *(u32 *)(r10 - 64) = r0
    112: r1 = *(u32 *)(r10 - 64)
    113: if w1 s< 1 goto -28
    114: r1 = *(u32 *)(r10 - 64)
    115: if w1 s> 7 goto -30
    116: r1 = *(u32 *)(r10 - 64)
    117: w1 &= 7
    118: w1 += w8
    119: r7 += 8
    120: w8 = w1
    121: if r7 != 224 goto -21

    Insn 117 did the '&' operation and we got more precise value range
    for 'w8' at insn 120. The test is happy then:

    #3/17 test_sysctl_loop1.o:OK

    Signed-off-by: Yonghong Song
    Signed-off-by: Daniel Borkmann
    Acked-by: Song Liu
    Link: https://lore.kernel.org/bpf/20191107170045.2503480-1-yhs@fb.com
    Signed-off-by: Sasha Levin

    Yonghong Song
     
  • [ Upstream commit 670cd6849ea36ea4df2f2941cf4717dff8755abe ]

    Fix printf format warnings on arm (and other 32bit arch).

    - udpgso.c and udpgso_bench_tx use %lu for size_t but it
    should be unsigned long long on 32bit arch.

    - so_txtime.c uses %ld for int64_t, but it should be
    unsigned long long on 32bit arch.

    Signed-off-by: Masami Hiramatsu
    Cc: Willem de Bruijn
    Cc: David S. Miller
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 2f3571ea71311bbb2cbb9c3bbefc9c1969a3e889 ]

    Currently proc-self-map-files-002.c sets va_max (max test address
    of user virtual address) to 4GB, but it is too big for 32bit
    arch and 1UL << 32 is overflow on 32bit long.
    Also since this value should be enough bigger than vm.mmap_min_addr
    (64KB or 32KB by default), 1MB should be enough.

    Make va_max 1MB unconditionally.

    Signed-off-by: Masami Hiramatsu
    Cc: Alexey Dobriyan
    Signed-off-by: Shuah Khan
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 9656b346b280c3e49c8a116c3a715f966633b161 ]

    Fix issue reported by static analysis (Coverity). If bpf_prog_get_fd_by_id()
    fails, xsk_lookup_bpf_maps() will fail as well and clean-up code will attempt
    close() with fd=-1. Fix by checking bpf_prog_get_fd_by_id() return result and
    exiting early.

    Fixes: 10a13bb40e54 ("libbpf: remove qidconf and better support external bpf programs.")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/20191107054059.313884-1-andriin@fb.com
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     
  • [ Upstream commit da6cb952a89efe24bb76c4971370d485737a2d85 ]

    Filter out instances except for inlined_subroutine and subprogram DIE in
    die_walk_instances() and die_is_func_instance().

    This fixes an issue that perf probe sets some probes on calling address
    instead of a target function itself.

    When perf probe walks on instances of an abstruct origin (a kind of
    function prototype of inlined function), die_walk_instances() can also
    pass a GNU_call_site (a GNU extension for call site) to callback. Since
    it is not an inlined instance of target function, we have to filter out
    when searching a probe point.

    Without this patch, perf probe sets probes on call site address too.This
    can happen on some function which is marked "inlined", but has actual
    symbol. (I'm not sure why GCC mark it "inlined"):

    # perf probe -D vfs_read
    p:probe/vfs_read _text+2500017
    p:probe/vfs_read_1 _text+2499468
    p:probe/vfs_read_2 _text+2499563
    p:probe/vfs_read_3 _text+2498876
    p:probe/vfs_read_4 _text+2498512
    p:probe/vfs_read_5 _text+2498627

    With this patch:

    Slightly different results, similar tho:

    # perf probe -D vfs_read
    p:probe/vfs_read _text+2498512

    Committer testing:

    # uname -a
    Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

    Before:

    # perf probe -D vfs_read
    p:probe/vfs_read _text+3131557
    p:probe/vfs_read_1 _text+3130975
    p:probe/vfs_read_2 _text+3131047
    p:probe/vfs_read_3 _text+3130380
    p:probe/vfs_read_4 _text+3130000
    # uname -a
    Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    #

    After:

    # perf probe -D vfs_read
    p:probe/vfs_read _text+3130000
    #

    Fixes: db0d2c6420ee ("perf probe: Search concrete out-of-line instances")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157241937063.32002.11024544873990816590.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit f4d99bdfd124823a81878b44b5e8750b97f73902 ]

    Skip end-of-sequence and non-statement lines while walking through lines
    list.

    The "end-of-sequence" line information means:

    "the current address is that of the first byte after the
    end of a sequence of target machine instructions."
    (DWARF version 4 spec 6.2.2)

    This actually means out of scope and we can not probe on it.

    On the other hand, the statement lines (is_stmt) means:

    "the current instruction is a recommended breakpoint location.
    A recommended breakpoint location is intended to “represent”
    a line, a statement and/or a semantically distinct subpart
    of a statement."

    (DWARF version 4 spec 6.2.2)

    So, non-statement line info also should be skipped.

    These can reduce unneeded probe points and also avoid an error.

    E.g. without this patch:

    # perf probe -a "clear_tasks_mm_cpumask:1"
    Added new events:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_3 (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_4 (on clear_tasks_mm_cpumask:1)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask_4 -aR sleep 1

    #

    This puts 5 probes on one line, but acutally it's not inlined function.
    This is because there are many non statement instructions at the
    function prologue.

    With this patch:

    # perf probe -a "clear_tasks_mm_cpumask:1"
    Added new event:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1

    #

    Now perf-probe skips unneeded addresses.

    Committer testing:

    Slightly different results, but similar:

    Before:

    # uname -a
    Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
    #
    # perf probe -a "clear_tasks_mm_cpumask:1"
    Added new events:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:1)
    probe:clear_tasks_mm_cpumask_2 (on clear_tasks_mm_cpumask:1)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask_2 -aR sleep 1

    #

    After:

    # perf probe -a "clear_tasks_mm_cpumask:1"
    Added new event:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask:1)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1

    # perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
    #

    Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157241936090.32002.12156347518596111660.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 86c0bf8539e7f46d91bd105e55eda96e0064caef ]

    Fix to show calling lines of inlined functions (where an inline function
    is called).

    die_walk_lines() filtered out the lines inside inlined functions based
    on the address. However this also filtered out the lines which call
    those inlined functions from the target function.

    To solve this issue, check the call_file and call_line attributes and do
    not filter out if it matches to the line information.

    Without this fix, perf probe -L doesn't show some lines correctly.
    (don't see the lines after 17)

    # perf probe -L vfs_read

    0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
    1 {
    2 ssize_t ret;

    4 if (!(file->f_mode & FMODE_READ))
    return -EBADF;
    6 if (!(file->f_mode & FMODE_CAN_READ))
    return -EINVAL;
    8 if (unlikely(!access_ok(buf, count)))
    return -EFAULT;

    11 ret = rw_verify_area(READ, file, pos, count);
    12 if (!ret) {
    13 if (count > MAX_RW_COUNT)
    count = MAX_RW_COUNT;
    15 ret = __vfs_read(file, buf, count, pos);
    16 if (ret > 0) {
    fsnotify_access(file);
    add_rchar(current, ret);
    }

    With this fix:

    # perf probe -L vfs_read

    0 ssize_t vfs_read(struct file *file, char __user *buf, size_t count, loff_t *pos)
    1 {
    2 ssize_t ret;

    4 if (!(file->f_mode & FMODE_READ))
    return -EBADF;
    6 if (!(file->f_mode & FMODE_CAN_READ))
    return -EINVAL;
    8 if (unlikely(!access_ok(buf, count)))
    return -EFAULT;

    11 ret = rw_verify_area(READ, file, pos, count);
    12 if (!ret) {
    13 if (count > MAX_RW_COUNT)
    count = MAX_RW_COUNT;
    15 ret = __vfs_read(file, buf, count, pos);
    16 if (ret > 0) {
    17 fsnotify_access(file);
    18 add_rchar(current, ret);
    }
    20 inc_syscr(current);
    }

    Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157241937995.32002.17899884017011512577.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit c701636aeec4c173208697d68da6e4271125564b ]

    Make find_best_scope() returns innermost DIE at given address if there
    is no best matched scope DIE. Since Gcc sometimes generates intuitively
    strange line info which is out of inlined function address range, we
    need this fixup.

    Without this, sometimes perf probe failed to probe on a line inside an
    inlined function:

    # perf probe -D ksys_open:3
    Failed to find scope of probe point.
    Error: Failed to add events.

    With this fix, 'perf probe' can probe it:

    # perf probe -D ksys_open:3
    p:probe/ksys_open _text+25707308
    p:probe/ksys_open_1 _text+25710596
    p:probe/ksys_open_2 _text+25711114
    p:probe/ksys_open_3 _text+25711343
    p:probe/ksys_open_4 _text+25714058
    p:probe/ksys_open_5 _text+2819653
    p:probe/ksys_open_6 _text+2819701

    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Namhyung Kim
    Cc: Ravi Bangoria
    Cc: Steven Rostedt (VMware)
    Cc: Tom Zanussi
    Link: http://lore.kernel.org/lkml/157291300887.19771.14936015360963292236.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit dee36a2abb67c175265d49b9a8c7dfa564463d9a ]

    Since debuginfo__find_probes() callback function can be called with the
    location which already passed, the callback function must filter out
    such overlapped locations.

    add_probe_trace_event() has already done it by commit 1a375ae7659a
    ("perf probe: Skip same probe address for a given line"), but
    add_available_vars() doesn't. Thus perf probe -v shows same address
    repeatedly as below:

    # perf probe -V vfs_read:18
    Available variables at vfs_read:18
    @
    char* buf
    loff_t* pos
    ssize_t ret
    struct file* file
    @
    char* buf
    loff_t* pos
    ssize_t ret
    struct file* file
    @
    char* buf
    loff_t* pos
    ssize_t ret
    struct file* file

    With this fix, perf probe -V shows it correctly:

    # perf probe -V vfs_read:18
    Available variables at vfs_read:18
    @
    char* buf
    loff_t* pos
    ssize_t ret
    struct file* file
    @
    char* buf
    loff_t* pos
    ssize_t ret
    struct file* file

    Fixes: cf6eb489e5c0 ("perf probe: Show accessible local variables")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157241938927.32002.4026859017790562751.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 38f2c4226e6bc3e8c41c318242821ba5dc825aba ]

    Avoid a memory leak when the configuration fails.

    Signed-off-by: Ian Rogers
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Andi Kleen
    Cc: Daniel Borkmann
    Cc: Jin Yao
    Cc: John Garry
    Cc: Kan Liang
    Cc: Mark Rutland
    Cc: Martin KaFai Lau
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Song Liu
    Cc: Stephane Eranian
    Cc: Yonghong Song
    Cc: bpf@vger.kernel.org
    Cc: clang-built-linux@googlegroups.com
    Cc: netdev@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20191030223448.12930-9-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Ian Rogers
     
  • [ Upstream commit 8e8714c3d157568b7a769917a5e05573bbaf5af0 ]

    If event parsing fails the event list is leaked, instead splice the list
    onto the out result and let the caller cleanup.

    An example input for parse_events found by libFuzzer that reproduces
    this memory leak is 'm{'.

    Signed-off-by: Ian Rogers
    Acked-by: Jiri Olsa
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Alexei Starovoitov
    Cc: Andi Kleen
    Cc: Daniel Borkmann
    Cc: Jin Yao
    Cc: John Garry
    Cc: Kan Liang
    Cc: Mark Rutland
    Cc: Martin KaFai Lau
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Song Liu
    Cc: Stephane Eranian
    Cc: Yonghong Song
    Cc: bpf@vger.kernel.org
    Cc: clang-built-linux@googlegroups.com
    Cc: netdev@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20191025180827.191916-5-irogers@google.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Ian Rogers
     
  • [ Upstream commit 71f699078b154fcb1c9162fd0208ada9ce532ffc ]

    Currently when cross compiling perf tool for ARM64 on my x86 machine I
    get this error:

    arch/arm64/util/sym-handling.c:9:10: fatal error: gelf.h: No such file or directory
    #include

    For the build, libelf is reported off:

    Auto-detecting system features:
    ...
    ... libelf: [ OFF ]

    Indeed, test-libelf is not built successfully:

    more ./build/feature/test-libelf.make.output
    test-libelf.c:2:10: fatal error: libelf.h: No such file or directory
    #include
    ^~~~~~~~~~
    compilation terminated.

    I have no such problems natively compiling on ARM64, and I did not
    previously have this issue for cross compiling. Fix by relocating the
    gelf.h include.

    Signed-off-by: John Garry
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Will Deacon
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lore.kernel.org/lkml/1573045254-39833-1-git-send-email-john.garry@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    John Garry
     
  • [ Upstream commit 5d16dbcc311d91267ddb45c6da4f187be320ecee ]

    Fix 'perf probe' to probe a function which has no entry pc or low pc but
    only has ranges attribute.

    probe_point_search_cb() uses dwarf_entrypc() to get the probe address,
    but that doesn't work for the function DIE which has only ranges
    attribute. Use die_entrypc() instead.

    Without this fix:

    # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
    Probe point 'clear_tasks_mm_cpumask' not found.
    Error: Failed to add events.

    With this:

    # perf probe -k ../build-x86_64/vmlinux -D clear_tasks_mm_cpumask:0
    p:probe/clear_tasks_mm_cpumask clear_tasks_mm_cpumask+0

    Committer testing:

    Before:

    [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0
    Probe point 'clear_tasks_mm_cpumask' not found.
    Error: Failed to add events.
    [root@quaco ~]#

    After:

    [root@quaco ~]# perf probe clear_tasks_mm_cpumask:0
    Added new event:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1

    [root@quaco ~]#

    Using it with 'perf trace':

    [root@quaco ~]# perf trace -e probe:clear_tasks_mm_cpumask

    Doesn't seem to be used in x86_64:

    $ find . -name "*.c" | xargs grep clear_tasks_mm_cpumask
    ./kernel/cpu.c: * clear_tasks_mm_cpumask - Safely clear tasks' mm_cpumask for a CPU
    ./kernel/cpu.c:void clear_tasks_mm_cpumask(int cpu)
    ./arch/xtensa/kernel/smp.c: clear_tasks_mm_cpumask(cpu);
    ./arch/csky/kernel/smp.c: clear_tasks_mm_cpumask(cpu);
    ./arch/sh/kernel/smp.c: clear_tasks_mm_cpumask(cpu);
    ./arch/arm/kernel/smp.c: clear_tasks_mm_cpumask(cpu);
    ./arch/powerpc/mm/nohash/mmu_context.c: clear_tasks_mm_cpumask(cpu);
    $ find . -name "*.h" | xargs grep clear_tasks_mm_cpumask
    ./include/linux/cpu.h:void clear_tasks_mm_cpumask(int cpu);
    $ find . -name "*.S" | xargs grep clear_tasks_mm_cpumask
    $

    Fixes: e1ecbbc3fa83 ("perf probe: Fix to handle optimized not-inlined functions")
    Reported-by: Arnaldo Carvalho de Melo
    Tested-by: Arnaldo Carvalho de Melo
    Signed-off-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157199319438.8075.4695576954550638618.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 22bd8f1b5a1dd168ba4eba27cb17643a11012f5d ]

    When a 'make DEBUG=1' build is done, the command parser is still built
    with -O6 and is hard to step through, fix it making it use -O0 in that
    case.

    Signed-off-by: James Clark
    Cc: Adrian Hunter
    Cc: Ian Rogers
    Cc: Jiri Olsa
    Cc: Josh Poimboeuf
    Cc: Namhyung Kim
    Cc: nd
    Link: http://lore.kernel.org/lkml/20191028113340.4282-1-james.clark@arm.com
    [ split from a larger patch ]
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    James Clark
     
  • [ Upstream commit 18e21eb671dc87a4f0546ba505a89ea93598a634 ]

    Fix 'perf probe --line' option to show inlined function callsite lines
    even if the function DIE has only ranges.

    Without this:

    # perf probe -L amd_put_event_constraints
    ...
    2 {
    3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
    __amd_put_nb_event_constraints(cpuc, event);
    5 }

    With this patch:

    # perf probe -L amd_put_event_constraints
    ...
    2 {
    3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
    4 __amd_put_nb_event_constraints(cpuc, event);
    5 }

    Committer testing:

    Before:

    [root@quaco ~]# perf probe -L amd_put_event_constraints

    0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
    struct perf_event *event)
    2 {
    3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
    __amd_put_nb_event_constraints(cpuc, event);
    5 }

    PMU_FORMAT_ATTR(event, "config:0-7,32-35");
    PMU_FORMAT_ATTR(umask, "config:8-15" );

    [root@quaco ~]#

    After:

    [root@quaco ~]# perf probe -L amd_put_event_constraints

    0 static void amd_put_event_constraints(struct cpu_hw_events *cpuc,
    struct perf_event *event)
    2 {
    3 if (amd_has_nb(cpuc) && amd_is_nb_event(&event->hw))
    4 __amd_put_nb_event_constraints(cpuc, event);
    5 }

    PMU_FORMAT_ATTR(event, "config:0-7,32-35");
    PMU_FORMAT_ATTR(umask, "config:8-15" );

    [root@quaco ~]# perf probe amd_put_event_constraints:4
    Added new event:
    probe:amd_put_event_constraints (on amd_put_event_constraints:4)

    You can now use it in all perf tools, such as:

    perf record -e probe:amd_put_event_constraints -aR sleep 1

    [root@quaco ~]#

    [root@quaco ~]# perf probe -l
    probe:amd_put_event_constraints (on amd_put_event_constraints:4@arch/x86/events/amd/core.c)
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
    [root@quaco ~]#

    Using it:

    [root@quaco ~]# perf trace -e probe:*
    ^C[root@quaco ~]#

    Ok, Intel system here... :-)

    Fixes: 4cc9cec636e7 ("perf probe: Introduce lines walker interface")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157199322107.8075.12659099000567865708.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit af04dd2f8ebaa8fbd46f698714acbf43da14da45 ]

    Fix to show ranges of variables (--range and --vars option) in functions
    which DIE has only ranges but no entry_pc attribute.

    Without this fix:

    # perf probe --range -V clear_tasks_mm_cpumask
    Available variables at clear_tasks_mm_cpumask
    @
    (No matched variables)

    With this fix:

    # perf probe --range -V clear_tasks_mm_cpumask
    Available variables at clear_tasks_mm_cpumask
    @
    [VAL] int cpu @

    Committer testing:

    Before:

    [root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
    Available variables at clear_tasks_mm_cpumask
    @
    (No matched variables)
    [root@quaco ~]#

    After:

    [root@quaco ~]# perf probe --range -V clear_tasks_mm_cpumask
    Available variables at clear_tasks_mm_cpumask
    @
    [VAL] int cpu @
    [root@quaco ~]#

    Using it:

    [root@quaco ~]# perf probe clear_tasks_mm_cpumask cpu
    Added new event:
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask with cpu)

    You can now use it in all perf tools, such as:

    perf record -e probe:clear_tasks_mm_cpumask -aR sleep 1

    [root@quaco ~]# perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c with cpu)
    [root@quaco ~]#
    [root@quaco ~]# perf trace -e probe:*cpumask
    ^C[root@quaco ~]#

    Fixes: 349e8d261131 ("perf probe: Add --range option to show a variable's location range")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157199323018.8075.8179744380479673672.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit eb6933b29d20bf2c3053883d409a53f462c1a3ac ]

    Fix perf probe to probe an inlne function which has no entry pc
    or low pc but only has ranges attribute.

    This seems very rare case, but I could find a few examples, as
    same as probe_point_search_cb(), use die_entrypc() to get the
    entry address in probe_point_inline_cb() too.

    Without this patch:

    # perf probe -D __amd_put_nb_event_constraints
    Failed to get entry address of __amd_put_nb_event_constraints.
    Probe point '__amd_put_nb_event_constraints' not found.
    Error: Failed to add events.

    With this patch:

    # perf probe -D __amd_put_nb_event_constraints
    p:probe/__amd_put_nb_event_constraints amd_put_event_constraints+43

    Committer testing:

    Before:

    [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
    Failed to get entry address of __amd_put_nb_event_constraints.
    Probe point '__amd_put_nb_event_constraints' not found.
    Error: Failed to add events.
    [root@quaco ~]#

    After:

    [root@quaco ~]# perf probe -D __amd_put_nb_event_constraints
    p:probe/__amd_put_nb_event_constraints _text+33789
    [root@quaco ~]#

    Fixes: 4ea42b181434 ("perf: Add perf probe subcommand, a kprobe-event setup helper")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157199320336.8075.16189530425277588587.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit acb6a7047ac2146b723fef69ee1ab6b7143546bf ]

    Since some inlined functions are in lexical blocks of given function, we
    have to recursively walk through the DIE tree. Without this fix,
    perf-probe -L can miss the inlined functions which is in a lexical block
    (like if (..) { func() } case.)

    However, even though, to walk the lines in a given function, we don't
    need to follow the children DIE of inlined functions because those do
    not have any lines in the specified function.

    We need to walk though whole trees only if we walk all lines in a given
    file, because an inlined function can include another inlined function
    in the same file.

    Fixes: b0e9cb2802d4 ("perf probe: Fix to search nested inlined functions in CU")
    Signed-off-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157190836514.1859.15996864849678136353.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 1785fbb73896dbd9d27a406f0d73047df42db710 ]

    There are memory leaks and file descriptor resource leaks in
    process_mapfile() and main().

    Fix this by adding free(), fclose() and free_arch_std_events() on the
    error paths.

    Fixes: 80eeb67fe577 ("perf jevents: Program to convert JSON file")
    Fixes: 3f056b66647b ("perf jevents: Make build fail on JSON parse error")
    Fixes: e9d32c1bf0cd ("perf vendor events: Add support for arch standard events")
    Signed-off-by: Yunfeng Ye
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Feilong Lin
    Cc: Hu Shiyuan
    Cc: Jiri Olsa
    Cc: John Garry
    Cc: Kan Liang
    Cc: Luke Mujica
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Zenghui Yu
    Link: http://lore.kernel.org/lkml/d7907042-ec9c-2bef-25b4-810e14602f89@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Yunfeng Ye
     
  • [ Upstream commit 3895534dd78f0fd4d3f9e05ee52b9cdd444a743e ]

    Since debuginfo__find_probe_point() uses dwarf_entrypc() for finding the
    entry address of the function on which a probe is, it will fail when the
    function DIE has only ranges attribute.

    To fix this issue, use die_entrypc() instead of dwarf_entrypc().

    Without this fix, perf probe -l shows incorrect offset:

    # perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579263632@work/linux/linux/kernel/cpu.c)
    probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask+18446744071579263752@work/linux/linux/kernel/cpu.c)

    With this:

    # perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@work/linux/linux/kernel/cpu.c)
    probe:clear_tasks_mm_cpumask_1 (on clear_tasks_mm_cpumask:21@work/linux/linux/kernel/cpu.c)

    Committer testing:

    Before:

    [root@quaco ~]# perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask+18446744071579765152@kernel/cpu.c)
    [root@quaco ~]#

    After:

    [root@quaco ~]# perf probe -l
    probe:clear_tasks_mm_cpumask (on clear_tasks_mm_cpumask@kernel/cpu.c)
    [root@quaco ~]#

    Fixes: 1d46ea2a6a40 ("perf probe: Fix listing incorrect line number with inline function")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157199321227.8075.14655572419136993015.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit 9d604aad4bb022e848dec80d6fe5f73fe87061a2 ]

    Macro TO_CS_QUEUE_NR definition has a typo, which uses 'trace_id_chan'
    as its parameter, this doesn't match with its definition body which uses
    'trace_chan_id'. So renames the parameter to 'trace_chan_id'.

    It's luck to have a local variable 'trace_chan_id' in the function
    cs_etm__setup_queue(), even we wrongly define the macro TO_CS_QUEUE_NR,
    the local variable 'trace_chan_id' is used rather than the macro's
    parameter 'trace_id_chan'; so the compiler doesn't complain for this
    before.

    After renaming the parameter, it leads to a compiling error due
    cs_etm__setup_queue() has no variable 'trace_id_chan'. This patch uses
    the variable 'trace_chan_id' for the macro so that fixes the compiling
    error.

    Signed-off-by: Leo Yan
    Reviewed-by: Mathieu Poirier
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Suzuki Poulouse
    Cc: coresight ml
    Cc: linux-arm-kernel@lists.infradead.org
    Link: http://lore.kernel.org/lkml/20191021074808.25795-1-leo.yan@linaro.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Leo Yan
     
  • [ Upstream commit b77afa1f810f37bd8a36cb1318178dfe2d7af6b6 ]

    Fix die_is_func_instance() to find range-only function instance.

    In some case, a function instance can be made without any low PC or
    entry PC, but only with address ranges by optimization. (e.g. cold text
    partially in "text.unlikely" section) To find such function instance, we
    have to check the range attribute too.

    Fixes: e1ecbbc3fa83 ("perf probe: Fix to handle optimized not-inlined functions")
    Signed-off-by: Masami Hiramatsu
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Link: http://lore.kernel.org/lkml/157190835669.1859.8368628035930950596.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu
     
  • [ Upstream commit d1b4574a4b86565325ef2e545eda8dfc9aa07c60 ]

    bpf_map__reuse_fd() was calling close() in the error path before returning
    an error value based on errno. However, close can change errno, so that can
    lead to potentially misleading error messages. Instead, explicitly store
    errno in the err variable before each goto.

    Signed-off-by: Toke Høiland-Jørgensen
    Signed-off-by: Alexei Starovoitov
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/157269297769.394725.12634985106772698611.stgit@toke.dk
    Signed-off-by: Sasha Levin

    Toke Høiland-Jørgensen