1. 02 9月, 2020 8 次提交
  2. 23 6月, 2020 2 次提交
  3. 28 5月, 2020 1 次提交
    • A
      selftests: add openat2(2) selftests · 5f7d3758
      Aleksa Sarai 提交于
      to #26323588
      
      commit b28a10aedcd4d175470171a32f4f20b0a60a612b upstream.
      
      Test all of the various openat2(2) flags. A small stress-test of a
      symlink-rename attack is included to show that the protections against
      ".."-based attacks are sufficient.
      
      The main things these self-tests are enforcing are:
      
        * The struct+usize ABI for openat2(2) and copy_struct_from_user() to
          ensure that upgrades will be handled gracefully (in addition,
          ensuring that misaligned structures are also handled correctly).
      
        * The -EINVAL checks for openat2(2) are all correctly handled to avoid
          userspace passing unknown or conflicting flag sets (most
          importantly, ensuring that invalid flag combinations are checked).
      
        * All of the RESOLVE_* semantics (including errno values) are
          correctly handled with various combinations of paths and flags.
      
        * RESOLVE_IN_ROOT correctly protects against the symlink rename(2)
          attack that has been responsible for several CVEs (and likely will
          be responsible for several more).
      
      Cc: Shuah Khan <shuah@kernel.org>
      Signed-off-by: NAleksa Sarai <cyphar@cyphar.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Acked-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
      5f7d3758
  4. 18 3月, 2020 4 次提交
    • A
      tools headers uapi: Sync asm-generic/mman-common.h with the kernel · 5c1675fc
      Arnaldo Carvalho de Melo 提交于
      commit b1ba55cf1cfb9f3e0e00d743534684a25bf66d28 upstream
      
      To pick the changes from:
      
        1a4e58cce84e ("mm: introduce MADV_PAGEOUT")
        9c276cc65a58 ("mm: introduce MADV_COLD")
      
      That result in these changes in the tools:
      
        $ tools/perf/trace/beauty/madvise_behavior.sh > before
        $ cp include/uapi/asm-generic/mman-common.h tools/include/uapi/asm-generic/mman-common.h
        $ git diff
        diff --git a/tools/include/uapi/asm-generic/mman-common.h b/tools/include/uapi/asm-generic/mman-common.h
        index 63b1f506ea67..c160a5354eb6 100644
        --- a/tools/include/uapi/asm-generic/mman-common.h
        +++ b/tools/include/uapi/asm-generic/mman-common.h
        @@ -67,6 +67,9 @@
         #define MADV_WIPEONFORK 18             /* Zero memory on fork, child only */
         #define MADV_KEEPONFORK 19             /* Undo MADV_WIPEONFORK */
      
        +#define MADV_COLD      20              /* deactivate these pages */
        +#define MADV_PAGEOUT   21              /* reclaim these pages */
        +
         /* compatibility flags */
         #define MAP_FILE       0
      
        $ tools/perf/trace/beauty/madvise_behavior.sh > after
        $ diff -u before after
        --- before	2019-09-27 11:29:43.346320100 -0300
        +++ after	2019-09-27 11:30:03.838570439 -0300
        @@ -16,6 +16,8 @@
         	[17] = "DODUMP",
         	[18] = "WIPEONFORK",
         	[19] = "KEEPONFORK",
        +	[20] = "COLD",
        +	[21] = "PAGEOUT",
         	[100] = "HWPOISON",
         	[101] = "SOFT_OFFLINE",
         };
        $
      
      I.e. now when madvise gets those behaviours as args, it will be able to
      translate from the number to a human readable string.
      
      This addresses the following perf build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h'
        diff -u tools/include/uapi/asm-generic/mman-common.h include/uapi/asm-generic/mman-common.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Minchan Kim <minchan@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-n40y6c4sa49p29q6sl8w3ufx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Reviewed-by: NYang Shi <yang.shi@linux.alibaba.com>
      Signed-off-by: NXunlei Pang <xlpang@linux.alibaba.com>
      5c1675fc
    • A
      tools build: Check if gettid() is available before providing helper · 27a374d1
      Arnaldo Carvalho de Melo 提交于
      commit 4541a8bb13a86e504416a13360c8dc64d2fd612a upstream
      
      Laura reported that the perf build failed in fedora when we got a glibc
      that provides gettid(), which I reproduced using fedora rawhide with the
      glibc-devel-2.29.9000-26.fc31.x86_64 package.
      
      Add a feature check to avoid providing a gettid() helper in such
      systems.
      
      On a fedora rawhide system with this patch applied we now get:
      
        [root@7a5f55352234 perf]# grep gettid /tmp/build/perf/FEATURE-DUMP
        feature-gettid=1
        [root@7a5f55352234 perf]# cat /tmp/build/perf/feature/test-gettid.make.output
        [root@7a5f55352234 perf]# ldd /tmp/build/perf/feature/test-gettid.bin
                linux-vdso.so.1 (0x00007ffc6b1f6000)
                libc.so.6 => /lib64/libc.so.6 (0x00007f04e0a74000)
                /lib64/ld-linux-x86-64.so.2 (0x00007f04e0c47000)
        [root@7a5f55352234 perf]# nm /tmp/build/perf/feature/test-gettid.bin | grep -w gettid
                         U gettid@@GLIBC_2.30
        [root@7a5f55352234 perf]#
      
      While on a fedora:29 system:
      
        [acme@quaco perf]$ grep gettid /tmp/build/perf/FEATURE-DUMP
        feature-gettid=0
        [acme@quaco perf]$ cat /tmp/build/perf/feature/test-gettid.make.output
        test-gettid.c: In function ‘main’:
        test-gettid.c:8:9: error: implicit declaration of function ‘gettid’; did you mean ‘getgid’? [-Werror=implicit-function-declaration]
          return gettid();
                 ^~~~~~
                 getgid
        cc1: all warnings being treated as errors
        [acme@quaco perf]$
      Reported-by: NLaura Abbott <labbott@redhat.com>
      Tested-by: NLaura Abbott <labbott@redhat.com>
      Acked-by: NJiri Olsa &lt;jolsa@kernel.org&gt;Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Florian Weimer <fweimer@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lkml.kernel.org/n/tip-yfy3ch53agmklwu9o7rlgf9c@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: Nluanshi <zhangliguang@linux.alibaba.com>
      Reviewed-by: NAlex Shi <alex.shi@linux.alibaba.com>
      27a374d1
    • J
      tools/io_uring: sync with liburing · a520af94
      Jens Axboe 提交于
      commit 004d564f908790efe815a6510a542ac1227ef2a2 upstream.
      
      Various fixes and changes have been applied to liburing since we
      copied some select bits to the kernel testing/examples part, sync
      up with liburing to get those changes.
      
      Most notable is the change that split the CQE reading into the peek
      and seen event, instead of being just a single function. Also fixes
      an unsigned wrap issue in io_uring_submit(), leak of 'fd' in setup
      if we fail, and various other little issues.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
      a520af94
    • J
      tools/io_uring: fix Makefile for pthread library link · 16770031
      Jens Axboe 提交于
      commit 486f069253c3c738dec62daeb16f7232b2cca065 upstream.
      
      Currently fails with:
      
      io_uring-bench.o: In function `main':
      /home/axboe/git/linux-block/tools/io_uring/io_uring-bench.c:560: undefined reference to `pthread_create'
      /home/axboe/git/linux-block/tools/io_uring/io_uring-bench.c:588: undefined reference to `pthread_join'
      collect2: error: ld returned 1 exit status
      Makefile:11: recipe for target 'io_uring-bench' failed
      make: *** [io_uring-bench] Error 1
      
      Move -lpthread to the end.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
      16770031
  5. 17 1月, 2020 5 次提交
    • P
      HYGON: tools/cpupower: Add Hygon Dhyana support · ec3c44ff
      Pu Wen 提交于
      commit 995d5f64b62f20f05b8e0972f07ec4d6c23333c9 upstream.
      
      The tool cpupower is useful to get CPU frequency information and monitor
      power stats on the Hygon Dhyana platform. So add Hygon Dhyana support to
      it by checking vendor and family to share the code path of AMD family
      17h.
      Signed-off-by: NPu Wen <puwen@hygon.cn>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NShuah Khan (Samsung OSG) <shuah@kernel.org>
      CC: Prarit Bhargava <prarit@redhat.com>
      CC: Shuah Khan <shuah@kernel.org>
      CC: Thomas Gleixner <tglx@linutronix.de>
      CC: Thomas Renninger <trenn@suse.com>
      CC: linux-pm@vger.kernel.org
      Link: http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cnAcked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      ec3c44ff
    • J
      tools/io_uring: remove IOCQE_FLAG_CACHEHIT · 204fcca3
      Jens Axboe 提交于
      commit 704236672edacf353c362bab70c3d3eda7bb4a51 upstream.
      
      This ended up not being included in the mainline version of io_uring,
      so drop it from the test app as well.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      204fcca3
    • A
      tools headers: Update x86's syscall_64.tbl and uapi/asm-generic/unistd · 00400e96
      Arnaldo Carvalho de Melo 提交于
      commit 8142bd82a59e452fefea7b21113101d6a87d9fa8 upstream.
      
      To pick up the changes introduced in the following csets:
      
        2b188cc1bb85 ("Add io_uring IO interface")
        edafccee56ff ("io_uring: add support for pre-mapped user IO buffers")
        3eb39f47934f ("signal: add pidfd_send_signal() syscall")
      
      This makes 'perf trace' to become aware of these new syscalls, so that
      one can use them like 'perf trace -e ui_uring*,*signal' to do a system
      wide strace-like session looking at those syscalls, for instance.
      
      For example:
      
        # perf trace -s io_uring-cp ~acme/isos/RHEL-x86_64-dvd1.iso ~/bla
      
         Summary of events:
      
         io_uring-cp (383), 1208866 events, 100.0%
      
           syscall         calls   total    min     avg     max   stddev
                                   (msec) (msec)  (msec)  (msec)     (%)
           -------------- ------ -------- ------ ------- -------  ------
           io_uring_enter 605780 2955.615  0.000   0.005  33.804   1.94%
           openat              4  459.446  0.004 114.861 459.435 100.00%
           munmap              4    0.073  0.009   0.018   0.042  44.03%
           mmap               10    0.054  0.002   0.005   0.026  43.24%
           brk                28    0.038  0.001   0.001   0.003   7.51%
           io_uring_setup      1    0.030  0.030   0.030   0.030   0.00%
           mprotect            4    0.014  0.002   0.004   0.005  14.32%
           close               5    0.012  0.001   0.002   0.004  28.87%
           fstat               3    0.006  0.001   0.002   0.003  35.83%
           read                4    0.004  0.001   0.001   0.002  13.58%
           access              1    0.003  0.003   0.003   0.003   0.00%
           lseek               3    0.002  0.001   0.001   0.001   9.00%
           arch_prctl          2    0.002  0.001   0.001   0.001   0.69%
           execve              1    0.000  0.000   0.000   0.000   0.00%
        #
        # perf trace -e io_uring* -s io_uring-cp ~acme/isos/RHEL-x86_64-dvd1.iso ~/bla
      
         Summary of events:
      
         io_uring-cp (390), 1191250 events, 100.0%
      
           syscall         calls   total    min    avg    max  stddev
                                   (msec) (msec) (msec) (msec)    (%)
           -------------- ------ -------- ------ ------ ------ ------
           io_uring_enter 597093 2706.060  0.001  0.005 14.761  1.10%
           io_uring_setup      1    0.038  0.038  0.038  0.038  0.00%
        #
      
      More work needed to make the tools/perf/examples/bpf/augmented_raw_syscalls.c
      BPF program to copy the 'struct io_uring_params' arguments to perf's ring
      buffer so that 'perf trace' can use the BTF info put in place by pahole's
      conversion of the kernel DWARF and then auto-beautify those arguments.
      
      This patch produces the expected change in the generated syscalls table
      for x86_64:
      
        --- /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c.before	2019-03-26 13:37:46.679057774 -0300
        +++ /tmp/build/perf/arch/x86/include/generated/asm/syscalls_64.c	2019-03-26 13:38:12.755990383 -0300
        @@ -334,5 +334,9 @@ static const char *syscalltbl_x86_64[] =
         	[332] = "statx",
         	[333] = "io_pgetevents",
         	[334] = "rseq",
        +	[424] = "pidfd_send_signal",
        +	[425] = "io_uring_setup",
        +	[426] = "io_uring_enter",
        +	[427] = "io_uring_register",
         };
        -#define SYSCALLTBL_x86_64_MAX_ID 334
        +#define SYSCALLTBL_x86_64_MAX_ID 427
      
      This silences these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/unistd.h' differs from latest version at 'include/uapi/asm-generic/unistd.h'
        diff -u tools/include/uapi/asm-generic/unistd.h include/uapi/asm-generic/unistd.h
        Warning: Kernel ABI header at 'tools/perf/arch/x86/entry/syscalls/syscall_64.tbl' differs from latest version at 'arch/x86/entry/syscalls/syscall_64.tbl'
        diff -u tools/perf/arch/x86/entry/syscalls/syscall_64.tbl arch/x86/entry/syscalls/syscall_64.tbl
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>
      Cc: Christian Brauner <christian@brauner.io>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lkml.kernel.org/n/tip-p0ars3otuc52x5iznf21shhw@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      00400e96
    • J
      io_uring: add a few test tools · b0034373
      Jens Axboe 提交于
      commit 21b4aa5d20fd07207e73270cadffed5c63fb4343 upstream.
      
      This adds two test programs in tools/io_uring/ that demonstrate both
      the raw io_uring API (and all features) through a small benchmark
      app, io_uring-bench, and the liburing exposed API in a simplified
      cp(1) implementation through io_uring-cp.
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
      Reviewed-by: NJeffle Xu <jefflexu@linux.alibaba.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      b0034373
    • M
      perf vendor events amd: perf PMU events for AMD Family 17h · 3253729e
      Martin Liška 提交于
      commit 98c07a8f74f85a19aeee2016f5afa0c667fa694d upstream.
      
      Thi patch adds PMC events for AMD Family 17 CPUs as defined in [1].  It
      covers events described in section: 2.1.13. Regex pattern in mapfile.csv
      covers all CPUs of the family.
      
      [1] https://support.amd.com/TechDocs/54945_PPR_Family_17h_Models_00h-0Fh.pdfSigned-off-by: NMartin Liška <mliska@suse.cz>
      Acked-by: NBorislav Petkov <bp@suse.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jon Grimm <jon.grimm@amd.com>
      Cc: Martin Jambor <mjambor@suse.cz>
      Cc: William Cohen <wcohen@redhat.com>
      Link: https://lkml.kernel.org/r/d65873ca-e402-b198-4fe9-8c4af81258c8@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NWANG Siyuan <Siyuan.Wang@amd.com>
      Acked-by: NCaspar Zhang <caspar@linux.alibaba.com>
      3253729e
  6. 15 1月, 2020 12 次提交
  7. 27 12月, 2019 6 次提交
  8. 18 12月, 2019 1 次提交
  9. 13 12月, 2019 1 次提交
    • A
      perf script: Fix invalid LBR/binary mismatch error · 484c4d9a
      Adrian Hunter 提交于
      [ Upstream commit 5172672da02e483d9b3c4d814c3482d0c8ffb1a6 ]
      
      The 'len' returned by grab_bb() includes an extra MAXINSN bytes to allow
      for the last instruction, so the the final 'offs' will not be 'len'.
      Fix the error condition logic accordingly.
      
      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
                  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
      
      After:
      
        $ 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
              00005641d58069c0                        movzxb  (%r13,%rdx,1), %edi
              00005641d58069c6                        add %rax, %rdi
      
      Fixes: e98df280bc2a ("perf script brstackinsn: Fix recovery from LBR/binary mismatch")
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lore.kernel.org/lkml/20191127095631.15663-1-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      484c4d9a