05 Aug, 2020

4 commits

  • [ Upstream commit b4da96ffd30bd4a305045ba5c9b0de5d4aa20dc7 ]

    On powerpcle, int64_t maps to long long. Clang 9 threw:
    warning: absolute value function 'labs' given an argument of type \
    'long long' but has parameter of type 'long' which may cause \
    truncation of value [-Wabsolute-value]
    if (labs(tstop - texpect) > cfg_variance_us)

    Tested: make -C tools/testing/selftests TARGETS="net" run_tests

    Fixes: af5136f95045 ("selftests/net: SO_TXTIME with ETF and FQ")
    Signed-off-by: Tanner Love
    Acked-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tanner Love
     
  • [ Upstream commit 64f9ede2274980076423583683d44480909b7a40 ]

    Clang 9 threw:
    warning: format specifies type 'unsigned short' but the argument has \
    type 'int' [-Wformat]
    typeflags, PORT_BASE, PORT_BASE + port_off);

    Tested: make -C tools/testing/selftests TARGETS="net" run_tests

    Fixes: 77f65ebdca50 ("packet: packet fanout rollover during socket overload")
    Signed-off-by: Tanner Love
    Acked-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tanner Love
     
  • [ Upstream commit 955cbe91bcf782c09afe369c95a20f0a4b6dcc3c ]

    The signedness of char is implementation-dependent. Some systems
    (including PowerPC and ARM) use unsigned char. Clang 9 threw:
    warning: result of comparison of constant -1 with expression of type \
    'char' is always true [-Wtautological-constant-out-of-range-compare]
    &arg_index)) != -1) {

    Tested: make -C tools/testing/selftests TARGETS="net" run_tests

    Fixes: 16e781224198 ("selftests/net: Add a test to validate behavior of rx timestamps")
    Signed-off-by: Tanner Love
    Acked-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Tanner Love
     
  • commit 39efdd94e314336f4acbac4c07e0f37bdc3bef71 upstream.

    In binutils 2.35, 'nm -D' changed to show symbol versions along with
    symbol names, with the usual @@ separator. When generating
    libtraceevent-dynamic-list we need just the names, so strip off the
    version suffix if present.

    Signed-off-by: Ben Hutchings
    Tested-by: Salvatore Bonaccorso
    Reviewed-by: Steven Rostedt
    Cc: linux-trace-devel@vger.kernel.org
    Cc: stable@vger.kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Ben Hutchings
     

22 Jul, 2020

2 commits

  • commit 0e0bf1ea1147fcf74eab19c2d3c853cc3740a72f upstream.

    As the code comments in perf_stat_process_counter() say, we calculate
    counter's data every interval, and the display code shows ps->res_stats
    avg value. We need to zero the stats for interval mode.

    But the current code only zeros the res_stats[0], it doesn't zero the
    res_stats[1] and res_stats[2], which are for ena and run of counter.

    This patch zeros the whole res_stats[] for interval mode.

    Fixes: 51fd2df1e882 ("perf stat: Fix interval output values")
    Signed-off-by: Jin Yao
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Jin Yao
    Cc: Jiri Olsa
    Cc: Kan Liang
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/20200409070755.17261-1-yao.jin@linux.intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Jin Yao
     
  • [ Upstream commit 34fe5a1cf95c3f114068fc16d919c9cf4b00e428 ]

    Brian reported a crash in IPv6 code when using rpfilter with a setup
    running FRR and external nexthop objects. The root cause of the crash
    is fib6_select_path setting fib6_nh in the result to NULL because of
    an improper check for nexthop objects.

    More specifically, rpfilter invokes ip6_route_lookup with flowi6_oif
    set causing fib6_select_path to be called with have_oif_match set.
    fib6_select_path has early check on have_oif_match and jumps to the
    out label which presumes a builtin fib6_nh. This path is invalid for
    nexthop objects; for external nexthops fib6_select_path needs to just
    return if the fib6_nh has already been set in the result otherwise it
    returns after the call to nexthop_path_fib6_result. Update the check
    on have_oif_match to not bail on external nexthops.

    Update selftests for this problem.

    Fixes: f88d8ea67fbd ("ipv6: Plumb support for nexthop object in a fib6_info")
    Reported-by: Brian Rak
    Signed-off-by: David Ahern
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    David Ahern
     

16 Jul, 2020

7 commits

  • commit 3a3cf7c570a486b07d9a6e68a77548aea6a8421f upstream.

    Using Python version 3.8.2 and PySide2 version 5.14.0, ctrl-F ('Find')
    would not expand the tree to the result. Fix by using setExpanded().

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Context-Sensitive Call Graph or Reports -> Call Tree
    Press: Ctrl-F
    Enter: main
    Press: Enter

    Before: line showing 'main' does not display

    After: tree is expanded to line showing 'main'

    Fixes: ebd70c7dc2f5f ("perf scripts python: exported-sql-viewer.py: Add ability to find symbols in the call-graph")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-4-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • commit 031c8d5edb1ddeb6d398f7942ce2a01a1a51ada9 upstream.

    Using ctrl-F ('Find') would not find 'unknown' because it matches id
    zero. Fix by excluding id zero from selection.

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Call Tree
    Press: Ctrl-F
    Enter: unknown
    Press: Enter

    Before: displays 'unknown' not found
    After: tree is expanded to line showing 'unknown'

    Fixes: ae8b887c00d3f ("perf scripts python: exported-sql-viewer.py: Add call tree")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-6-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • commit 7ff520b0a71dd2db695b52ad117d81b7eaf6ff9d upstream.

    Using ctrl-F ('Find') would not find 'unknown' because it matches id zero.
    Fix by excluding id zero from selection.

    Example:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.034 MB perf.data ]
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-sqlite.py perf.data.db branches calls
    2020-06-26 15:32:14.928997 Creating database ...
    2020-06-26 15:32:14.933971 Writing records...
    2020-06-26 15:32:15.535251 Adding indexes
    2020-06-26 15:32:15.542993 Dropping unused tables
    2020-06-26 15:32:15.549716 Done
    $ python3 ~/libexec/perf-core/scripts/python/exported-sql-viewer.py perf.data.db

    Select: Reports -> Context-Sensitive Call Graph
    Press: Ctrl-F
    Enter: unknown
    Press: Enter

    Before: gets stuck
    After: tree is expanded to line showing 'unknown'

    Fixes: 254c0d820b86d ("perf scripts python: exported-sql-viewer.py: Factor out CallGraphModelBase")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-5-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • commit 640432e6bed08e9d5d2ba26856ba3f55008b07e3 upstream.

    Python 3.8 is requiring that arguments being packed as integers are also
    integers. Add int() accordingly.

    Before:

    $ perf record -e intel_pt//u uname
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
    2020-06-25 16:09:10.547256 Creating database...
    2020-06-25 16:09:10.733185 Writing to intermediate files...
    Traceback (most recent call last):
    File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1106, in synth_data
    cbr(id, raw_buf)
    File "/home/ahunter/libexec/perf-core/scripts/python/export-to-postgresql.py", line 1058, in cbr
    value = struct.pack("!hiqiiiiii", 4, 8, id, 4, cbr, 4, MHz, 4, percent)
    struct.error: required argument is not an integer
    Fatal Python error: problem in Python trace event handler
    Python runtime state: initialized

    Current thread 0x00007f35d3695780 (most recent call first):

    Aborted (core dumped)

    After:

    $ dropdb perf_data_db
    $ rm -rf perf_data_db-perf-data
    $ perf script --itrace=bep -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py perf_data_db branches calls
    2020-06-25 16:09:40.990267 Creating database...
    2020-06-25 16:09:41.207009 Writing to intermediate files...
    2020-06-25 16:09:41.270915 Copying to database...
    2020-06-25 16:09:41.382030 Removing intermediate files...
    2020-06-25 16:09:41.384630 Adding primary keys
    2020-06-25 16:09:41.541894 Adding foreign keys
    2020-06-25 16:09:41.677044 Dropping unused tables
    2020-06-25 16:09:41.703761 Done

    Fixes: aba44287a224 ("perf scripts python: export-to-postgresql.py: Export Intel PT power and ptwrite events")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200629091955.17090-2-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • [ Upstream commit 4c95ad261cfac120dd66238fcae222766754c219 ]

    The condition to add XMM registers was missing, the regs array needed to
    be in the outer scope, and the size of the regs array was too small.

    Fixes: 143d34a6b387b ("perf intel-pt: Add XMM registers to synthesized PEBS sample")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Luwei Kang
    Link: http://lore.kernel.org/lkml/20200630133935.11150-4-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Adrian Hunter
     
  • [ Upstream commit 75bcb8776dc987538f267ba4ba05ca43fc2b1676 ]

    When recording PEBS-via-PT, the kernel will not accept the intel_pt
    event with register sampling e.g.

    # perf record --kcore -c 10000 -e '{intel_pt/branch=0/,branch-loads/aux-output/ppp}' -I -- ls -l
    Error:
    intel_pt/branch=0/: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'

    Fix by suppressing register sampling on the intel_pt evsel.

    Committer notes:

    Adrian informed that this is only available from Tremont onwards, so on
    older processors the error continues the same as before.

    Fixes: 9e64cefe4335b ("perf intel-pt: Process options for PEBS event synthesis")
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: Luwei Kang
    Link: http://lore.kernel.org/lkml/20200630133935.11150-2-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Adrian Hunter
     
  • [ Upstream commit d61cbb859b45fdb6b4997f2d51834fae41af0e94 ]

    The segmentation fault can be reproduced as following steps:

    1) Executing perf report in tui.

    2) Typing '/xxxxx' to filter the symbol to get nothing matched.

    3) Pressing enter with no entry selected.

    Then it will report a segmentation fault.

    It is caused by the lack of check of browser->he_selection when
    accessing it's member res_samples in perf_evsel__hists_browse().

    These processes are meaningful for specified samples, so we can skip
    these when nothing is selected.

    Fixes: 4968ac8fb7c3 ("perf report: Implement browsing of individual samples")
    Signed-off-by: Wei Li
    Acked-by: Jiri Olsa
    Acked-by: Namhyung Kim
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Alexander Shishkin
    Cc: Andi Kleen
    Cc: Hanjun Guo
    Cc: Jin Yao
    Cc: Mark Rutland
    Link: http://lore.kernel.org/lkml/20200612094322.39565-1-liwei391@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Wei Li
     

