1. 20 10月, 2018 1 次提交
    • A
      perf evsel: Introduce per event max_events property · 2fda5ada
      Arnaldo Carvalho de Melo 提交于
      This simply adds the field to 'struct perf_evsel' and allows setting
      it via the event parser, to test it lets trace trace:
      
      First look at where in a function that receives an evsel we can put a probe
      to read how evsel->max_events was setup:
      
        # perf probe -x ~/bin/perf -L trace__event_handler
        <trace__event_handler@/home/acme/git/perf/tools/perf/builtin-trace.c:0>
              0  static int trace__event_handler(struct trace *trace, struct perf_evsel *evsel,
                                                union perf_event *event __maybe_unused,
                                                struct perf_sample *sample)
              3  {
              4         struct thread *thread = machine__findnew_thread(trace->host, sample->pid, sample->tid);
              5         int callchain_ret = 0;
      
              7         if (sample->callchain) {
              8                 callchain_ret = trace__resolve_callchain(trace, evsel, sample, &callchain_cursor);
              9                 if (callchain_ret == 0) {
             10                         if (callchain_cursor.nr < trace->min_stack)
             11                                 goto out;
             12                         callchain_ret = 1;
                                }
                        }
      
      See what variables we can probe at line 7:
      
        # perf probe -x ~/bin/perf -V trace__event_handler:7
        Available variables at trace__event_handler:7
                @<trace__event_handler+89>
                        int     callchain_ret
                        struct perf_evsel*      evsel
                        struct perf_sample*     sample
                        struct thread*  thread
                        struct trace*   trace
                        union perf_event*       event
      
      Add a probe at that line asking for evsel->max_events to be collected and named
      as "max_events":
      
        # perf probe -x ~/bin/perf trace__event_handler:7 'max_events=evsel->max_events'
        Added new event:
          probe_perf:trace__event_handler (on trace__event_handler:7 in /home/acme/bin/perf with max_events=evsel->max_events)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe_perf:trace__event_handler -aR sleep 1
      
      Now use 'perf trace', here aliased to just 'trace' and trace trace, i.e.
      the first 'trace' is tracing just that 'probe_perf:trace__event_handler' event,
      while the traced trace is tracing all scheduler tracepoints, will stop at two
      events (--max-events 2) and will just set evsel->max_events for all the sched
      tracepoints to 9, we will see the output of both traces intermixed:
      
        # trace -e *perf:*event_handler trace --max-events 2 -e sched:*/nr=9/
             0.000 :0/0 sched:sched_waking:comm=rcu_sched pid=10 prio=120 target_cpu=000
             0.009 :0/0 sched:sched_wakeup:comm=rcu_sched pid=10 prio=120 target_cpu=000
             0.000 trace/23949 probe_perf:trace__event_handler:(48c34a) max_events=0x9
             0.046 trace/23949 probe_perf:trace__event_handler:(48c34a) max_events=0x9
        #
      
      Now, if the traced trace sends its output to /dev/null, we'll see just
      what the first level trace outputs: that evsel->max_events is indeed
      being set to 9:
      
        # trace -e *perf:*event_handler trace -o /dev/null --max-events 2 -e sched:*/nr=9/
             0.000 trace/23961 probe_perf:trace__event_handler:(48c34a) max_events=0x9
             0.030 trace/23961 probe_perf:trace__event_handler:(48c34a) max_events=0x9
        #
      
      Now that we can set evsel->max_events, we can go to the next step, honour that
      per-event property in 'perf trace'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-og00yasj276joem6e14l1eas@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      2fda5ada
  2. 19 10月, 2018 3 次提交
    • A
      perf trace: Introduce --max-events · 5067a8cd
      Arnaldo Carvalho de Melo 提交于
      Allow stopping tracing after a number of events take place, considering
      strace-like syscalls formatting as one event per enter/exit pair or when
      in a multi-process tracing session a syscall is interrupted and printed
      ending with '...'.
      
      Examples included in the documentation:
      
      Trace the first 4 open, openat or open_by_handle_at syscalls (in the future more syscalls may match here):
      
        $ perf trace -e open* --max-events 4
        [root@jouet perf]# trace -e open* --max-events 4
        2272.992 ( 0.037 ms): gnome-shell/1370 openat(dfd: CWD, filename: /proc/self/stat) = 31
        2277.481 ( 0.139 ms): gnome-shell/3039 openat(dfd: CWD, filename: /proc/self/stat) = 65
        3026.398 ( 0.076 ms): gnome-shell/3039 openat(dfd: CWD, filename: /proc/self/stat) = 65
        4294.665 ( 0.015 ms): sed/15879 openat(dfd: CWD, filename: /etc/ld.so.cache, flags: CLOEXEC) = 3
        $
      
      Trace the first minor page fault when running a workload:
      
        # perf trace -F min --max-stack=7 --max-events 1 sleep 1
           0.000 ( 0.000 ms): sleep/18006 minfault [__clear_user+0x1a] => 0x5626efa56080 (?k)
                                             __clear_user ([kernel.kallsyms])
                                             load_elf_binary ([kernel.kallsyms])
                                             search_binary_handler ([kernel.kallsyms])
                                             __do_execve_file.isra.33 ([kernel.kallsyms])
                                             __x64_sys_execve ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64 ([kernel.kallsyms])
        #
      
      Trace the next min page page fault to take place on the first CPU:
      
        # perf trace -F min --call-graph=dwarf --max-events 1 --cpu 0
           0.000 ( 0.000 ms): Web Content/17136 minfault [js::gc::Chunk::fetchNextDecommittedArena+0x4b] => 0x7fbe6181b000 (?.)
                                             js::gc::FreeSpan::initAsEmpty (inlined)
                                             js::gc::Arena::setAsNotAllocated (inlined)
                                             js::gc::Chunk::fetchNextDecommittedArena (/usr/lib64/firefox/libxul.so)
                                             js::gc::Chunk::allocateArena (/usr/lib64/firefox/libxul.so)
                                             js::gc::GCRuntime::allocateArena (/usr/lib64/firefox/libxul.so)
                                             js::gc::ArenaLists::allocateFromArena (/usr/lib64/firefox/libxul.so)
                                             js::gc::GCRuntime::tryNewTenuredThing<JSString, (js::AllowGC)1> (inlined)
                                             js::AllocateString<JSString, (js::AllowGC)1> (/usr/lib64/firefox/libxul.so)
                                             js::Allocate<JSThinInlineString, (js::AllowGC)1> (inlined)
                                             JSThinInlineString::new_<(js::AllowGC)1> (inlined)
                                             AllocateInlineString<(js::AllowGC)1, unsigned char> (inlined)
                                             js::ConcatStrings<(js::AllowGC)1> (/usr/lib64/firefox/libxul.so)
                                             [0x18b26e6bc2bd] (/tmp/perf-17136.map)
      
      Tracing the next four ext4 operations on a specific CPU:
      
        # perf trace -e ext4:*/call-graph=fp/ --max-events 4 --cpu 3
           0.000 mutt/3849 ext4:ext4_es_lookup_extent_enter:dev 253,2 ino 57277 lblk 0
                                             ext4_es_lookup_extent ([kernel.kallsyms])
                                             read (/usr/lib64/libc-2.26.so)
           0.097 mutt/3849 ext4:ext4_es_lookup_extent_exit:dev 253,2 ino 57277 found 0 [0/0) 0
                                             ext4_es_lookup_extent ([kernel.kallsyms])
                                             read (/usr/lib64/libc-2.26.so)
           0.141 mutt/3849 ext4:ext4_ext_map_blocks_enter:dev 253,2 ino 57277 lblk 0 len 1 flags
                                             ext4_ext_map_blocks ([kernel.kallsyms])
                                             read (/usr/lib64/libc-2.26.so)
           0.184 mutt/3849 ext4:ext4_ext_load_extent:dev 253,2 ino 57277 lblk 1516511 pblk 18446744071750013657
                                             __read_extent_tree_block ([kernel.kallsyms])
                                             __read_extent_tree_block ([kernel.kallsyms])
                                             ext4_find_extent ([kernel.kallsyms])
                                             ext4_ext_map_blocks ([kernel.kallsyms])
                                             ext4_map_blocks ([kernel.kallsyms])
                                             ext4_mpage_readpages ([kernel.kallsyms])
                                             read_pages ([kernel.kallsyms])
                                             __do_page_cache_readahead ([kernel.kallsyms])
                                             ondemand_readahead ([kernel.kallsyms])
                                             generic_file_read_iter ([kernel.kallsyms])
                                             __vfs_read ([kernel.kallsyms])
                                             vfs_read ([kernel.kallsyms])
                                             ksys_read ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             entry_SYSCALL_64 ([kernel.kallsyms])
                                             read (/usr/lib64/libc-2.26.so)
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Rudá Moura <ruda.moura@gmail.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-sweh107bs7ol5bzls0m4tqdz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      5067a8cd
    • A
      tools lib subcmd: Introduce OPTION_ULONG · 4ba8b3eb
      Arnaldo Carvalho de Melo 提交于
      For completeness, will be used in 'perf trace --max-events'.
      
      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: Josh Poimboeuf <jpoimboe@redhat.com>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-glaj3pwespxfj2fdjs9a20b6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4ba8b3eb
    • H
      perf arm64: Fix generate system call table failed with /tmp mounted with noexec · 389373d3
      Hongxu Jia 提交于
      When /tmp is mounted with noexec, mksyscalltbl fails.
      
        [snip]
        |perf-1.0/tools/perf/arch/arm64/entry/syscalls//mksyscalltbl:
        /tmp/create-table-6VGPSt: Permission denied
        [snip]
      
      Add variable TMPDIR as prefix dir of the temporary file, if it is set,
      replace default /tmp.
      Signed-off-by: NHongxu Jia <hongxu.jia@windriver.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kim Phillips <kim.phillips@arm.com>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Sébastien Boisvert <sboisvert@gydle.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Fixes: 2b588243 ("perf arm64: Generate system call table from asm/unistd.h")
      LPU-Reference: 1539851173-14959-1-git-send-email-hongxu.jia@windriver.com
      Link: https://lkml.kernel.org/n/tip-1qrgq840ci0c5cy4oww957ge@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      389373d3
  3. 18 10月, 2018 7 次提交
    • D
      perf symbols: Set PLT entry/header sizes properly on Sparc · d6afa561
      David Miller 提交于
      Using the sh_entsize for both values isn't correct.  It happens to be
      correct on x86...
      
      For both 32-bit and 64-bit sparc, there are four PLT entries in the PLT
      section.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexis Berlemont <alexis.berlemont@gmail.com>
      Cc: David Tolnay <dtolnay@gmail.com>
      Cc: Hanjun Guo <guohanjun@huawei.com>
      Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
      Cc: Li Bin <huawei.libin@huawei.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Milian Wolff <milian.wolff@kdab.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: zhangmengting@huawei.com
      Fixes: b2f76050 ("perf symbols: Fix plt entry calculation for ARM and AARCH64")
      Link: http://lkml.kernel.org/r/20181017.120859.2268840244308635255.davem@davemloft.netSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d6afa561
    • D
    • D
      perf annotate: Add Sparc support · 0ab41886
      David Miller 提交于
      E.g.:
      
        $ perf annotate --stdio2
        Samples: 7K of event 'cycles:ppp', 4000 Hz, Event count (approx.): 3086733887
        __gettimeofday  /lib32/libc-2.27.so [Percent: local period]
        Percent│
               │
               │
               │    Disassembly of section .text:
               │
               │    000a6fa0 <__gettimeofday@@GLIBC_2.0>:
          0.47 │      save   %sp, -96, %sp
          0.73 │      sethi  %hi(0xe9000), %l7
               │    → call   __frame_state_for@@GLIBC_2.0+0x480
          0.30 │      add    %l7, 0x58, %l7     ! e9058 <nftw64@@GLIBC_2.3.3+0x818>
          1.33 │      mov    %i0, %o0
               │      mov    %i1, %o1
          0.43 │      mov    0x74, %g1
               │      ta     0x10
         88.92 │    ↓ bcc    30
          2.95 │      clr    %g1
               │      neg    %o0
               │      mov    1, %g1
          0.31 │30:   cmp    %g1, 0
               │      bne,pn %icc, a6fe4 <__gettimeofday@@GLIBC_2.0+0x44>
               │      mov    %o0, %i0
          1.96 │    ← return %i7 + 8
          2.62 │      nop
               │      sethi  %hi(0), %g1
               │      neg    %o0, %g2
               │      add    %g1, 0x160, %g1
               │      ld     [ %l7 + %g1 ], %g1
               │      st     %g2, [ %g7 + %g1 ]
               │    ← return %i7 + 8
               │      mov    -1, %o0
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Link: http://lkml.kernel.org/r/20181016.205555.1070918198627611771.davem@davemloft.netSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0ab41886
    • A
      perf record: Encode -k clockid frequency into Perf trace · cf790516
      Alexey Budankov 提交于
      Store -k clockid frequency into Perf trace to enable timestamps
      derived metrics conversion into wall clock time on reporting stage.
      
      Below is the example of perf report output:
      
        tools/perf/perf record -k raw -- ../../matrix/linux/matrix.gcc
        ...
        [ perf record: Captured and wrote 31.222 MB perf.data (818054 samples) ]
      
        tools/perf/perf report --header
        # ========
        ...
        # event : name = cycles:ppp, , size = 112, { sample_period, sample_freq } = 4000, sample_type = IP|TID|TIME|PERIOD, disabled = 1, inherit = 1, mmap = 1, comm = 1, freq = 1, enable_on_exec = 1, task = 1, precise_ip = 3, sample_id_all = 1, exclude_guest = 1, mmap2 = 1, comm_exec = 1, use_clockid = 1, clockid = 4
        ...
        # clockid frequency: 1000 MHz
        ...
        # ========
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/23a4a1dc-b160-85a0-347d-40a2ed6d007b@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cf790516
    • A
      ce6c9da1
    • I
      Merge tag 'perf-urgent-for-mingo-4.19-20181017' of... · 20e8e72d
      Ingo Molnar 提交于
      Merge tag 'perf-urgent-for-mingo-4.19-20181017' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
      - Stop falling back to kallsyms for vDSO symbols lookup, this wasn't
        being really used and is not valid in arches such as Sparc, where
        user and kernel space don't share the address space, relying only on
        cpumode to figure out what DSOs to lookup (Arnaldo Carvalho de Melo)
      
      - Align CPU map synthesized events properly, fixing SIGBUS in
        CPUs like Sparc (David Miller)
      
      - Fix use of alternatives to find JDIR (Jarod Wilson)
      
      - Store IDs for events with their own CPUs when synthesizing user
        level event details (scale, unit, etc) events, fixing a crash
        when recording a PMU event with a cpumask defined (Jiri Olsa)
      
      - Fix wrong filter_band* values for uncore Intel vendor events (Jiri Olsa)
      
      - Fix detection of tracefs path in systems without tracefs, where
        that path should be the debugfs mountpoint plus "/tracing/" (Jiri Olsa)
      
      - Pass build flags to traceevent build, allowing using alternative
        flags in distro packages, RPM, for instance (Jiri Olsa)
      
      - Fix 'perf report' crash on invalid inline debug information (Milian Wolff)
      
      - Synch KVM UAPI copies (Arnaldo Carvalho de Melo)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      20e8e72d
    • A
      perf tools: Stop fallbacking to kallsyms for vdso symbols lookup · edeb0c90
      Arnaldo Carvalho de Melo 提交于
      David reports that:
      
      <quote>
      Perf has this hack where it uses the kernel symbol map as a backup when
      a symbol can't be found in the user's symbol table(s).
      
      This causes problems because the tests driving this code path use
      machine__kernel_ip(), and that is completely meaningless on Sparc.  On
      sparc64 the kernel and user live in physically separate virtual address
      spaces, rather than a shared one.  And the kernel lives at a virtual
      address that overlaps common userspace addresses.  So this test passes
      almost all the time when a user symbol lookup fails.
      
      The consequence of this is that, if the unfound user virtual address in
      the sample doesn't match up to a kernel symbol either, we trigger things
      like this code in builtin-top.c:
      
      	if (al.sym == NULL && al.map != NULL) {
      		const char *msg = "Kernel samples will not be resolved.\n";
      		/*
      		 * As we do lazy loading of symtabs we only will know if the
      		 * specified vmlinux file is invalid when we actually have a
      		 * hit in kernel space and then try to load it. So if we get
      		 * here and there are _no_ symbols in the DSO backing the
      		 * kernel map, bail out.
      		 *
      		 * We may never get here, for instance, if we use -K/
      		 * --hide-kernel-symbols, even if the user specifies an
      		 * invalid --vmlinux ;-)
      		 */
      		if (!machine->kptr_restrict_warned && !top->vmlinux_warned &&
      		    __map__is_kernel(al.map) && map__has_symbols(al.map)) {
      			if (symbol_conf.vmlinux_name) {
      				char serr[256];
      				dso__strerror_load(al.map->dso, serr, sizeof(serr));
      				ui__warning("The %s file can't be used: %s\n%s",
      					    symbol_conf.vmlinux_name, serr, msg);
      			} else {
      				ui__warning("A vmlinux file was not found.\n%s",
      					    msg);
      			}
      
      			if (use_browser <= 0)
      				sleep(5);
      			top->vmlinux_warned = true;
      		}
      	}
      
      When I fire up a compilation on sparc, this triggers immediately.
      
      I'm trying to figure out what the "backup to kernel map" code is
      accomplishing.
      
      I see some language in the current code and in the changes that have
      happened in this area talking about vdso.  Does that really happen?
      
      The vdso is mapped into userspace virtual addresses, not kernel ones.
      
      More history.  This didn't cause problems on sparc some time ago,
      because the kernel IP check used to be "ip < 0" :-) Sparc kernel
      addresses are not negative.  But now with machine__kernel_ip(), which
      works using the symbol table determined kernel address range, it does
      trigger.
      
      What it all boils down to is that on architectures like sparc,
      machine__kernel_ip() should always return false in this scenerio, and
      therefore this kind of logic:
      
      		if (cpumode == PERF_RECORD_MISC_USER && machine &&
      		    mg != &machine->kmaps &&
      		    machine__kernel_ip(machine, al->addr)) {
      
      is basically invalid.  PERF_RECORD_MISC_USER implies no kernel address
      can possibly match for the sample/event in question (no matter how
      hard you try!) :-)
      </>
      
      So, I thought something had changed and in the past we would somehow
      find that address in the kallsyms, but I couldn't find anything to back
      that up, the patch introducing this is over a decade old, lots of things
      changed, so I was just thinking I was missing something.
      
      I tried a gtod busy loop to generate vdso activity and added a 'perf
      probe' at that branch, on x86_64 to see if it ever gets hit:
      
      Made thread__find_map() noinline, as 'perf probe' in lines of inline
      functions seems to not be working, only at function start. (Masami?)
      
        # perf probe -x ~/bin/perf -L thread__find_map:57
        <thread__find_map@/home/acme/git/perf/tools/perf/util/event.c:57>
           57                 if (cpumode == PERF_RECORD_MISC_USER && machine &&
           58                     mg != &machine->kmaps &&
           59                     machine__kernel_ip(machine, al->addr)) {
           60                         mg = &machine->kmaps;
           61                         load_map = true;
           62                         goto try_again;
                              }
                      } else {
                              /*
                               * Kernel maps might be changed when loading
                               * symbols so loading
                               * must be done prior to using kernel maps.
                               */
           69                 if (load_map)
           70                         map__load(al->map);
           71                 al->addr = al->map->map_ip(al->map, al->addr);
      
        # perf probe -x ~/bin/perf thread__find_map:60
        Added new event:
          probe_perf:thread__find_map (on thread__find_map:60 in /home/acme/bin/perf)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe_perf:thread__find_map -aR sleep 1
      
        #
      
        Then used this to see if, system wide, those probe points were being hit:
      
        # perf trace -e *perf:thread*/max-stack=8/
        ^C[root@jouet ~]#
      
        No hits when running 'perf top' and:
      
        # cat gtod.c
        #include <sys/time.h>
      
        int main(void)
        {
      	struct timeval tv;
      
      	while (1)
      		gettimeofday(&tv, 0);
      
      	return 0;
        }
        [root@jouet c]# ./gtod
        ^C
      
        Pressed 'P' in 'perf top' and the [vdso] samples are there:
      
        62.84%  [vdso]                    [.] __vdso_gettimeofday
         8.13%  gtod                      [.] main
         7.51%  [vdso]                    [.] 0x0000000000000914
         5.78%  [vdso]                    [.] 0x0000000000000917
         5.43%  gtod                      [.] _init
         2.71%  [vdso]                    [.] 0x000000000000092d
         0.35%  [kernel]                  [k] native_io_delay
         0.33%  libc-2.26.so              [.] __memmove_avx_unaligned_erms
         0.20%  [vdso]                    [.] 0x000000000000091d
         0.17%  [i2c_i801]                [k] i801_access
         0.06%  firefox                   [.] free
         0.06%  libglib-2.0.so.0.5400.3   [.] g_source_iter_next
         0.05%  [vdso]                    [.] 0x0000000000000919
         0.05%  libpthread-2.26.so        [.] __pthread_mutex_lock
         0.05%  libpixman-1.so.0.34.0     [.] 0x000000000006d3a7
         0.04%  [kernel]                  [k] entry_SYSCALL_64_trampoline
         0.04%  libxul.so                 [.] style::dom_apis::query_selector_slow
         0.04%  [kernel]                  [k] module_get_kallsym
         0.04%  firefox                   [.] malloc
         0.04%  [vdso]                    [.] 0x0000000000000910
      
        I added a 'perf probe' to thread__find_map:69, and that surely got tons
        of hits, i.e. for every map found, just to make sure the 'perf probe'
        command was really working.
      
        In the process I noticed a bug, we're only have records for '[vdso]' for
        pre-existing commands, i.e. ones that are running when we start 'perf top',
        when we will generate the PERF_RECORD_MMAP by looking at /perf/PID/maps.
      
        I.e. like this, for preexisting processes with a vdso map, again,
        tracing for all the system, only pre-existing processes get a [vdso] map
        (when having one):
      
        [root@jouet ~]# perf probe -x ~/bin/perf __machine__addnew_vdso
        Added new event:
        probe_perf:__machine__addnew_vdso (on __machine__addnew_vdso in /home/acme/bin/perf)
      
        You can now use it in all perf tools, such as:
      
      	perf record -e probe_perf:__machine__addnew_vdso -aR sleep 1
      
        [root@jouet ~]# perf trace -e probe_perf:__machine__addnew_vdso/max-stack=8/
           0.000 probe_perf:__machine__addnew_vdso:(568eb3)
                                             __machine__addnew_vdso (/home/acme/bin/perf)
                                             map__new (/home/acme/bin/perf)
                                             machine__process_mmap2_event (/home/acme/bin/perf)
                                             machine__process_event (/home/acme/bin/perf)
                                             perf_event__process (/home/acme/bin/perf)
                                             perf_tool__process_synth_event (/home/acme/bin/perf)
                                             perf_event__synthesize_mmap_events (/home/acme/bin/perf)
                                             __event__synthesize_thread (/home/acme/bin/perf)
      
      The kernel is generating a PERF_RECORD_MMAP for vDSOs, but somehow
      'perf top' is not getting those records while 'perf record' is:
      
        # perf record ~acme/c/gtod
        ^C[ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.076 MB perf.data (1499 samples) ]
      
        # perf report -D | grep PERF_RECORD_MMAP2
        71293612401913 0x11b48 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x400000(0x1000) @ 0 fd:02 1137 541179306]: r-xp /home/acme/c/gtod
        71293612419012 0x11be0 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x7fa4a2783000(0x227000) @ 0 fd:00 3146370 854107250]: r-xp /usr/lib64/ld-2.26.so
        71293612432110 0x11c50 [0x60]: PERF_RECORD_MMAP2 25484/25484: [0x7ffcdb53a000(0x2000) @ 0 00:00 0 0]: r-xp [vdso]
        71293612509944 0x11cb0 [0x70]: PERF_RECORD_MMAP2 25484/25484: [0x7fa4a23cd000(0x3b6000) @ 0 fd:00 3149723 262067164]: r-xp /usr/lib64/libc-2.26.so
        #
        # perf script | grep vdso | head
            gtod 25484 71293.612768: 2485554 cycles:ppp:  7ffcdb53a914 [unknown] ([vdso])
            gtod 25484 71293.613576: 2149343 cycles:ppp:  7ffcdb53a917 [unknown] ([vdso])
            gtod 25484 71293.614274: 1814652 cycles:ppp:  7ffcdb53aca8 __vdso_gettimeofday+0x98 ([vdso])
            gtod 25484 71293.614862: 1669070 cycles:ppp:  7ffcdb53acc5 __vdso_gettimeofday+0xb5 ([vdso])
            gtod 25484 71293.615404: 1451589 cycles:ppp:  7ffcdb53acc5 __vdso_gettimeofday+0xb5 ([vdso])
            gtod 25484 71293.615999: 1269941 cycles:ppp:  7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
            gtod 25484 71293.616405: 1177946 cycles:ppp:  7ffcdb53a914 [unknown] ([vdso])
            gtod 25484 71293.616775: 1121290 cycles:ppp:  7ffcdb53ac47 __vdso_gettimeofday+0x37 ([vdso])
            gtod 25484 71293.617150: 1037721 cycles:ppp:  7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
            gtod 25484 71293.617478:  994526 cycles:ppp:  7ffcdb53ace6 __vdso_gettimeofday+0xd6 ([vdso])
        #
      
      The patch is the obvious one and with it we also continue to resolve
      vdso symbols for pre-existing processes in 'perf top' and for all
      processes in 'perf record' + 'perf report/script'.
      Suggested-by: NDavid Miller <davem@davemloft.net>
      Acked-by: NDavid Miller <davem@davemloft.net>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-cs7skq9pp0kjypiju6o7trse@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      edeb0c90
  4. 17 10月, 2018 4 次提交
    • J
      perf tools: Pass build flags to traceevent build · 298faf53
      Jiri Olsa 提交于
      So the extra user build flags are propagated to libtraceevent.
      Signed-off-by: NJiri Olsa <jolsa@kernel.org>
      Cc: "Herton R. Krzesinski" <herton@redhat.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
      Cc: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
      Link: http://lkml.kernel.org/r/20181016150614.21260-3-jolsa@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      298faf53
    • M
      perf report: Don't crash on invalid inline debug information · d4046e8e
      Milian Wolff 提交于
      When the function name for an inline frame is invalid, we must not try
      to demangle this symbol, otherwise we crash with:
      
        #0  0x0000555555895c01 in bfd_demangle ()
        #1  0x0000555555823262 in demangle_sym (dso=0x555555d92b90, elf_name=0x0, kmodule=0) at util/symbol-elf.c:215
        #2  dso__demangle_sym (dso=dso@entry=0x555555d92b90, kmodule=<optimized out>, kmodule@entry=0, elf_name=elf_name@entry=0x0) at util/symbol-elf.c:400
        #3  0x00005555557fef4b in new_inline_sym (funcname=0x0, base_sym=0x555555d92b90, dso=0x555555d92b90) at util/srcline.c:89
        #4  inline_list__append_dso_a2l (dso=dso@entry=0x555555c7bb00, node=node@entry=0x555555e31810, sym=sym@entry=0x555555d92b90) at util/srcline.c:264
        #5  0x00005555557ff27f in addr2line (dso_name=dso_name@entry=0x555555d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf", addr=addr@entry=2888, file=file@entry=0x0,
            line=line@entry=0x0, dso=dso@entry=0x555555c7bb00, unwind_inlines=unwind_inlines@entry=true, node=0x555555e31810, sym=0x555555d92b90) at util/srcline.c:313
        #6  0x00005555557ffe7c in addr2inlines (sym=0x555555d92b90, dso=0x555555c7bb00, addr=2888, dso_name=0x555555d92430 "/home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf")
            at util/srcline.c:358
      
      So instead handle the case where we get invalid function names for
      inlined frames and use a fallback '??' function name instead.
      
      While this crash was originally reported by Hadrien for rust code, I can
      now also reproduce it with trivial C++ code. Indeed, it seems like
      libbfd fails to interpret the debug information for the inline frame
      symbol name:
      
        $ addr2line -e /home/milian/.debug/.build-id/f7/186d14bb94f3c6161c010926da66033d24fce5/elf -if b48
        main
        /usr/include/c++/8.2.1/complex:610
        ??
        /usr/include/c++/8.2.1/complex:618
        ??
        /usr/include/c++/8.2.1/complex:675
        ??
        /usr/include/c++/8.2.1/complex:685
        main
        /home/milian/projects/kdab/rnd/hotspot/tests/test-clients/cpp-inlining/main.cpp:39
      
      I've reported this bug upstream and also attached a patch there which
      should fix this issue:
      
      https://sourceware.org/bugzilla/show_bug.cgi?id=23715Reported-by: NHadrien Grasland <grasland@lal.in2p3.fr>
      Signed-off-by: NMilian Wolff <milian.wolff@kdab.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Fixes: a64489c5 ("perf report: Find the inline stack for a given address")
      [ The above 'Fixes:' cset is where originally the problem was
        introduced, i.e.  using a2l->funcname without checking if it is NULL,
        but this current patch fixes the current codebase, i.e. multiple csets
        were applied after a64489c5 before the problem was reported by Hadrien ]
      Link: http://lkml.kernel.org/r/20180926135207.30263-3-milian.wolff@kdab.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d4046e8e
    • G
      Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc · b955a910
      Greg Kroah-Hartman 提交于
      David writes:
        "Sparc fixes
      
         1) Revert the %pOF change, it causes regressions.
      
         2) Wire up io_pgetevents().
      
         3) Fix perf events on single-PCR sparc64 cpus.
      
         4) Do proper perf event throttling like arm and x86."
      
      * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc:
        Revert "sparc: Convert to using %pOFn instead of device_node.name"
        sparc64: Set %l4 properly on trap return after handling signals.
        sparc64: Make proc_id signed.
        sparc: Throttle perf events properly.
        sparc: Fix single-pcr perf event counter management.
        sparc: Wire up io_pgetevents system call.
        sunvdc: Remove VLA usage
      b955a910
    • G
      Merge tag 'selinux-pr-20181015' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux · a8861998
      Greg Kroah-Hartman 提交于
      Paul writes:
        "SELinux fixes for v4.19
      
         We've got one SELinux "fix" that I'd like to get into v4.19 if
         possible.  I'm using double quotes on "fix" as this is just an update
         to the MAINTAINERS file and not a code change.  From my perspective,
         MAINTAINERS updates generally don't warrant inclusion during the -rcX
         phase, but this is a change to the mailing list location so it seemed
         prudent to get this in before v4.19 is released"
      
      * tag 'selinux-pr-20181015' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/selinux:
        MAINTAINERS: update the SELinux mailing list location
      a8861998
  5. 16 10月, 2018 6 次提交
  6. 15 10月, 2018 4 次提交
    • D
      afs: Fix clearance of reply · f0a7d188
      David Howells 提交于
      The recent patch to fix the afs_server struct leak didn't actually fix the
      bug, but rather fixed some of the symptoms.  The problem is that an
      asynchronous call that holds a resource pointed to by call->reply[0] will
      find the pointer cleared in the call destructor, thereby preventing the
      resource from being cleaned up.
      
      In the case of the server record leak, the afs_fs_get_capabilities()
      function in devel code sets up a call with reply[0] pointing at the server
      record that should be altered when the result is obtained, but this was
      being cleared before the destructor was called, so the put in the
      destructor does nothing and the record is leaked.
      
      Commit f014ffb0 removed the additional ref obtained by
      afs_install_server(), but the removal of this ref is actually used by the
      garbage collector to mark a server record as being defunct after the record
      has expired through lack of use.
      
      The offending clearance of call->reply[0] upon completion in
      afs_process_async_call() has been there from the origin of the code, but
      none of the asynchronous calls actually use that pointer currently, so it
      should be safe to remove (note that synchronous calls don't involve this
      function).
      
      Fix this by the following means:
      
       (1) Revert commit f014ffb0.
      
       (2) Remove the clearance of reply[0] from afs_process_async_call().
      
      Without this, afs_manage_servers() will suffer an assertion failure if it
      sees a server record that didn't get used because the usage count is not 1.
      
      Fixes: f014ffb0 ("afs: Fix afs_server struct leak")
      Fixes: 08e0e7c8 ("[AF_RXRPC]: Make the in-kernel AFS filesystem use AF_RXRPC.")
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      f0a7d188
    • G
      Linux 4.19-rc8 · 35a7f35a
      Greg Kroah-Hartman 提交于
      35a7f35a
    • D
      sparc64: Set %l4 properly on trap return after handling signals. · d1f1f98c
      David S. Miller 提交于
      If we did some signal processing, we have to reload the pt_regs
      tstate register because it's value may have changed.
      
      In doing so we also have to extract the %pil value contained in there
      anre load that into %l4.
      
      This value is at bit 20 and thus needs to be shifted down before we
      later write it into the %pil register.
      
      Most of the time this is harmless as we are returning to userspace
      and the %pil is zero for that case.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      d1f1f98c
    • D
      sparc64: Make proc_id signed. · b3e1eb8e
      David S. Miller 提交于
      So that when it is unset, ie. '-1', userspace can see it
      properly.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      b3e1eb8e
  7. 14 10月, 2018 2 次提交
  8. 13 10月, 2018 13 次提交