1. 26 11月, 2019 6 次提交
  2. 22 11月, 2019 15 次提交
  3. 21 11月, 2019 1 次提交
  4. 20 11月, 2019 8 次提交
  5. 19 11月, 2019 10 次提交
    • I
      perf parse: Report initial event parsing error · a910e466
      Ian Rogers 提交于
      Record the first event parsing error and report. Implementing feedback
      from Jiri Olsa:
      
        https://lkml.org/lkml/2019/10/28/680
      
      An example error is:
      
        $ tools/perf/perf stat -e c/c/
        WARNING: multiple event parsing errors
        event syntax error: 'c/c/'
                               \___ unknown term
      
        valid terms: event,filter_rem,filter_opc0,edge,filter_isoc,filter_tid,filter_loc,filter_nc,inv,umask,filter_opc1,tid_en,thresh,filter_all_op,filter_not_nm,filter_state,filter_nm,config,config1,config2,name,period,percore
      
      Initial error:
      
        event syntax error: 'c/c/'
                            \___ Cannot find PMU `c'. Missing kernel support?
        Run 'perf list' for a list of valid events
      
         Usage: perf stat [<options>] [<command>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Allison Randal <allison@lohutok.net>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20191116074652.9960-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a910e466
    • M
      perf probe: Trace a magic number if variable is not found · cb402730
      Masami Hiramatsu 提交于
      Trace a magic number as immediate value if the target variable is not
      found at some probe points which is based on one probe event.
      
      This feature is good for the case if you trace a source code line with
      some local variables, which is compiled into several instructions and
      some of the variables are optimized out on some instructions.
      
      Even if so, with this feature, perf probe trace a magic number instead
      of such disappeared variables and fold those probes on one event.
      
      E.g. without this patch:
      
        # perf probe -D "pud_page_vaddr pud"
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        Failed to find 'pud' in this function.
        p:probe/pud_page_vaddr _text+23480787 pud=%ax:x64
        p:probe/pud_page_vaddr _text+23808453 pud=%bp:x64
        p:probe/pud_page_vaddr _text+23558082 pud=%ax:x64
        p:probe/pud_page_vaddr _text+328373 pud=%r8:x64
        p:probe/pud_page_vaddr _text+348448 pud=%bx:x64
        p:probe/pud_page_vaddr _text+23816818 pud=%bx:x64
      
      With this patch:
      
        # perf probe -D "pud_page_vaddr pud" | head
        spurious_kernel_fault is blacklisted function, skip it.
        vmalloc_fault is blacklisted function, skip it.
        p:probe/pud_page_vaddr _text+23480787 pud=%ax:x64
        p:probe/pud_page_vaddr _text+149051 pud=\deade12d:x64
        p:probe/pud_page_vaddr _text+23808453 pud=%bp:x64
        p:probe/pud_page_vaddr _text+315926 pud=\deade12d:x64
        p:probe/pud_page_vaddr _text+23807209 pud=\deade12d:x64
        p:probe/pud_page_vaddr _text+23557365 pud=%ax:x64
        p:probe/pud_page_vaddr _text+314097 pud=%di:x64
        p:probe/pud_page_vaddr _text+314015 pud=\deade12d:x64
        p:probe/pud_page_vaddr _text+313893 pud=\deade12d:x64
        p:probe/pud_page_vaddr _text+324083 pud=\deade12d:x64
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406476931.24476.6261475888681844285.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cb402730
    • M
      perf probe: Support DW_AT_const_value constant value · 66f69b21
      Masami Hiramatsu 提交于
      Support DW_AT_const_value for variable assignment instead of location.
      Note that this requires ftrace supporting immediate value.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406476012.24476.16096289871757175775.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      66f69b21
    • M
      perf probe: Support multiprobe event · 72363540
      Masami Hiramatsu 提交于
      Support multiprobe event if the event is based on function and lines and
      kernel supports it. In this case, perf probe creates the first probe
      with an event, and tries to append following probes on that event, since
      those probes must be on the same source code line.
      
      Before this patch;
      
        # perf probe -a vfs_read:18
        Added new events:
          probe:vfs_read_L18   (on vfs_read:18)
          probe:vfs_read_L18_1 (on vfs_read:18)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:vfs_read_L18_1 -aR sleep 1
      
        #
      
      After this patch (on multiprobe supported kernel)
        # perf probe -a vfs_read:18
        Added new events:
          probe:vfs_read_L18   (on vfs_read:18)
          probe:vfs_read_L18   (on vfs_read:18)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:vfs_read_L18 -aR sleep 1
      
        #
      
      Committer testing:
      
      On a kernel that doesn't support multiprobe events, after this patch:
      
        # uname -a
        Linux quaco 5.3.8-200.fc30.x86_64 #1 SMP Tue Oct 29 14:46:22 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
        # grep append /sys/kernel/debug/tracing/README
        	    be modified by appending '.descending' or '.ascending' to a
        	    can be modified by appending any of the following modifiers
        #
        # perf probe -a vfs_read:18
        Added new events:
          probe:vfs_read_L18   (on vfs_read:18)
          probe:vfs_read_L18_1 (on vfs_read:18)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:vfs_read_L18_1 -aR sleep 1
      
        # perf probe -l
          probe:vfs_read_L18   (on vfs_read:18@fs/read_write.c)
          probe:vfs_read_L18_1 (on vfs_read:18@fs/read_write.c)
        #
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406475010.24476.586290752591512351.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      72363540
    • M
      perf probe: Generate event name with line number · 15354d54
      Masami Hiramatsu 提交于
      Generate event name from function name with line number as
      <function>_L<line_number>. Note that this is only for the new event
      which is defined by the line number of function (except for line 0).
      
      If there is another event on same line, you have to use
      "-f" option. In that case, the new event has "_1" suffix.
      
       e.g.
        # perf probe -a kernel_read:2
        Added new event:
          probe:kernel_read_L2 (on kernel_read:2)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:kernel_read_L2 -aR sleep 1
      
      But if we omit the line number or 0th line, it will
      have no suffix.
      
        # perf probe -a kernel_read:0
        Added new event:
          probe:kernel_read (on kernel_read)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:kernel_read -aR sleep 1
      
        probe:kernel_read    (on kernel_read@linux-5.0.0/fs/read_write.c)
        probe:kernel_read_L2 (on kernel_read:2@linux-5.0.0/fs/read_write.c)
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406474026.24476.2828897745502059569.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      15354d54
    • M
      perf probe: Do not show non representive lines by perf-probe -L · 499144c8
      Masami Hiramatsu 提交于
      Since perf probe -L shows non representive lines, it can be mislead
      users where user can put probes.  This prevents to show such non
      representive lines so that user can understand which lines user can
      probe.
      
        # perf probe -L kernel_read
        <kernel_read@/build/linux-pvZVvI/linux-5.0.0/fs/read_write.c:0>
              0  ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
                 {
              2         mm_segment_t old_fs;
                        ssize_t result;
      
                        old_fs = get_fs();
              6         set_fs(get_ds());
                        /* The cast to a user pointer is valid due to the set_fs() */
              8         result = vfs_read(file, (void __user *)buf, count, pos);
              9         set_fs(old_fs);
             10         return result;
                 }
                 EXPORT_SYMBOL(kernel_read);
      
      Committer testing:
      
      Before:
      
        # perf probe -L kernel_read
        <kernel_read@/usr/src/debug/kernel-5.3.fc30/linux-5.3.8-200.fc30.x86_64/fs/read_write.c:0>
              0  ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
              1  {
              2         mm_segment_t old_fs;
              3         ssize_t result;
      
              5         old_fs = get_fs();
              6         set_fs(KERNEL_DS);
                        /* The cast to a user pointer is valid due to the set_fs() */
              8         result = vfs_read(file, (void __user *)buf, count, pos);
              9         set_fs(old_fs);
             10         return result;
                 }
                 EXPORT_SYMBOL(kernel_read);
        #
      
      See the 1, 3, 5 lines? They shouldn't be there, after this patch:
      
        # perf probe -L kernel_read
        <kernel_read@/usr/src/debug/kernel-5.3.fc30/linux-5.3.8-200.fc30.x86_64/fs/read_write.c:0>
              0  ssize_t kernel_read(struct file *file, void *buf, size_t count, loff_t *pos)
                 {
              2         mm_segment_t old_fs;
                        ssize_t result;
      
                        old_fs = get_fs();
              6         set_fs(KERNEL_DS);
                        /* The cast to a user pointer is valid due to the set_fs() */
              8         result = vfs_read(file, (void __user *)buf, count, pos);
              9         set_fs(old_fs);
             10         return result;
                 }
                 EXPORT_SYMBOL(kernel_read);
        #
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406473064.24476.2913278267727587314.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      499144c8
    • M
      perf probe: Verify given line is a representive line · 1ae5d88a
      Masami Hiramatsu 提交于
      Verify user given probe line is a representive line (which doesn't share
      the address with other lines or the line is the least line among the
      lines which shares same address), and if not, it shows what is the
      representive line.
      
      Without this fix, user can put a probe on the lines which is not a a
      representive line. But since this is not a representive line, perf probe
      -l shows a representive line number instead of user given line number.
      e.g. (put kernel_read:3, but listed as kernel_read:2)
      
        # perf probe -a kernel_read:3
        Added new event:
          probe:kernel_read    (on kernel_read:3)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:kernel_read -aR sleep 1
      
        # perf probe -l
          probe:kernel_read    (on kernel_read:2@linux-5.0.0/fs/read_write.c)
      
      With this fix, perf probe doesn't allow user to put a probe on a
      representive line, and tell what is the representive line.
      
        # perf probe -a kernel_read:3
        This line is sharing the addrees with other lines.
        Please try to probe at kernel_read:2 instead.
          Error: Failed to add events.
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406472071.24476.14915451439785001021.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1ae5d88a
    • M
      perf probe: Show correct statement line number by perf probe -l · 57f95bf5
      Masami Hiramatsu 提交于
      The dwarf_getsrc_die() can return the line which is not a statement nor
      the least line number among the lines which shares same address.
      
      This can lead perf probe --list shows incorrect line number for probed
      address.
      
      To fix this, this introduces cu_getsrc_die() which returns only a
      statement line and which is the least line number (we call it the
      representive line for an address), and use it in cu_find_lineinfo().
      
      Also, if the given address is the entry address of a real function,
      cu_find_lineinfo() returns the function declared line number instead of
      the start line number of the function body.
      
      For example, without this change perf probe -l shows incorrect line as
      below.
      
        # perf probe -a kernel_read:2
        Added new event:
          probe:kernel_read    (on kernel_read:2)
      
        You can now use it in all perf tools, such as:
      
        	perf record -e probe:kernel_read -aR sleep 1
      
        # perf probe -l
          probe:kernel_read    (on kernel_read:1@linux-5.0.0/fs/read_write.c)
      
      With this fix, it shows correct line number as below;
      
        # perf probe -l
          probe:kernel_read    (on kernel_read:2@linux-5.0.0/fs/read_write.c)
      Reported-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
      Cc: Tom Zanussi <tom.zanussi@linux.intel.com>
      Link: http://lore.kernel.org/lkml/157406471067.24476.17463149618465494448.stgit@devnote2Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      57f95bf5
    • A
      x86/insn: perf tools: Add some instructions to the new instructions test · 1e5f0154
      Adrian Hunter 提交于
      Add to the "x86 instruction decoder - new instructions" test the following
      instructions:
      	cldemote
      	tpause
      	umonitor
      	umwait
      	movdiri
      	movdir64b
      	enqcmd
      	enqcmds
      	encls
      	enclu
      	enclv
      	pconfig
      	wbnoinvd
      
      For information about the instructions, refer Intel SDM May 2019
      (325462-070US) and Intel Architecture Instruction Set Extensions
      May 2019 (319433-037).
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Reviewed-by: NAndi Kleen <ak@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: x86@kernel.org
      Link: http://lore.kernel.org/lkml/20191115135447.6519-2-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1e5f0154
    • A
      perf map: Move seldom used ->flags field to second cacheline · 7624e694
      Arnaldo Carvalho de Melo 提交于
      So we start with:
      
        $ pahole -C map ~/bin/perf
        struct map {
        	union {
        		struct rb_node rb_node __attribute__((__aligned__(8))); /*     0    24 */
        		struct list_head node;                   /*     0    16 */
        	} __attribute__((__aligned__(8)));                                               /*     0    24 */
        	u64                        start;                /*    24     8 */
        	u64                        end;                  /*    32     8 */
        	_Bool                      erange_warned:1;      /*    40: 0  1 */
        	_Bool                      priv:1;               /*    40: 1  1 */
      
        	/* XXX 6 bits hole, try to pack */
        	/* XXX 3 bytes hole, try to pack */
      
        	u32                        prot;                 /*    44     4 */
        	u32                        flags;                /*    48     4 */
      
        	/* XXX 4 bytes hole, try to pack */
      
        	u64                        pgoff;                /*    56     8 */
        	/* --- cacheline 1 boundary (64 bytes) --- */
        	u64                        reloc;                /*    64     8 */
        	u32                        maj;                  /*    72     4 */
        	u32                        min;                  /*    76     4 */
        	u64                        ino;                  /*    80     8 */
        	u64                        ino_generation;       /*    88     8 */
        	u64                        (*map_ip)(struct map *, u64); /*    96     8 */
        	u64                        (*unmap_ip)(struct map *, u64); /*   104     8 */
        	struct dso *               dso;                  /*   112     8 */
        	refcount_t                 refcnt;               /*   120     4 */
      
        	/* size: 128, cachelines: 2, members: 17 */
        	/* sum members: 116, holes: 2, sum holes: 7 */
        	/* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 6 bits */
        	/* padding: 4 */
        	/* forced alignments: 1 */
        } __attribute__((__aligned__(8)));
        $
      
      and 'flags' is seldom used when printing details about the map or with
      the "cacheline" sort order, we can move them it to the second cacheline,
      that will allow combining it with 'refcnt', that is only four bytes:
      
        $ pahole -C map ~/bin/perf
        struct map {
        	union {
        		struct rb_node rb_node __attribute__((__aligned__(8))); /*     0    24 */
        		struct list_head node;                   /*     0    16 */
        	} __attribute__((__aligned__(8)));                                               /*     0    24 */
        	u64                        start;                /*    24     8 */
        	u64                        end;                  /*    32     8 */
        	_Bool                      erange_warned:1;      /*    40: 0  1 */
        	_Bool                      priv:1;               /*    40: 1  1 */
      
        	/* XXX 6 bits hole, try to pack */
        	/* XXX 3 bytes hole, try to pack */
      
        	u32                        prot;                 /*    44     4 */
        	u64                        pgoff;                /*    48     8 */
        	u64                        reloc;                /*    56     8 */
        	/* --- cacheline 1 boundary (64 bytes) --- */
        	u32                        maj;                  /*    64     4 */
        	u32                        min;                  /*    68     4 */
        	u64                        ino;                  /*    72     8 */
        	u64                        ino_generation;       /*    80     8 */
        	u64                        (*map_ip)(struct map *, u64); /*    88     8 */
        	u64                        (*unmap_ip)(struct map *, u64); /*    96     8 */
        	struct dso *               dso;                  /*   104     8 */
        	refcount_t                 refcnt;               /*   112     4 */
        	u32                        flags;                /*   116     4 */
      
        	/* size: 120, cachelines: 2, members: 17 */
        	/* sum members: 116, holes: 1, sum holes: 3 */
        	/* sum bitfield members: 2 bits, bit holes: 1, sum bit holes: 6 bits */
        	/* forced alignments: 1 */
        	/* last cacheline: 56 bytes */
        } __attribute__((__aligned__(8)));
        $
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-2cdw3zlw1mkamaf7nqtdlxfi@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7624e694