09 Jul, 2020

3 commits

  • commit 377ff83083c953dd58c5a030b3c9b5b85d8cc727 upstream.

    It's better to use /bin/sh instead of /bin/bash in order to run the tests
    in the BusyBox shell.

    Fixes: 6ea3dfe1e073 ("selftests: add TPM 2.0 tests")
    Cc: stable@vger.kernel.org
    Cc: linux-integrity@vger.kernel.org
    Cc: linux-kselftest@vger.kernel.org
    Signed-off-by: Jarkko Sakkinen
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Jarkko Sakkinen
     
  • [ Upstream commit 74621d929d944529a5e2878a84f48bfa6fb69a66 ]

    Commit c61f13eaa1ee1 ("gcc-plugins: Add structleak for more stack
    initialization") added "__attribute__((user))" to the user when
    stackleak detector is enabled. This now appears in the field format of
    system call trace events for system calls that have user buffers. The
    "__attribute__((user))" breaks the parsing in libtraceevent. That needs
    to be handled.

    Signed-off-by: Steven Rostedt (VMware)
    Cc: Andrew Morton
    Cc: Jaewon Kim
    Cc: Jiri Olsa
    Cc: Kees Kook
    Cc: Namhyung Kim
    Cc: Vlastimil Babka
    Cc: linux-mm@kvack.org
    Cc: linux-trace-devel@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200324200956.663647256@goodmis.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Steven Rostedt (VMware)
     
  • [ Upstream commit 27d4d336f2872193e90ee5450559e1699fae0f6d ]

    There's several locations that open code realloc and strcat() to append
    text to strings. Add an append() function that takes a delimiter and a
    string to append to another string.

    Signed-off-by: Steven Rostedt (VMware)
    Cc: Andrew Morton
    Cc: Jaewon Lim
    Cc: Jiri Olsa
    Cc: Kees Kook
    Cc: linux-mm@kvack.org
    Cc: linux-trace-devel@vger.kernel.org
    Cc: Namhyung Kim
    Cc: Vlastimil Babka
    Link: http://lore.kernel.org/lkml/20200324200956.515118403@goodmis.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Steven Rostedt (VMware)
     

01 Jul, 2020

1 commit

  • [ Upstream commit ca8826095e4d4afc0ccaead27bba6e4b623a12ae ]

    The ETF qdisc can queue skbs that it could not pace on the errqueue.

    Address a few issues in the selftest

    - recv buffer size was too small, and incorrectly calculated
    - compared errno to ee_code instead of ee_errno
    - missed invalid request error type

    v2:
    - fix a few checkpatch --strict indentation warnings

    Fixes: ea6a547669b3 ("selftests/net: make so_txtime more robust to timer variance")
    Signed-off-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Willem de Bruijn
     

24 Jun, 2020

6 commits

  • [ Upstream commit c0c652fc705de75f4ba52e93053acc1ed3933e74 ]

    If config->aggr_map is NULL and config->aggr_get_id is not NULL,
    the function print_aggr() will still calling arrg_update_shadow(),
    which can result in accessing the invalid pointer.

    Fixes: 088519f318be ("perf stat: Move the display functions to stat-display.c")
    Signed-off-by: Hongbo Yao
    Cc: Alexander Shishkin
    Cc: Jiri Olsa
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Wei Li
    Link: https://lore.kernel.org/lkml/20200608163625.GC3073@kernel.org
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Hongbo Yao
     
  • [ Upstream commit 11b6e5482e178055ec1f2444b55f2518713809d1 ]

    The 'evname' variable can be NULL, as it is checked a few lines back,
    check it before using.

    Fixes: 9e207ddfa207 ("perf report: Show call graph from reference events")
    Cc: Adrian Hunter
    Cc: Alexander Shishkin
    Cc: Ingo Molnar
    Cc: Jiri Olsa
    Cc: Kan Liang
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Link: http://lore.kernel.org/lkml/
    Signed-off-by: Gaurav Singh
    Signed-off-by: Sasha Levin

    Gaurav Singh
     
  • [ Upstream commit 32022fd97ed34f6812802bf1288db27c313576f4 ]

    Handle a GCC quirk of emitting extra volatile modifier in DWARF (and
    subsequently preserved in BTF by pahole) for function pointers marked as
    __attribute__((noreturn)). This was the way to mark such functions before GCC
    2.5 added noreturn attribute. Drop such func_proto modifiers, similarly to how
    it's done for array (also to handle GCC quirk/bug).

    Such volatile attribute is emitted by GCC only, so existing selftests can't
    express such test. Simple repro is like this (compiled with GCC + BTF
    generated by pahole):

    struct my_struct {
    void __attribute__((noreturn)) (*fn)(int);
    };
    struct my_struct a;

    Without this fix, output will be:

    struct my_struct {
    voidvolatile (*fn)(int);
    };

    With the fix:

    struct my_struct {
    void (*fn)(int);
    };

    Fixes: 351131b51c7a ("libbpf: add btf_dump API for BTF-to-C conversion")
    Reported-by: Jean-Philippe Brucker
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Daniel Borkmann
    Tested-by: Jean-Philippe Brucker
    Link: https://lore.kernel.org/bpf/20200610052335.2862559-1-andriin@fb.com
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     
  • [ Upstream commit 8027bc0307ce59759b90679fa5d8b22949586d20 ]

    If user passed an interface option longer than 15 characters, then
    device.ifr_name and hwtstamp.ifr_name became non-null-terminated
    strings. The compiler warned about this:

    timestamping.c:353:2: warning: ‘strncpy’ specified bound 16 equals \
    destination size [-Wstringop-truncation]
    353 | strncpy(device.ifr_name, interface, sizeof(device.ifr_name));

    Fixes: cb9eff097831 ("net: new user space API for time stamping of incoming and outgoing packets")
    Signed-off-by: Tanner Love
    Acked-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    tannerlove
     
  • [ Upstream commit 2130c0ba69d69bb21f5c52787f2587db00d13d8a ]

    When remote files are counted in get_files_count, without using SSH,
    the code returns 0 because there is a colon prepended to $LOC. $VPATH
    should have been used instead of $LOC.

    Fixes: 06bd0407d06c ("NTB: ntb_test: Update ntb_tool Scratchpad tests")
    Signed-off-by: Logan Gunthorpe
    Acked-by: Allen Hubbe
    Tested-by: Alexander Fomichev
    Signed-off-by: Jon Mason
    Signed-off-by: Sasha Levin

    Logan Gunthorpe
     
  • [ Upstream commit 6e373263ce07eeaa6410843179535fbdf561fc31 ]

    alloc_random_pkey() was allocating the same pkey every time. Not all
    pkeys were geting tested. This fixes it.

    Signed-off-by: Ram Pai
    Signed-off-by: Sandipan Das
    Signed-off-by: Andrew Morton
    Acked-by: Dave Hansen
    Cc: Dave Hansen
    Cc: Florian Weimer
    Cc: "Desnes A. Nunes do Rosario"
    Cc: Ingo Molnar
    Cc: Thiago Jung Bauermann
    Cc: "Aneesh Kumar K.V"
    Cc: Michael Ellerman
    Cc: Michal Hocko
    Cc: Michal Suchanek
    Cc: Shuah Khan
    Link: http://lkml.kernel.org/r/0162f55816d4e783a0d6e49e554d0ab9a3c9a23b.1585646528.git.sandipan@linux.ibm.com
    Signed-off-by: Linus Torvalds
    Signed-off-by: Sasha Levin

    Ram Pai
     

22 Jun, 2020

13 commits

  • commit 0affd0e5262b6d40f5f63466d88933e99698e240 upstream.

    Adjust 'map->pgoff' also when moving a map's start address.

    Example with v5.4.34 based kernel:

    Before:

    $ sudo tools/perf/perf record -a --kcore -e intel_pt//k sleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 1.958 MB perf.data ]
    $ sudo tools/perf/perf script --itrace=e >/dev/null
    Warning:
    961 instruction trace errors

    After:

    $ sudo tools/perf/perf script --itrace=e >/dev/null
    $

    Committer testing:

    # uname -a
    Linux seventh 5.6.10-100.fc30.x86_64 #1 SMP Mon May 4 15:36:44 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
    #

    Before:

    # perf record -a --kcore -e intel_pt//k sleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.923 MB perf.data ]
    # perf script --itrace=e >/dev/null
    Warning:
    295 instruction trace errors
    #

    After:

    # perf record -a --kcore -e intel_pt//k sleep 1
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.919 MB perf.data ]
    # perf script --itrace=e >/dev/null
    #

    Fixes: fb5a88d4131a ("perf tools: Preserve eBPF maps when loading kcore")
    Signed-off-by: Adrian Hunter
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200602112505.1406-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • commit 85afd35575a3c1a3a905722dde5ee70b49282e70 upstream.

    Reportedly, from 19.10 Ubuntu has begun mixing up the location of some
    debug symbol files, putting files expected to be in
    /usr/lib/debug/usr/lib into /usr/lib/debug/lib instead. Fix by adding
    another dso_binary_type.

    Example on Ubuntu 20.04

    Before:

    $ perf record -e intel_pt//u uname
    Linux
    [ perf record: Woken up 1 times to write data ]
    [ perf record: Captured and wrote 0.030 MB perf.data ]
    $ perf script --call-trace | head -5
    uname 14003 [005] 15321.764958566: cbr: 42 freq: 4219 MHz (156%)
    uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4100
    uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4df0
    uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc4e18
    uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) 7f1e71cc5128

    After:

    $ perf script --call-trace | head -5
    uname 14003 [005] 15321.764958566: cbr: 42 freq: 4219 MHz (156%)
    uname 14003 [005] 15321.764958566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _start
    uname 14003 [005] 15321.764961566: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start
    uname 14003 [005] 15321.764961900: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start
    uname 14003 [005] 15321.764963233: (/usr/lib/x86_64-linux-gnu/ld-2.31.so ) _dl_start

    Reported-by: Travis Downs
    Signed-off-by: Adrian Hunter
    Cc: Jiri Olsa
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/20200526155207.9172-1-adrian.hunter@intel.com
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Adrian Hunter
     
  • commit 2ae5d0d7d8868df7c05c2013c0b9cddd4d40610e upstream.

    Since commit 03db8b583d1c ("perf tools: Fix
    maps__find_symbol_by_name()") introduced map address range check in
    maps__find_symbol_by_name(), we can not get "_etext" from kernel map
    because _etext is placed on the edge of the kernel .text section (=
    kernel map in perf.)

    To fix this issue, this checks the address correctness by map address
    range information (map->start and map->end) instead of using _etext
    address.

    This can cause an error if the target inlined function is embedded in
    both __init function and normal function.

    For exaample, request_resource() is a normal function but also embedded
    in __init reserve_setup(). In this case, the probe point in
    reserve_setup() must be skipped.

    However, without this fix, it failes to setup all probe points:

    # ./perf probe -v request_resource
    probe-definition(0): request_resource
    symbol:request_resource file:(null) line:0 offset:0 return:0 lazy:(null)
    0 arguments
    Looking at the vmlinux_path (8 entries long)
    Using /usr/lib/debug/lib/modules/5.5.17-200.fc31.x86_64/vmlinux for symbols
    Open Debuginfo file: /usr/lib/debug/lib/modules/5.5.17-200.fc31.x86_64/vmlinux
    Try to find probe point from debuginfo.
    Matched function: request_resource [15e29ad]
    found inline addr: 0xffffffff82fbf892
    Probe point found: reserve_setup+204
    found inline addr: 0xffffffff810e9790
    Probe point found: request_resource+0
    Found 2 probe_trace_events.
    Opening /sys/kernel/debug/tracing//kprobe_events write=1
    Opening /sys/kernel/debug/tracing//README write=0
    Writing event: p:probe/request_resource _text+33290386
    Failed to write event: Invalid argument
    Error: Failed to add events. Reason: Invalid argument (Code: -22)
    #

    With this fix,

    # ./perf probe request_resource
    reserve_setup is out of .text, skip it.
    Added new events:
    (null):(null) (on request_resource)
    probe:request_resource (on request_resource)

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

    perf record -e probe:request_resource -aR sleep 1

    #

    Fixes: 03db8b583d1c ("perf tools: Fix maps__find_symbol_by_name()")
    Reported-by: Arnaldo Carvalho de Melo
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/158763967332.30755.4922496724365529088.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • commit 80526491c2ca6abc028c0f0dbb0707a1f35fb18a upstream.

    Fix to check kprobe blacklist address correctly with relocated address
    by adjusting debuginfo address.

    Since the address in the debuginfo is same as objdump, it is different
    from relocated kernel address with KASLR. Thus, 'perf probe' always
    misses to catch the blacklisted addresses.

    Without this patch, 'perf probe' can not detect the blacklist addresses
    on a KASLR enabled kernel.

    # perf probe kprobe_dispatcher
    Failed to write event: Invalid argument
    Error: Failed to add events.
    #

    With this patch, it correctly shows the error message.

    # perf probe kprobe_dispatcher
    kprobe_dispatcher is blacklisted function, skip it.
    Probe point 'kprobe_dispatcher' not found.
    Error: Failed to add events.
    #

    Fixes: 9aaf5a5f479b ("perf probe: Check kprobes blacklist when adding new events")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/158763966411.30755.5882376357738273695.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • commit f41ebe9defacddeae96a872a33f0f22ced0bfcef upstream.

    When a probe point is expanded to several places (like inlined) and if
    some of them are skipped because of blacklisted or __init function,
    those trace_events has no event name. It must be skipped while showing
    results.

    Without this fix, you can see "(null):(null)" on the list,

    # ./perf probe request_resource
    reserve_setup is out of .text, skip it.
    Added new events:
    (null):(null) (on request_resource)
    probe:request_resource (on request_resource)

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

    perf record -e probe:request_resource -aR sleep 1

    #

    With this fix, it is ignored:

    # ./perf probe request_resource
    reserve_setup is out of .text, skip it.
    Added new events:
    probe:request_resource (on request_resource)

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

    perf record -e probe:request_resource -aR sleep 1

    #

    Fixes: 5a51fcd1f30c ("perf probe: Skip kernel symbols which is out of .text")
    Signed-off-by: Masami Hiramatsu
    Tested-by: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: stable@vger.kernel.org
    Link: http://lore.kernel.org/lkml/158763968263.30755.12800484151476026340.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • [ Upstream commit b8215dce7dfd817ca38807f55165bf502146cd68 ]

    test_flow_dissector leaves a TAP device after it's finished, potentially
    interfering with other tests that will run after it. Fix it by closing the
    TAP descriptor on cleanup.

    Fixes: 0905beec9f52 ("selftests/bpf: run flow dissector tests in skb-less mode")
    Signed-off-by: Jakub Sitnicki
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200531082846.2117903-11-jakub@cloudflare.com
    Signed-off-by: Sasha Levin

    Jakub Sitnicki
     
  • [ Upstream commit 601b05ca6edb0422bf6ce313fbfd55ec7bbbc0fd ]

    In case the cpu_bufs are sparsely allocated they are not all
    free'ed. These changes will fix this.

    Fixes: fb84b8224655 ("libbpf: add perf buffer API")
    Signed-off-by: Eelco Chaudron
    Signed-off-by: Daniel Borkmann
    Acked-by: Andrii Nakryiko
    Link: https://lore.kernel.org/bpf/159056888305.330763.9684536967379110349.stgit@ebuild
    Signed-off-by: Alexei Starovoitov
    Signed-off-by: Sasha Levin

    Eelco Chaudron
     
  • [ Upstream commit 3c8e8cf4b18b3a7034fab4c4504fc4b54e4b6195 ]

    test_seg6_loop.o uses the helper bpf_lwt_seg6_adjust_srh();
    it will not be present if CONFIG_IPV6_SEG6_BPF is not specified.

    Fixes: b061017f8b4d ("selftests/bpf: add realistic loop tests")
    Signed-off-by: Alan Maguire
    Signed-off-by: Daniel Borkmann
    Link: https://lore.kernel.org/bpf/1590147389-26482-2-git-send-email-alan.maguire@oracle.com
    Signed-off-by: Sasha Levin

    Alan Maguire
     
  • [ Upstream commit 21f3cfeab304fc07b90d93d98d4d2f62110fe6b2 ]

    Wrapping numbers in strings is used by some to work around bit-width issues in
    some enviroments. The problem isn't innate to json and the workaround seems to
    cause more integration problems than help. Let's drop the string wrapping.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jens Axboe
    Signed-off-by: Sasha Levin

    Tejun Heo
     
  • [ Upstream commit 9f56bb531a809ecaa7f0ddca61d2cf3adc1cb81a ]

    getline() allocates string, which has to be freed.

    Fixes: 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Cc: Song Liu
    Link: https://lore.kernel.org/bpf/20200429012111.277390-7-andriin@fb.com
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     
  • [ Upstream commit c6fddb28bad26e5472cb7acf7b04cd5126f1a4ab ]

    The xxx_mountpoint() interface provided by fs.c finds mount points for
    common pseudo filesystems. The first time xxx_mountpoint() is invoked,
    it scans the mount table (/proc/mounts) looking for a match. If found,
    it is cached. The price to scan /proc/mounts is paid once if the mount
    is found.

    When the mount point is not found, subsequent calls to xxx_mountpoint()
    scan /proc/mounts over and over again. There is no caching.

    This causes a scaling issue in perf record with hugeltbfs__mountpoint().
    The function is called for each process found in
    synthesize__mmap_events(). If the machine has thousands of processes
    and if the /proc/mounts has many entries this could cause major overhead
    in perf record. We have observed multi-second slowdowns on some
    configurations.

    As an example on a laptop:

    Before:

    $ sudo umount /dev/hugepages
    $ strace -e trace=openat -o /tmp/tt perf record -a ls
    $ fgrep mounts /tmp/tt
    285

    After:

    $ sudo umount /dev/hugepages
    $ strace -e trace=openat -o /tmp/tt perf record -a ls
    $ fgrep mounts /tmp/tt
    1

    One could argue that the non-caching in case the moint point is not
    found is intentional. That way subsequent calls may discover a moint
    point if the sysadmin mounts the filesystem. But the same argument could
    be made against caching the mount point. It could be unmounted causing
    errors. It all depends on the intent of the interface. This patch
    assumes it is expected to scan /proc/mounts once. The patch documents
    the caching behavior in the fs.h header file.

    An alternative would be to just fix perf record. But it would solve the
    problem with hugetlbs__mountpoint() but there could be similar issues
    (possibly down the line) with other xxx_mountpoint() calls in perf or
    other tools.

    Signed-off-by: Stephane Eranian
    Reviewed-by: Ian Rogers
    Acked-by: Jiri Olsa
    Cc: Alexander Shishkin
    Cc: Andrey Zhizhikin
    Cc: Kan Liang
    Cc: Kefeng Wang
    Cc: Mark Rutland
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Petr Mladek
    Cc: Thomas Gleixner
    Link: http://lore.kernel.org/lkml/20200402154357.107873-3-irogers@google.com
    Signed-off-by: Ian Rogers
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Stephane Eranian
     
  • [ Upstream commit 229bf8bf4d910510bc1a2fd0b89bd467cd71050d ]

    Fix memory leak in hashmap_clear() not freeing hashmap_entry structs for each
    of the remaining entries. Also NULL-out bucket list to prevent possible
    double-free between hashmap__clear() and hashmap__free().

    Running test_progs-asan flavor clearly showed this problem.

    Reported-by: Alston Tang
    Signed-off-by: Andrii Nakryiko
    Signed-off-by: Alexei Starovoitov
    Link: https://lore.kernel.org/bpf/20200429012111.277390-5-andriin@fb.com
    Signed-off-by: Sasha Levin

    Andrii Nakryiko
     
  • [ Upstream commit 7170cf47d16f1ba29eca07fd818870b7af0a93a5 ]

    The .alternatives section can contain entries with no original
    instructions. Objtool will currently crash when handling such an entry.

    Just skip that entry, but still give a warning to discourage useless
    entries.

    Signed-off-by: Julien Thierry
    Acked-by: Peter Zijlstra (Intel)
    Reviewed-by: Miroslav Benes
    Signed-off-by: Josh Poimboeuf
    Signed-off-by: Ingo Molnar
    Signed-off-by: Sasha Levin

    Julien Thierry
     

17 Jun, 2020

4 commits

  • commit 619ee76f5c9f6a1d601d1a056a454d62bf676ae4 upstream.

    Check whether error_log file exists in tracing/error_log testcase
    and return UNSUPPORTED if no error_log file.

    This can happen if we run the ftracetest on the older stable
    kernel.

    Fixes: 4eab1cc461a6 ("selftests/ftrace: Add tracing/error_log testcase")
    Cc: stable@vger.kernel.org
    Signed-off-by: Masami Hiramatsu
    Signed-off-by: Shuah Khan
    Signed-off-by: Greg Kroah-Hartman

    Masami Hiramatsu
     
  • [ Upstream commit 865a6cbb2288f8af7f9dc3b153c61b7014fdcf1e ]

    getopt_long requires the last element to be filled with zeros.
    Otherwise, passing an unrecognized option can cause a segfault.

    Fixes: 16e781224198 ("selftests/net: Add a test to validate behavior of rx timestamps")
    Signed-off-by: Tanner Love
    Acked-by: Willem de Bruijn
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    tannerlove
     
  • [ Upstream commit 0531b0357ba37464e5c0033e1b7c69bbf5ecd8fb ]

    Flower tests used to create ingress filter with specified parent qdisc
    "parent ffff:" but dump them on "ingress". With recent commit that fixed
    tcm_parent handling in dump those are not considered same parent anymore,
    which causes iproute2 tc to emit additional "parent ffff:" in first line of
    filter dump output. The change in output causes filter match in tests to
    fail.

    Prevent parent qdisc output when dumping filters in flower tests by always
    correctly specifying "ingress" parent both when creating and dumping
    filters.

    Fixes: a7df4870d79b ("net_sched: fix tcm_parent in tc filter dump")
    Signed-off-by: Vlad Buslov
    Signed-off-by: David S. Miller
    Signed-off-by: Sasha Levin

    Vlad Buslov
     
  • [ Upstream commit c6aab66a728b6518772c74bd9dff66e1a1c652fd ]

    Since the commit 6a13a0d7b4d1 ("ftrace/kprobe: Show the maxactive number
    on kprobe_events") introduced to show the instance number of kretprobe
    events, the length of the 1st format of the kprobe event will not 1, but
    it can be longer. This caused a parser error in perf-probe.

    Skip the length check the 1st format of the kprobe event to accept this
    instance number.

    Without this fix:

    # perf probe -a vfs_read%return
    Added new event:
    probe:vfs_read__return (on vfs_read%return)

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

    perf record -e probe:vfs_read__return -aR sleep 1

    # perf probe -l
    Semantic error :Failed to parse event name: r16:probe/vfs_read__return
    Error: Failed to show event list.

    And with this fixes:

    # perf probe -a vfs_read%return
    ...
    # perf probe -l
    probe:vfs_read__return (on vfs_read%return)

    Fixes: 6a13a0d7b4d1 ("ftrace/kprobe: Show the maxactive number on kprobe_events")
    Reported-by: Yuxuan Shui
    Signed-off-by: Masami Hiramatsu
    Tested-by: Yuxuan Shui
    Cc: Jiri Olsa
    Cc: Namhyung Kim
    Cc: stable@vger.kernel.org
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=207587
    Link: http://lore.kernel.org/lkml/158877535215.26469.1113127926699134067.stgit@devnote2
    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: Sasha Levin

    Masami Hiramatsu