1. 24 3月, 2021 1 次提交
    • S
      perf stat: Introduce 'bperf' to share hardware PMCs with BPF · 7fac83aa
      Song Liu 提交于
      The perf tool uses performance monitoring counters (PMCs) to monitor
      system performance. The PMCs are limited hardware resources. For
      example, Intel CPUs have 3x fixed PMCs and 4x programmable PMCs per cpu.
      
      Modern data center systems use these PMCs in many different ways: system
      level monitoring, (maybe nested) container level monitoring, per process
      monitoring, profiling (in sample mode), etc. In some cases, there are
      more active perf_events than available hardware PMCs. To allow all
      perf_events to have a chance to run, it is necessary to do expensive
      time multiplexing of events.
      
      On the other hand, many monitoring tools count the common metrics
      (cycles, instructions). It is a waste to have multiple tools create
      multiple perf_events of "cycles" and occupy multiple PMCs.
      
      bperf tries to reduce such wastes by allowing multiple perf_events of
      "cycles" or "instructions" (at different scopes) to share PMUs. Instead
      of having each perf-stat session to read its own perf_events, bperf uses
      BPF programs to read the perf_events and aggregate readings to BPF maps.
      Then, the perf-stat session(s) reads the values from these BPF maps.
      
      Please refer to the comment before the definition of bperf_ops for the
      description of bperf architecture.
      
      bperf is off by default. To enable it, pass --bpf-counters option to
      perf-stat. bperf uses a BPF hashmap to share information about BPF
      programs and maps used by bperf. This map is pinned to bpffs. The
      default path is /sys/fs/bpf/perf_attr_map. The user could change the
      path with option --bpf-attr-map.
      
      Committer testing:
      
        # dmesg|grep "Performance Events" -A5
        [    0.225277] Performance Events: Fam17h+ core perfctr, AMD PMU driver.
        [    0.225280] ... version:                0
        [    0.225280] ... bit width:              48
        [    0.225281] ... generic registers:      6
        [    0.225281] ... value mask:             0000ffffffffffff
        [    0.225281] ... max period:             00007fffffffffff
        #
        #  for a in $(seq 6) ; do perf stat -a -e cycles,instructions sleep 100000 & done
        [1] 2436231
        [2] 2436232
        [3] 2436233
        [4] 2436234
        [5] 2436235
        [6] 2436236
        # perf stat -a -e cycles,instructions sleep 0.1
      
         Performance counter stats for 'system wide':
      
               310,326,987      cycles                                                        (41.87%)
               236,143,290      instructions              #    0.76  insn per cycle           (41.87%)
      
               0.100800885 seconds time elapsed
      
        #
      
      We can see that the counters were enabled for this workload 41.87% of
      the time.
      
      Now with --bpf-counters:
      
        #  for a in $(seq 32) ; do perf stat --bpf-counters -a -e cycles,instructions sleep 100000 & done
        [1] 2436514
        [2] 2436515
        [3] 2436516
        [4] 2436517
        [5] 2436518
        [6] 2436519
        [7] 2436520
        [8] 2436521
        [9] 2436522
        [10] 2436523
        [11] 2436524
        [12] 2436525
        [13] 2436526
        [14] 2436527
        [15] 2436528
        [16] 2436529
        [17] 2436530
        [18] 2436531
        [19] 2436532
        [20] 2436533
        [21] 2436534
        [22] 2436535
        [23] 2436536
        [24] 2436537
        [25] 2436538
        [26] 2436539
        [27] 2436540
        [28] 2436541
        [29] 2436542
        [30] 2436543
        [31] 2436544
        [32] 2436545
        #
        # ls -la /sys/fs/bpf/perf_attr_map
        -rw-------. 1 root root 0 Mar 23 14:53 /sys/fs/bpf/perf_attr_map
        # bpftool map | grep bperf | wc -l
        64
        #
      
        # bpftool map | tail
        1265: percpu_array  name accum_readings  flags 0x0
        	key 4B  value 24B  max_entries 1  memlock 4096B
        1266: hash  name filter  flags 0x0
        	key 4B  value 4B  max_entries 1  memlock 4096B
        1267: array  name bperf_fo.bss  flags 0x400
        	key 4B  value 8B  max_entries 1  memlock 4096B
        	btf_id 996
        	pids perf(2436545)
        1268: percpu_array  name accum_readings  flags 0x0
        	key 4B  value 24B  max_entries 1  memlock 4096B
        1269: hash  name filter  flags 0x0
        	key 4B  value 4B  max_entries 1  memlock 4096B
        1270: array  name bperf_fo.bss  flags 0x400
        	key 4B  value 8B  max_entries 1  memlock 4096B
        	btf_id 997
        	pids perf(2436541)
        1285: array  name pid_iter.rodata  flags 0x480
        	key 4B  value 4B  max_entries 1  memlock 4096B
        	btf_id 1017  frozen
        	pids bpftool(2437504)
        1286: array  flags 0x0
        	key 4B  value 32B  max_entries 1  memlock 4096B
        #
        # bpftool map dump id 1268 | tail
        value (CPU 21):
        8f f3 bc ca 00 00 00 00  80 fd 2a d1 4d 00 00 00
        80 fd 2a d1 4d 00 00 00
        value (CPU 22):
        7e d5 64 4d 00 00 00 00  a4 8a 2e ee 4d 00 00 00
        a4 8a 2e ee 4d 00 00 00
        value (CPU 23):
        a7 78 3e 06 01 00 00 00  b2 34 94 f6 4d 00 00 00
        b2 34 94 f6 4d 00 00 00
        Found 1 element
        # bpftool map dump id 1268 | tail
        value (CPU 21):
        c6 8b d9 ca 00 00 00 00  20 c6 fc 83 4e 00 00 00
        20 c6 fc 83 4e 00 00 00
        value (CPU 22):
        9c b4 d2 4d 00 00 00 00  3e 0c df 89 4e 00 00 00
        3e 0c df 89 4e 00 00 00
        value (CPU 23):
        18 43 66 06 01 00 00 00  5b 69 ed 83 4e 00 00 00
        5b 69 ed 83 4e 00 00 00
        Found 1 element
        # bpftool map dump id 1268 | tail
        value (CPU 21):
        f2 6e db ca 00 00 00 00  92 67 4c ba 4e 00 00 00
        92 67 4c ba 4e 00 00 00
        value (CPU 22):
        dc 8e e1 4d 00 00 00 00  d9 32 7a c5 4e 00 00 00
        d9 32 7a c5 4e 00 00 00
        value (CPU 23):
        bd 2b 73 06 01 00 00 00  7c 73 87 bf 4e 00 00 00
        7c 73 87 bf 4e 00 00 00
        Found 1 element
        #
      
        # perf stat --bpf-counters -a -e cycles,instructions sleep 0.1
      
         Performance counter stats for 'system wide':
      
             119,410,122      cycles
             152,105,479      instructions              #    1.27  insn per cycle
      
             0.101395093 seconds time elapsed
      
        #
      
      See? We had the counters enabled all the time.
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Reviewed-by: NJiri Olsa <jolsa@kernel.org>
      Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: kernel-team@fb.com
      Link: http://lore.kernel.org/lkml/20210316211837.910506-2-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7fac83aa
  2. 07 3月, 2021 3 次提交
  3. 29 1月, 2021 1 次提交
    • S
      tools: Factor Clang, LLC and LLVM utils definitions · 211a741c
      Sedat Dilek 提交于
      When dealing with BPF/BTF/pahole and DWARF v5 I wanted to build bpftool.
      
      While looking into the source code I found duplicate assignments in misc tools
      for the LLVM eco system, e.g. clang and llvm-objcopy.
      
      Move the Clang, LLC and/or LLVM utils definitions to tools/scripts/Makefile.include
      file and add missing includes where needed. Honestly, I was inspired by the commit
      c8a950d0 ("tools: Factor HOSTCC, HOSTLD, HOSTAR definitions").
      
      I tested with bpftool and perf on Debian/testing AMD64 and LLVM/Clang v11.1.0-rc1.
      
      Build instructions:
      
      [ make and make-options ]
      MAKE="make V=1"
      MAKE_OPTS="HOSTCC=clang HOSTCXX=clang++ HOSTLD=ld.lld CC=clang LD=ld.lld LLVM=1 LLVM_IAS=1"
      MAKE_OPTS="$MAKE_OPTS PAHOLE=/opt/pahole/bin/pahole"
      
      [ clean-up ]
      $MAKE $MAKE_OPTS -C tools/ clean
      
      [ bpftool ]
      $MAKE $MAKE_OPTS -C tools/bpf/bpftool/
      
      [ perf ]
      PYTHON=python3 $MAKE $MAKE_OPTS -C tools/perf/
      
      I was careful with respecting the user's wish to override custom compiler, linker,
      GNU/binutils and/or LLVM utils settings.
      Signed-off-by: NSedat Dilek <sedat.dilek@gmail.com>
      Signed-off-by: NDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: NAndrii Nakryiko <andrii@kernel.org>
      Acked-by: Jiri Olsa <jolsa@redhat.com> # tools/build and tools/perf
      Link: https://lore.kernel.org/bpf/20210128015117.20515-1-sedat.dilek@gmail.com
      211a741c
  4. 21 1月, 2021 1 次提交
    • S
      perf stat: Enable counting events for BPF programs · fa853c4b
      Song Liu 提交于
      Introduce 'perf stat -b' option, which counts events for BPF programs, like:
      
        [root@localhost ~]# ~/perf stat -e ref-cycles,cycles -b 254 -I 1000
           1.487903822            115,200      ref-cycles
           1.487903822             86,012      cycles
           2.489147029             80,560      ref-cycles
           2.489147029             73,784      cycles
           3.490341825             60,720      ref-cycles
           3.490341825             37,797      cycles
           4.491540887             37,120      ref-cycles
           4.491540887             31,963      cycles
      
      The example above counts 'cycles' and 'ref-cycles' of BPF program of id
      254.  This is similar to bpftool-prog-profile command, but more
      flexible.
      
      'perf stat -b' creates per-cpu perf_event and loads fentry/fexit BPF
      programs (monitor-progs) to the target BPF program (target-prog). The
      monitor-progs read perf_event before and after the target-prog, and
      aggregate the difference in a BPF map. Then the user space reads data
      from these maps.
      
      A new 'struct bpf_counter' is introduced to provide a common interface
      that uses BPF programs/maps to count perf events.
      
      Committer notes:
      
      Removed all but bpf_counter.h includes from evsel.h, not needed at all.
      
      Also BPF map lookups for PERCPU_ARRAYs need to have as its value receive
      buffer passed to the kernel libbpf_num_possible_cpus() entries, not
      evsel__nr_cpus(evsel), as the former uses
      /sys/devices/system/cpu/possible while the later uses
      /sys/devices/system/cpu/online, which may be less than the 'possible'
      number making the bpf map lookup overwrite memory and cause hard to
      debug memory corruption.
      
      We need to continue using evsel__nr_cpus(evsel) when accessing the
      perf_counts array tho, not to overwrite another are of memory :-)
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Link: https://lore.kernel.org/lkml/20210120163031.GU12699@kernel.org/Acked-by: NNamhyung Kim <namhyung@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-team@fb.com
      Link: http://lore.kernel.org/lkml/20201229214214.3413833-4-songliubraving@fb.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fa853c4b
  5. 16 1月, 2021 1 次提交
  6. 12 11月, 2020 1 次提交
  7. 01 10月, 2020 1 次提交
    • A
      perf trace: Use the autogenerated mmap 'prot' string/id table · 388968d8
      Arnaldo Carvalho de Melo 提交于
      No change in behaviour:
      
        # perf trace -e mmap sleep 1
             0.000 ( 0.009 ms): sleep/751870 mmap(len: 143317, prot: READ, flags: PRIVATE, fd: 3)                  = 0x7fa96d0f7000
             0.028 ( 0.004 ms): sleep/751870 mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS)           = 0x7fa96d0f5000
             0.037 ( 0.005 ms): sleep/751870 mmap(len: 1872744, prot: READ, flags: PRIVATE|DENYWRITE, fd: 3)       = 0x7fa96cf2b000
             0.044 ( 0.011 ms): sleep/751870 mmap(addr: 0x7fa96cf50000, len: 1376256, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x25000) = 0x7fa96cf50000
             0.056 ( 0.007 ms): sleep/751870 mmap(addr: 0x7fa96d0a0000, len: 307200, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x175000) = 0x7fa96d0a0000
             0.064 ( 0.007 ms): sleep/751870 mmap(addr: 0x7fa96d0eb000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x1bf000) = 0x7fa96d0eb000
             0.075 ( 0.005 ms): sleep/751870 mmap(addr: 0x7fa96d0f1000, len: 13160, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) = 0x7fa96d0f1000
             0.253 ( 0.005 ms): sleep/751870 mmap(len: 218049136, prot: READ, flags: PRIVATE, fd: 3)               = 0x7fa95ff38000
        #
        #
        # set -o vi
        # strace -e mmap sleep 1
        mmap(NULL, 143317, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f333bd83000
        mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f333bd81000
        mmap(NULL, 1872744, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f333bbb7000
        mmap(0x7f333bbdc000, 1376256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f333bbdc000
        mmap(0x7f333bd2c000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x175000) = 0x7f333bd2c000
        mmap(0x7f333bd77000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f333bd77000
        mmap(0x7f333bd7d000, 13160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f333bd7d000
        mmap(NULL, 218049136, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f332ebc4000
        +++ exited with 0 +++
        #
      
      And you can as well tweak 'perf trace's output to more closely match
      strace's:
      
        # perf config trace.show_arg_names=no
        # perf config trace.show_duration=no
        # perf config trace.show_prefix=yes
        # perf config trace.show_timestamp=no
        # perf config trace.show_zeros=yes
        # perf config trace.no_inherit=yes
        # perf trace -e mmap sleep 1
        mmap(NULL, 143317, PROT_READ, MAP_PRIVATE, 3, 0)                      = 0x7f0d287ca000
        mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS)     = 0x7f0d287c8000
        mmap(NULL, 1872744, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0)       = 0x7f0d285fe000
        mmap(0x7f0d28623000, 1376256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f0d28623000
        mmap(0x7f0d28773000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x175000) = 0x7f0d28773000
        mmap(0x7f0d287be000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f0d287be000
        mmap(0x7f0d287c4000, 13160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS) = 0x7f0d287c4000
        mmap(NULL, 218049136, PROT_READ, MAP_PRIVATE, 3, 0)                   = 0x7f0d1b60b000
        #
      
        # perf config | grep ^trace
        trace.show_arg_names=no
        trace.show_duration=no
        trace.show_prefix=yes
        trace.show_timestamp=no
        trace.show_zeros=yes
        trace.no_inherit=yes
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      388968d8
  8. 30 9月, 2020 1 次提交
    • A
      perf trace beauty: Add script to autogenerate mremap's flags args string/id table · 9012e3dd
      Arnaldo Carvalho de Melo 提交于
      It'll also conditionally generate the defines, so that if we don't have
      those when building a new tool tarball in an older systems, we get
      those, and we need them sometimes in the actual scnprintf routine, such
      as when checking if a flags means we have an extra arg, like with
      MREMAP_FIXED.
      
        $ tools/perf/trace/beauty/mremap_flags.sh
        static const char *mremap_flags[] = {
        	[ilog2(1) + 1] = "MAYMOVE",
        #ifndef MREMAP_MAYMOVE
        #define MREMAP_MAYMOVE 1
        #endif
        	[ilog2(2) + 1] = "FIXED",
        #ifndef MREMAP_FIXED
        #define MREMAP_FIXED 2
        #endif
        	[ilog2(4) + 1] = "DONTUNMAP",
        #ifndef MREMAP_DONTUNMAP
        #define MREMAP_DONTUNMAP 4
        #endif
        };
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ian Rogers <irogers@google.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9012e3dd
  9. 05 9月, 2020 2 次提交
  10. 14 8月, 2020 1 次提交
    • F
      perf build-ids: Fall back to debuginfod query if debuginfo not found · c7a14fdc
      Frank Ch. Eigler 提交于
      During a perf-record, use the -ldebuginfod API to query a debuginfod
      server, should the debug data not be found in the usual system
      locations.  If successful, the usual $HOME/.debug dir is populated.
      
      Tested with:
      
        $ find .
        .
        ./ctags-debuginfo-5.8-26.fc31.x86_64.rpm
        ./usr
        ./usr/lib
        ./usr/lib/debug
        ./usr/lib/debug/.build-id
        ./usr/lib/debug/.build-id/ca
        ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d
        ./usr/lib/debug/.build-id/ca/46f6ae6a0cee57d85abc1d461c49074248908d.debug
        ./usr/lib/debug/usr
        ./usr/lib/debug/usr/bin
        ./usr/lib/debug/usr/bin/ctags-5.8-26.fc31.x86_64.debug
      
        $ debuginfod  -F .
        ...
      
        $ rm -rf ~/.debug/ ; mkdir ~/.debug
      
        $ perf record make tags
          BUILD:   Doing 'make -j8' parallel build
          GEN      tags
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.107 MB perf.data (1483 samples) ]
      
        $ find ~/.debug | grep ctags
        /home/jolsa/.debug/usr/bin/ctags
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes
      
        $ rm -rf ~/.debug/ ; mkdir ~/.debug
      
        $ DEBUGINFOD_URLS=http://localhost:8002 perf record make tags
          BUILD:   Doing 'make -j8' parallel build
          GEN      tags
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.108 MB perf.data (1531 samples) ]
      
        $ find ~/.debug | grep ctag
        /home/jolsa/.debug/usr/bin/ctags
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/debug
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/elf
        /home/jolsa/.debug/usr/bin/ctags/ca46f6ae6a0cee57d85abc1d461c49074248908d/probes
      
      Note the 'debug' file is created in the last run.
      
      Note that currently the debuginfo data are downloaded only on record path,
      we still need add this support to perf build-id/report.. and test ;-)
      Tested-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Signed-off-by: NFrank Ch. Eigler <fche@redhat.com>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c7a14fdc
  11. 12 8月, 2020 1 次提交
    • A
      perf trace beauty: Use the autogenerated protocol family table · f3cf7fa9
      Arnaldo Carvalho de Melo 提交于
      That helps us not to lose new protocol families when they are
      introduced, replacing that hardcoded, dated family->string table.
      
      To recap what this allows us to do:
      
        # perf trace -e syscalls:sys_enter_socket/max-stack=10/ --filter=family==INET --max-events=1
           0.000 fetchmail/41097 syscalls:sys_enter_socket(family: INET, type: DGRAM|CLOEXEC|NONBLOCK, protocol: IP)
                                             __GI___socket (inlined)
                                             reopen (/usr/lib64/libresolv-2.31.so)
                                             send_dg (/usr/lib64/libresolv-2.31.so)
                                             __res_context_send (/usr/lib64/libresolv-2.31.so)
                                             __GI___res_context_query (inlined)
                                             __GI___res_context_search (inlined)
                                             _nss_dns_gethostbyname4_r (/usr/lib64/libnss_dns-2.31.so)
                                             gaih_inet.constprop.0 (/usr/lib64/libc-2.31.so)
                                             __GI_getaddrinfo (inlined)
                                             [0x15cb2] (/usr/bin/fetchmail)
        #
      
      More work is still needed to allow for the more natura strace-like
      syscall name usage instead of the trace event name:
      
        # perf trace -e socket/max-stack=10,family==INET/ --max-events=1
      
      I.e. to allow for modifiers to follow the syscall name and for logical
      expressions to be accepted as filters to use with that syscall, be it as
      trace event filters or BPF based ones.
      
      Using -v we can see how the trace event filter is built:
      
        # perf trace -v -e syscalls:sys_enter_socket/call-graph=dwarf/ --filter=family==INET --max-events=2
        <SNIP>
        New filter for syscalls:sys_enter_socket: (family==0x2) && (common_pid != 41384 && common_pid != 2836)
        <SNIP>
      
        $ tools/perf/trace/beauty/socket.sh | grep -w 2
      	[2] = "INET",
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3cf7fa9
  12. 30 5月, 2020 2 次提交
    • S
      perf tools: Add optional support for libpfm4 · 70943490
      Stephane Eranian 提交于
      This patch links perf with the libpfm4 library if it is available and
      LIBPFM4 is passed to the build. The libpfm4 library contains hardware
      event tables for all processors supported by perf_events. It is a helper
      library that helps convert from a symbolic event name to the event
      encoding required by the underlying kernel interface. This library is
      open-source and available from: http://perfmon2.sf.net.
      
      With this patch, it is possible to specify full hardware events by name.
      Hardware filters are also supported. Events must be specified via the
      --pfm-events and not -e option. Both options are active at the same time
      and it is possible to mix and match:
      
        $ perf stat --pfm-events inst_retired:any_p:c=1:i -e cycles ....
      
      One needs to explicitely ask for its inclusion by using the LIBPFM4 make
      command line option, ie its opt-in rather than opt-out of feature
      detection and build support.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Reviewed-by: NIan Rogers <irogers@google.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200505182943.218248-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      70943490
    • A
      perf build: Allow explicitely disabling the NO_SYSCALL_TABLE variable · 43de3869
      Arnaldo Carvalho de Melo 提交于
      This is useful to see if, on x86, the legacy libaudit still works, as it
      is used in architectures that don't have the SYSCALL_TABLE logic and we
      want to have it tested in 'make -C tools/perf/ build-test'.
      
      E.g.:
      
      Without having audit-libs-devel installed:
      
        $ make NO_SYSCALL_TABLE=1 O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
        <SNIP>
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ OFF ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        Makefile.config:664: No libaudit.h found, disables 'trace' tool, please install audit-libs-devel or libaudit-dev
        <SNIP>
      
      After installing it:
      
        $ rm -rf /tmp/build/perf ; mkdir -p /tmp/build/perf
        $ time make NO_SYSCALL_TABLE=1 O=/tmp/build/perf  -C tools/perf install-bin ; perf test python
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j12' parallel build
          HOSTCC   /tmp/build/perf/fixdep.o
          HOSTLD   /tmp/build/perf/fixdep-in.o
          LINK     /tmp/build/perf/fixdep
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/msr-index.h' differs from latest version at 'arch/x86/include/asm/msr-index.h'
        diff -u tools/arch/x86/include/asm/msr-index.h arch/x86/include/asm/msr-index.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.h' differs from latest version at 'tools/lib/bpf/hashmap.h'
        diff -u tools/perf/util/hashmap.h tools/lib/bpf/hashmap.h
        Warning: Kernel ABI header at 'tools/perf/util/hashmap.c' differs from latest version at 'tools/lib/bpf/hashmap.c'
        diff -u tools/perf/util/hashmap.c tools/lib/bpf/hashmap.c
      
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        $ ldd ~/bin/perf | grep audit
        	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007fc18978e000)
        $
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20200529155552.463-3-acme@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43de3869
  13. 28 5月, 2020 1 次提交
  14. 06 5月, 2020 1 次提交
    • I
      perf doc: Pass ASCIIDOC_EXTRA as an argument · 4b198449
      Ian Rogers 提交于
      commit e9cfa47e ("perf doc: allow ASCIIDOC_EXTRA to be an argument")
      allowed ASCIIDOC_EXTRA to be passed as an option to the Documentation
      Makefile. This change passes ASCIIDOC_EXTRA, set by detected features or
      command line options, prior to doing a Documentation build. This is
      necessary to allow conditional compilation, based on configuration
      variables, in asciidoc code.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Acked-by: NJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Florian Fainelli <f.fainelli@gmail.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Igor Lubashev <ilubashe@akamai.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiwei Sun <jiwei.sun@windriver.com>
      Cc: John Garry <john.garry@huawei.com>
      Cc: Kan Liang <kan.liang@linux.intel.com>
      Cc: Leo Yan <leo.yan@linaro.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Cc: yuzhoujian <yuzhoujian@didichuxing.com>
      Link: http://lore.kernel.org/lkml/20200429231443.207201-2-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4b198449
  15. 26 3月, 2020 1 次提交
  16. 24 3月, 2020 1 次提交
  17. 06 1月, 2020 1 次提交
  18. 26 11月, 2019 1 次提交
    • J
      perf tools: Allow to link with libbpf dynamicaly · 7b65e203
      Jiri Olsa 提交于
      Currently we support only static linking with kernel's libbpf
      (tools/lib/bpf). This patch adds libbpf package detection and support to
      link perf with it dynamically.
      
      The libbpf package status is displayed with:
      
        $ make VF=1
        Auto-detecting system features:
        ...
        ...                        libbpf: [ on  ]
      
      It's not checked by default, because it's quite new.  Once it's on most
      distros we can switch it on.
      
      For the same reason it's not added to the test-all check.
      
      Perf does not need advanced version of libbpf, so we can check just for
      the base bpf_object__open function.
      
      Adding new compile variable to detect libbpf package and link bpf
      dynamically:
      
        $ make LIBBPF_DYNAMIC=1
          ...
          LINK     perf
        $ ldd perf | grep bpf
          libbpf.so.0 => /lib64/libbpf.so.0 (0x00007f46818bc000)
      
      If libbpf is not installed, build stops with:
      
        Makefile.config:486: *** Error: No libbpf devel library found,\
        please install libbpf-devel.  Stop.
      
      Committer testing:
      
        $ make LIBBPF_DYNAMIC=1 -C tools/perf O=/tmp/build/perf
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
        Makefile.config:493: *** Error: No libbpf devel library found, please install libbpf-devel.  Stop.
        make[1]: *** [Makefile.perf:225: sub-make] Error 2
        make: *** [Makefile:70: all] Error 2
        make: Leaving directory '/home/acme/git/perf/tools/perf'
        $
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Toke Høiland-Jørgensen <toke@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexei Starovoitov <alexei.starovoitov@gmail.com>
      Cc: Andrii Nakryiko <andriin@fb.com>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: Jesper Dangaard Brouer <brouer@redhat.com>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Yonghong Song <yhs@fb.com>
      Cc: bpf@vger.kernel.org
      Cc: netdev@vger.kernel.org
      Link: http://lore.kernel.org/lkml/20191126121253.28253-1-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b65e203
  19. 16 10月, 2019 1 次提交
    • A
      libbeauty: Hook up the x86 irq_vectors table generator · f19a85c6
      Arnaldo Carvalho de Melo 提交于
      I.e. after running:
      
        $ make -C tools/perf O=/tmp/build/perf
      
      We end up with:
      
        $ cat /tmp/build/perf/trace/beauty/generated/x86_arch_irq_vectors_array.c
        static const char *x86_irq_vectors[] = {
        	[0x02] = "NMI",
        	[0x12] = "MCE",
        	[0x20] = "IRQ_MOVE_CLEANUP",
        	[0x80] = "IA32_SYSCALL",
        	[0xec] = "LOCAL_TIMER",
        	[0xed] = "HYPERV_STIMER0",
        	[0xee] = "HYPERV_REENLIGHTENMENT",
        	[0xef] = "MANAGED_IRQ_SHUTDOWN",
        	[0xf0] = "POSTED_INTR_NESTED",
        	[0xf1] = "POSTED_INTR_WAKEUP",
        	[0xf2] = "POSTED_INTR",
        	[0xf3] = "HYPERVISOR_CALLBACK",
        	[0xf4] = "DEFERRED_ERROR",
        	[0xf6] = "IRQ_WORK",
        	[0xf7] = "X86_PLATFORM_IPI",
        	[0xf8] = "REBOOT",
        	[0xf9] = "THRESHOLD_APIC",
        	[0xfa] = "THERMAL_APIC",
        	[0xfb] = "CALL_FUNCTION_SINGLE",
        	[0xfc] = "CALL_FUNCTION",
        	[0xfd] = "RESCHEDULE",
        	[0xfe] = "ERROR_APIC",
        	[0xff] = "SPURIOUS_APIC",
        };
        $
      
      Now its just a matter of using it, associating it to tracepoint arguments named
      'vector', all of which can be correctly used with this table, for int args.
      
      At some point we should move tools/perf/trace/beauty to tools/beauty/,
      so that it can be used more generally and even made available externally
      like libbpf, libperf, libtraceevent, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-0p2df4kq1afrxbck4e4ct34r@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f19a85c6
  20. 15 10月, 2019 1 次提交
    • J
      perf tools: Allow to build with -ltcmalloc · bb91a073
      Jiri Olsa 提交于
      By using "make TCMALLOC=1" you can enable perf to be build for usage
      with libtcmalloc.so (gperftools).
      
      Get heap profile (tools/perf directory):
      
        $ <install gperftools>
        $ make TCMALLOC=1 DEBUG=1
        $ HEAPPROFILE=/tmp/heapprof ./perf ...
        $ pprof ./perf /tmp/heapprof.000*
        (pprof) top
        Total: 2335.5 MB
          1735.1  74.3%  74.3%   1735.1  74.3% memdup
           402.0  17.2%  91.5%    402.0  17.2% zalloc
           140.2   6.0%  97.5%    145.8   6.2% map__new
            33.6   1.4%  98.9%     33.6   1.4% symbol__new
            12.4   0.5%  99.5%     12.4   0.5% alloc_event
             6.2   0.3%  99.7%      6.2   0.3% nsinfo__new
             5.5   0.2% 100.0%      5.5   0.2% nsinfo__copy
             0.3   0.0% 100.0%      0.3   0.0% dso__new
             0.1   0.0% 100.0%      0.1   0.0% do_read_string
             0.0   0.0% 100.0%      0.0   0.0% __GI__IO_file_doallocate
      
      See callstack:
        $ pprof --pdf ./perf /tmp/heapprof.00* > callstack.pdf
        $ pprof --web ./perf /tmp/heapprof.00*
      
      Committer testing:
      
      Install gperftools, on fedora:
      
        # dnf install gperftools-devel
      
      Then build:
      
       $ make TCMALLOC=1 DEBUG=1 -C tools/perf O=/tmp/build/perf install-bin
      
      Verify that it linked against the right library:
      
        $ ldd ~/bin/perf | grep tcma
      	libtcmalloc.so.4 => /lib64/libtcmalloc.so.4 (0x00007fb2953a7000)
        $
      
      Run 'perf trace' system wide for 1 minute:
      
        # HEAPPROFILE=/tmp/heapprof perf trace -a sleep 1m
        <SNIP>
         59985.524 ( 0.006 ms): Web Content/20354 recvmsg(fd: 9<socket:[1762817]>, msg: 0x7ffee5fdafb0) = -1 EAGAIN (Resource temporarily unavailable)
         59985.536 ( 0.005 ms): Web Content/20354 recvmsg(fd: 9<socket:[1762817]>, msg: 0x7ffee5fdafc0) = -1 EAGAIN (Resource temporarily unavailable)
         59981.956 (10.143 ms): SCTP timer/21716  ... [continued]: select())                            = 0 (Timeout)
         59985.549 (         ): Web Content/20354 poll(ufds: 0x7f1df38af180, nfds: 3, timeout_msecs: 4294967295) ...
             0.926 (59999.481 ms): sleep/29764  ... [continued]: nanosleep())                           = 0
         59992.133 (         ): SCTP timer/21716 select(tvp: 0x7ff5bf7fee80)                            ...
         60000.477 ( 0.009 ms): sleep/29764 close(fd: 1)                                                = 0
         60000.493 ( 0.005 ms): sleep/29764 close(fd: 2)                                                = 0
         60000.514 (         ): sleep/29764 exit_group()                                                = ?
        Dumping heap profile to /tmp/heapprof.0001.heap (Exiting, 3 MB in use)
      [root@quaco ~]#
      
      Install pprof:
      
        # dnf install pprof
      
      And run it:
      
        # pprof ~/bin/perf /tmp/heapprof.0001.heap
        Using local file /root/bin/perf.
        Using local file /tmp/heapprof.0001.heap.
        Welcome to pprof!  For help, type 'help'.
        (pprof) top
        Total: 4.0 MB
             1.7  42.0%  42.0%      2.2  54.1% map__new
             0.9  23.3%  65.3%      0.9  23.3% zalloc
             0.5  11.4%  76.7%      0.5  11.4% dso__new
             0.2   5.6%  82.3%      0.3   8.5% trace__sys_enter
             0.2   4.9%  87.2%      0.2   4.9% __GI___strdup
             0.2   3.8%  91.0%      0.2   3.8% new_term
             0.1   2.2%  93.2%      0.4  10.1% __perf_pmu__new_alias
             0.0   1.0%  94.3%      0.0   1.2% event_read_fields
             0.0   0.8%  95.1%      0.0   0.8% nsinfo__new
             0.0   0.7%  95.8%      0.1   3.2% trace__read_syscall_info
        (pprof)
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20191013151427.11941-2-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      bb91a073
  21. 11 10月, 2019 1 次提交
  22. 09 10月, 2019 1 次提交
    • A
      perf beauty: Hook up the x86 MSR table generator · fd218347
      Arnaldo Carvalho de Melo 提交于
      This way we generate the source with the table for later use by plugins,
      etc.
      
      I.e. after running:
      
        $ make -C tools/perf O=/tmp/build/perf
      
      We end up with:
      
        $ head /tmp/build/perf/trace/beauty/generated/x86_arch_MSRs_array.c
        static const char *x86_MSRs[] = {
        	[0x00000000] = "IA32_P5_MC_ADDR",
        	[0x00000001] = "IA32_P5_MC_TYPE",
        	[0x00000010] = "IA32_TSC",
        	[0x00000017] = "IA32_PLATFORM_ID",
        	[0x0000001b] = "IA32_APICBASE",
        	[0x00000020] = "KNC_PERFCTR0",
        	[0x00000021] = "KNC_PERFCTR1",
        	[0x00000028] = "KNC_EVNTSEL0",
        	[0x00000029] = "KNC_EVNTSEL1",
        $
      
      Now its just a matter of using it, first in a libtracevent plugin.
      
      At some point we should move tools/perf/trace/beauty to tools/beauty/,
      so that it can be used more generally and even made available externally
      like libbpf, libperf, libtraevent, etc.
      
      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: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b3rmutg4igcohx6kpo67qh4j@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fd218347
  23. 25 9月, 2019 1 次提交
  24. 10 9月, 2019 1 次提交
  25. 13 8月, 2019 1 次提交
    • I
      tools build: Add capability-related feature detection · 74d5f3d0
      Igor Lubashev 提交于
      Add utilities to help checking capabilities of the running procss.  Make
      perf link with libcap, if it is available. If no libcap-dev[el], assume
      no capabilities.
      
      Committer testing:
      
        $ make O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
      
        Auto-detecting system features:
        <SNIP>
        ...                        libbfd: [ on  ]
        ...                        libcap: [ OFF ]
        ...                        libelf: [ on  ]
        <SNIP>
        Makefile.config:833: No libcap found, disables capability support, please install libcap-devel/libcap-dev
        <SNIP>
        $ grep libcap /tmp/build/perf/FEATURE-DUMP
        feature-libcap=0
        $ cat /tmp/build/perf/feature/test-libcap.make.output
        test-libcap.c:2:10: fatal error: sys/capability.h: No such file or directory
            2 | #include <sys/capability.h>
              |          ^~~~~~~~~~~~~~~~~~
        compilation terminated.
        $
      
      Now install libcap-devel and try again:
      
        $ make O=/tmp/build/perf -C tools/perf install-bin
        make: Entering directory '/home/acme/git/perf/tools/perf'
          BUILD:   Doing 'make -j8' parallel build
        Warning: Kernel ABI header at 'tools/include/linux/bits.h' differs from latest version at 'include/linux/bits.h'
        diff -u tools/include/linux/bits.h include/linux/bits.h
        Warning: Kernel ABI header at 'tools/arch/x86/include/asm/cpufeatures.h' differs from latest version at 'arch/x86/include/asm/cpufeatures.h'
        diff -u tools/arch/x86/include/asm/cpufeatures.h arch/x86/include/asm/cpufeatures.h
      
        Auto-detecting system features:
        <SNIP>
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        ...                        libelf: [ on  ]
        <SNIP>>
          CC       /tmp/build/perf/jvmti/libjvmti.o
        <SNIP>>
        $ grep libcap /tmp/build/perf/FEATURE-DUMP
        feature-libcap=1
        $ cat /tmp/build/perf/feature/test-libcap.make.output
        $ ldd /tmp/build/perf/feature/test-libcap.make.bin
        ldd: /tmp/build/perf/feature/test-libcap.make.bin: No such file or directory
        $ ldd /tmp/build/perf/feature/test-libcap.bin
        	linux-vdso.so.1 (0x00007ffc35bfe000)
        	libcap.so.2 => /lib64/libcap.so.2 (0x00007ff9c62ff000)
        	libc.so.6 => /lib64/libc.so.6 (0x00007ff9c6139000)
        	/lib64/ld-linux-x86-64.so.2 (0x00007ff9c6326000)
        $
      Signed-off-by: NIgor Lubashev <ilubashe@akamai.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
      [ split from a larger patch ]
      Link: http://lkml.kernel.org/r/8a1e76cf5c7c9796d0d4d240fbaa85305298aafa.1565188228.git.ilubashe@akamai.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      74d5f3d0
  26. 30 7月, 2019 2 次提交
    • J
      libperf: Add libperf to the python.so build · a429dcb8
      Jiri Olsa 提交于
      Link libperf.a with python.so.
      
      Committer testing:
      
      Continues to work:
      
        # perf test python
        18: 'import perf' in python                               : Ok
        #
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-26-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a429dcb8
    • J
      libperf: Make libperf.a part of the perf build · 31435049
      Jiri Olsa 提交于
      Add an empty libperf.a under tools/perf/lib and link it with perf.
      
      It can also be built separately with:
      
        $ cd tools/perf/lib && make
          CC       core.o
          LD       libperf-in.o
          AR       libperf.a
          LINK     libperf.so
      
      Committer testing:
      
        $ make O=/tmp/build/perf -C tools/perf/lib/
        make: Entering directory '/home/acme/git/perf/tools/perf/lib'
          LINK     /tmp/build/perf/libperf.so
        make: Leaving directory '/home/acme/git/perf/tools/perf/lib'
        $ ls -la /tmp/build/perf/libperf.so
        -rwxrwxr-x. 1 acme acme 16232 Jul 22 15:30 /tmp/build/perf/libperf.so
        $ file /tmp/build/perf/libperf.so
        /tmp/build/perf/libperf.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=7a51d227d871b381ddb686dcf94145c4dd908221, not stripped
        $ git status tools/perf
        On branch perf/core
        nothing to commit, working tree clean
        $
        $ ls -lart tools/perf/lib/
        total 16
        drwxrwxr-x. 16 acme acme 4096 Jul 22 15:29 ..
        -rw-rw-r--.  1 acme acme 1633 Jul 22 15:29 Makefile
        -rw-rw-r--.  1 acme acme    0 Jul 22 15:29 core.c
        -rw-rw-r--.  1 acme acme   20 Jul 22 15:29 Build
        drwxrwxr-x.  2 acme acme 4096 Jul 22 15:29 .
        $
      
      Committer notes:
      
      Need to add -I$(srctree)/tools/arch/$(ARCH)/include/uapi
      -I$(srctree)/tools/include/uapi to tools/perf/lib/Makefile's INCLUDE
      variable to pick up the latest versions of kernel headers, even in older
      systems, this is in line with what is in tools/lib/bpf/Makefile.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Michael Petlan <mpetlan@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/20190721112506.12306-24-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      31435049
  27. 29 5月, 2019 5 次提交
    • A
      perf trace: Beautify 'sync_file_range' arguments · a9a187a7
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced sync_file_range
      flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e sync_file_range
      
      As root and see all sync_file_range syscalls with its args beautified.
      
        Doing a syscall strace like session looking for this syscall, then run
        postgresql's initdb command:
      
        # perf trace -e sync_file_range
        <SNIP>
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(7</var/lib/pgsql/data/base/1/2682>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(7</var/lib/pgsql/data/base/1/2682>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(6</var/lib/pgsql/data/global/1260_fsm>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(5</var/lib/pgsql/data/global>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(4</var/lib/pgsql/data>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        initdb/1332 sync_file_range(4</var/lib/pgsql/data>, 0, 0, SYNC_FILE_RANGE_WRITE) = 0
        ^C
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Amir Goldstein <amir73il@gmail.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-8tqy34xhpg8gwnaiv74xy93w@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9a187a7
    • A
      perf trace: Beautify 'fsmount' arguments · f6af0956
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced fsmount
      attr_flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fsmount
      
      As root and see all fsmount syscalls with its args beautified.
      
        # cat sys_fsmount.c
        #define _GNU_SOURCE        /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
      
        #define __NR_fsmount 432
      
        #define MOUNT_ATTR_RDONLY	 0x00000001 /* Mount read-only */
        #define MOUNT_ATTR_NOSUID	 0x00000002 /* Ignore suid and sgid bits */
        #define MOUNT_ATTR_NODEV	 0x00000004 /* Disallow access to device special files */
        #define MOUNT_ATTR_NOEXEC	 0x00000008 /* Disallow program execution */
        #define MOUNT_ATTR__ATIME	 0x00000070 /* Setting on how atime should be updated */
        #define MOUNT_ATTR_RELATIME	 0x00000000 /* - Update atime relative to mtime/ctime. */
        #define MOUNT_ATTR_NOATIME	 0x00000010 /* - Do not update access times. */
        #define MOUNT_ATTR_STRICTATIME 0x00000020 /* - Always perform atime updates */
        #define MOUNT_ATTR_NODIRATIME	 0x00000080 /* Do not update directory access times */
      
        static inline int sys_fsmount(int fs_fd, int flags, int attr_flags)
        {
        	syscall(__NR_fsmount, fs_fd, flags, attr_flags);
        }
      
        int main(int argc, char *argv[])
        {
        	int attr_flags = 0, fs_fd = 0;
      
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_RDONLY;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOSUID;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NODEV;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOEXEC;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NOATIME;
        	sys_fsmount(fs_fd++, 1, attr_flags);
        	attr_flags |= MOUNT_ATTR_STRICTATIME;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	attr_flags |= MOUNT_ATTR_NODIRATIME;
        	sys_fsmount(fs_fd++, 0, attr_flags);
        	return 0;
        }
        #
        # perf trace -e fsmount ./sys_fsmount
        fsmount(0, 0, MOUNT_ATTR_RELATIME)      = -1 EINVAL (Invalid argument)
        fsmount(1, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
        fsmount(2, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_RELATIME) = -1 EINVAL (Invalid argument)
        fsmount(3, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
        fsmount(4, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_RELATIME) = -1 EBADF (Bad file descriptor)
        fsmount(5, FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME) = -1 EBADF (Bad file descriptor)
        fsmount(6, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME) = -1 EINVAL (Invalid argument)
        fsmount(7, 0, MOUNT_ATTR_RDONLY|MOUNT_ATTR_NOSUID|MOUNT_ATTR_NODEV|MOUNT_ATTR_NOEXEC|MOUNT_ATTR_NOATIME|MOUNT_ATTR_STRICTATIME|MOUNT_ATTR_NODIRATIME) = -1 EINVAL (Invalid argument)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-w71uge0sfo6ns9uclhwtthca@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f6af0956
    • A
      perf trace: Beautify 'fsconfig' arguments · dcc6fd64
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first arg, fd, assigned using the
      heuristic that looks for syscall arg names and associates SCA_FD with
      'fd' named argumes, and wire up the recently introduced fsconfig cmd
      table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fsconfig
      
      As root and see all fsconfig syscalls with its args beautified, more
      work needed to look at the command and according to it handle the 'key',
      'value' and 'aux' args, using the 'fcntl' and 'futex' beautifiers as a
      starting point to see how to suppress sets of these last three args that
      may not be used by the 'cmd' arg, etc.
      
        # cat sys_fsconfig.c
        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
        #include <fcntl.h>
      
        #define __NR_fsconfig 431
      
        enum fsconfig_command {
        	FSCONFIG_SET_FLAG	= 0,	/* Set parameter, supplying no value */
        	FSCONFIG_SET_STRING	= 1,	/* Set parameter, supplying a string value */
        	FSCONFIG_SET_BINARY	= 2,	/* Set parameter, supplying a binary blob value */
        	FSCONFIG_SET_PATH	= 3,	/* Set parameter, supplying an object by path */
        	FSCONFIG_SET_PATH_EMPTY	= 4,	/* Set parameter, supplying an object by (empty) path */
        	FSCONFIG_SET_FD		= 5,	/* Set parameter, supplying an object by fd */
        	FSCONFIG_CMD_CREATE	= 6,	/* Invoke superblock creation */
        	FSCONFIG_CMD_RECONFIGURE = 7,	/* Invoke superblock reconfiguration */
        };
      
        static inline int sys_fsconfig(int fd, int cmd, const char *key, const void *value, int aux)
        {
        	syscall(__NR_fsconfig, fd, cmd, key, value, aux);
        }
      
        int main(int argc, char *argv[])
        {
        	int fd = 0, aux = 0;
      
        	open("/foo", 0);
        	sys_fsconfig(fd++, FSCONFIG_SET_FLAG,	     "/foo1", "/bar1", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_STRING,	     "/foo2", "/bar2", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_BINARY,	     "/foo3", "/bar3", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_PATH,	     "/foo4", "/bar4", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_PATH_EMPTY,  "/foo5", "/bar5", aux++);
        	sys_fsconfig(fd++, FSCONFIG_SET_FD,	     "/foo6", "/bar6", aux++);
        	sys_fsconfig(fd++, FSCONFIG_CMD_CREATE,	     "/foo7", "/bar7", aux++);
        	sys_fsconfig(fd++, FSCONFIG_CMD_RECONFIGURE, "/foo8", "/bar8", aux++);
        	return 0;
        }
        # trace -e fsconfig ./sys_fsconfig
        fsconfig(0, FSCONFIG_SET_FLAG, 0x40201b, 0x402015, 0) = -1 EINVAL (Invalid argument)
        fsconfig(1, FSCONFIG_SET_STRING, 0x402027, 0x402021, 1) = -1 EINVAL (Invalid argument)
        fsconfig(2, FSCONFIG_SET_BINARY, 0x402033, 0x40202d, 2) = -1 EINVAL (Invalid argument)
        fsconfig(3, FSCONFIG_SET_PATH, 0x40203f, 0x402039, 3) = -1 EBADF (Bad file descriptor)
        fsconfig(4, FSCONFIG_SET_PATH_EMPTY, 0x40204b, 0x402045, 4) = -1 EBADF (Bad file descriptor)
        fsconfig(5, FSCONFIG_SET_FD, 0x402057, 0x402051, 5) = -1 EINVAL (Invalid argument)
        fsconfig(6, FSCONFIG_CMD_CREATE, 0x402063, 0x40205d, 6) = -1 EINVAL (Invalid argument)
        fsconfig(7, FSCONFIG_CMD_RECONFIGURE, 0x40206f, 0x402069, 7) = -1 EINVAL (Invalid argument)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-fb04b76cm59zfuv1wzu40uxy@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      dcc6fd64
    • A
      perf trace: Beautify 'fspick' arguments · 693bd394
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first 2 args (dfd, path) and wire up
      the recently introduced fspick flags table generator.
      
      Now it should be possible to just use:
      
         perf trace -e fspick
      
      As root and see all move_mount syscalls with its args beautified, either
      using the vfs_getname perf probe method or using the
      augmented_raw_syscalls.c eBPF helper to get the pathnames, the other
      args should work in all cases, i.e. all that is needed can be obtained
      directly from the raw_syscalls:sys_enter tracepoint args.
      
        # cat sys_fspick.c
        #define _GNU_SOURCE        /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
        #include <fcntl.h>
      
        #define __NR_fspick 433
      
        #define FSPICK_CLOEXEC          0x00000001
        #define FSPICK_SYMLINK_NOFOLLOW 0x00000002
        #define FSPICK_NO_AUTOMOUNT     0x00000004
        #define FSPICK_EMPTY_PATH       0x00000008
      
        static inline int sys_fspick(int fd, const char *path, int flags)
        {
        	syscall(__NR_fspick, fd, path, flags);
        }
      
        int main(int argc, char *argv[])
        {
        	int flags = 0, fd = 0;
      
        	open("/foo", 0);
        	sys_fspick(fd++, "/foo1", flags);
        	flags |= FSPICK_CLOEXEC;
        	sys_fspick(fd++, "/foo2", flags);
        	flags |= FSPICK_SYMLINK_NOFOLLOW;
        	sys_fspick(fd++, "/foo3", flags);
        	flags |= FSPICK_NO_AUTOMOUNT;
        	sys_fspick(fd++, "/foo4", flags);
        	flags |= FSPICK_EMPTY_PATH;
        	return sys_fspick(fd++, "/foo5", flags);
        }
        # perf trace -e fspick ./sys_fspick
        LLVM: dumping /home/acme/git/perf/tools/perf/examples/bpf/augmented_raw_syscalls.o
        fspick(0, "/foo1", 0)                   = -1 ENOENT (No such file or directory)
        fspick(1, "/foo2", FSPICK_CLOEXEC)      = -1 ENOENT (No such file or directory)
        fspick(2, "/foo3", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW) = -1 ENOENT (No such file or directory)
        fspick(3, "/foo4", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT) = -1 ENOENT (No such file or directory)
        fspick(4, "/foo5", FSPICK_CLOEXEC|FSPICK_SYMLINK_NOFOLLOW|FSPICK_NO_AUTOMOUNT|FSPICK_EMPTY_PATH) = -1 ENOENT (No such file or directory)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-erau5xjtt8wvgnhvdbchstuk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      693bd394
    • A
      perf trace: Beautify 'move_mount' arguments · 566e3022
      Arnaldo Carvalho de Melo 提交于
      Use existing beautifiers for the first 4 args (to/from fds, pathnames)
      and wire up the recently introduced move_mount flags table generator.
      
      Now it should be possible to just use:
      
            perf trace -e move_mount
      
      As root and see all move_mount syscalls with its args beautified, except
      for the filenames, that need work in the augmented_raw_syscalls.c eBPF
      helper to pass more than one, see comment in the
      augmented_raw_syscalls.c source code, the other args should work in all
      cases, i.e. all that is needed can be obtained directly from the
      raw_syscalls:sys_enter tracepoint args.
      
      Running without the strace "skin" (.perfconfig setting output formatting
      switches to look like strace output + BPF to collect strings, as we
      still need to support collecting multiple string args for the same
      syscall, like with move_mount):
      
        # cat sys_move_mount.c
        #define _GNU_SOURCE         /* See feature_test_macros(7) */
        #include <unistd.h>
        #include <sys/syscall.h>   /* For SYS_xxx definitions */
      
        #define __NR_move_mount 429
      
        #define MOVE_MOUNT_F_SYMLINKS		0x00000001 /* Follow symlinks on from path */
        #define MOVE_MOUNT_F_AUTOMOUNTS		0x00000002 /* Follow automounts on from path */
        #define MOVE_MOUNT_F_EMPTY_PATH		0x00000004 /* Empty from path permitted */
        #define MOVE_MOUNT_T_SYMLINKS		0x00000010 /* Follow symlinks on to path */
        #define MOVE_MOUNT_T_AUTOMOUNTS		0x00000020 /* Follow automounts on to path */
        #define MOVE_MOUNT_T_EMPTY_PATH		0x00000040 /* Empty to path permitted */
      
        static inline int sys_move_mount(int from_fd, const char *from_pathname,
        				 int to_fd, const char *to_pathname,
        				 int flags)
        {
        	  syscall(__NR_move_mount, from_fd, from_pathname, to_fd, to_pathname, flags);
        }
      
        int main(int argc, char *argv[])
        {
        	  int flags = 0, from_fd = 0, to_fd = 100;
      
        	  sys_move_mount(from_fd++, "/foo", to_fd++, "bar", flags);
        	  flags |= MOVE_MOUNT_F_SYMLINKS;
        	  sys_move_mount(from_fd++, "/foo1", to_fd++, "bar1", flags);
                flags |= MOVE_MOUNT_F_AUTOMOUNTS;
        	  sys_move_mount(from_fd++, "/foo2", to_fd++, "bar2", flags);
                flags |= MOVE_MOUNT_F_EMPTY_PATH;
        	  sys_move_mount(from_fd++, "/foo3", to_fd++, "bar3", flags);
                flags |= MOVE_MOUNT_T_SYMLINKS;
        	  sys_move_mount(from_fd++, "/foo4", to_fd++, "bar4", flags);
                flags |= MOVE_MOUNT_T_AUTOMOUNTS;
        	  sys_move_mount(from_fd++, "/foo5", to_fd++, "bar5", flags);
                flags |= MOVE_MOUNT_T_EMPTY_PATH;
        	  return sys_move_mount(from_fd++, "/foo6", to_fd++, "bar6", flags);
        }
        # mv ~/.perfconfig  ~/.perfconfig.OFF
        # perf trace -e move_mount ./sys_move_mount
             0.000 ( 0.009 ms): sys_move_mount/28971 move_mount(from_pathname: 0x402010, to_dfd: 100, to_pathname: 0x402015) = -1 ENOENT (No such file or directory)
             0.011 ( 0.003 ms): sys_move_mount/28971 move_mount(from_dfd: 1, from_pathname: 0x40201e, to_dfd: 101, to_pathname: 0x402019, flags: F_SYMLINKS) = -1 ENOENT (No such file or directory)
             0.016 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 2, from_pathname: 0x402029, to_dfd: 102, to_pathname: 0x402024, flags: F_SYMLINKS|F_AUTOMOUNTS) = -1 ENOENT (No such file or directory)
             0.020 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 3, from_pathname: 0x402034, to_dfd: 103, to_pathname: 0x40202f, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH) = -1 ENOENT (No such file or directory)
             0.023 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 4, from_pathname: 0x40203f, to_dfd: 104, to_pathname: 0x40203a, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS) = -1 ENOENT (No such file or directory)
             0.027 ( 0.002 ms): sys_move_mount/28971 move_mount(from_dfd: 5, from_pathname: 0x40204a, to_dfd: 105, to_pathname: 0x402045, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS) = -1 ENOENT (No such file or directory)
             0.031 ( 0.017 ms): sys_move_mount/28971 move_mount(from_dfd: 6, from_pathname: 0x402055, to_dfd: 106, to_pathname: 0x402050, flags: F_SYMLINKS|F_AUTOMOUNTS|F_EMPTY_PATH|T_SYMLINKS|T_AUTOMOUNTS|T_EMPTY_PATH) = -1 ENOENT (No such file or directory)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-83rim8g4k0s4gieieh5nnlck@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      566e3022
  28. 21 5月, 2019 1 次提交
  29. 02 4月, 2019 1 次提交
  30. 29 3月, 2019 1 次提交
    • A
      tools headers uapi: Sync asm-generic/mman-common.h and linux/mman.h · be709d48
      Arnaldo Carvalho de Melo 提交于
      To deal with the move of some defines from asm-generic/mmap-common.h to
      linux/mman.h done in:
      
        746c9398 ("arch: move common mmap flags to linux/mman.h")
      
      The generated mmap_flags array stays the same:
      
        $ tools/perf/trace/beauty/mmap_flags.sh
        static const char *mmap_flags[] = {
      	[ilog2(0x40) + 1] = "32BIT",
      	[ilog2(0x01) + 1] = "SHARED",
      	[ilog2(0x02) + 1] = "PRIVATE",
      	[ilog2(0x10) + 1] = "FIXED",
      	[ilog2(0x20) + 1] = "ANONYMOUS",
      	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
      	[ilog2(0x0100) + 1] = "GROWSDOWN",
      	[ilog2(0x0800) + 1] = "DENYWRITE",
      	[ilog2(0x1000) + 1] = "EXECUTABLE",
      	[ilog2(0x2000) + 1] = "LOCKED",
      	[ilog2(0x4000) + 1] = "NORESERVE",
      	[ilog2(0x8000) + 1] = "POPULATE",
      	[ilog2(0x10000) + 1] = "NONBLOCK",
      	[ilog2(0x20000) + 1] = "STACK",
      	[ilog2(0x40000) + 1] = "HUGETLB",
      	[ilog2(0x80000) + 1] = "SYNC",
        };
        $
      
      And to have the system's sys/mman.h find the definition of MAP_SHARED
      and MAP_PRIVATE, make sure they are defined in the tools/ mman-common.h
      in a way that keeps it the same as the kernel's, need for keeping the
      Android's NDK cross build working.
      
      This silences these perf build warnings:
      
        Warning: Kernel ABI header at 'tools/include/uapi/asm-generic/mman-common.h' differs from latest version at 'include/uapi/asm-generic/mman-common.h'
        diff -u tools/include/uapi/asm-generic/mman-common.h include/uapi/asm-generic/mman-common.h
        Warning: Kernel ABI header at 'tools/include/uapi/linux/mman.h' differs from latest version at 'include/uapi/linux/mman.h'
        diff -u tools/include/uapi/linux/mman.h include/uapi/linux/mman.h
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-h80ycpc6pedg9s5z2rwpy6ws@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      be709d48
  31. 15 2月, 2019 1 次提交