Skip to content
  1. Apr 05, 2017
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.12-20170404' of... · 11e445e9
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-4.12-20170404' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      User visible changes:
      
      - Add missing number of samples in 'perf annotate --stdio -l --show-total-period'
        (Taeung Song)
      
      Vendor events updates:
      
      - Add uncore_arb Intel vendor events in JSON format (Andi Kleen)
      
      - Add uncore vendor events for Intel's Sandy Bridge, Ivy Bridge,
        Haswell, Broadwell and Skylake architectures (Andi Kleen)
      
      - Add missing UNC_M_DCLOCKTICKS Intel Broadwell DE uncore vendor event (Andi Kleen)
      
      Infrastructure changes:
      
      - Remove some more die() calls, avoiding sudden death in library code
        (Arnaldo Carvalho de Melo)
      
      - Add argument support for SDT events in powerpc (Ravi Bangoria)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      11e445e9
    • Taeung Song's avatar
      perf annotate: Fix missing number of samples for source_line_samples · 99094a5e
      Taeung Song authored
      
      
      The option 'show-total-period' works fine without a option '-l'.  But if
      running 'perf annotate --stdio -l --show-total-period', you can see a
      problem showing only zero '0' for number of samples.
      
      Before:
          $ perf annotate --stdio -l --show-total-period
      ...
             0 :        400816:       push   %rbp
             0 :        400817:       mov    %rsp,%rbp
             0 :        40081a:       mov    %edi,-0x24(%rbp)
             0 :        40081d:       mov    %rsi,-0x30(%rbp)
             0 :        400821:       mov    -0x24(%rbp),%eax
             0 :        400824:       mov    -0x30(%rbp),%rdx
             0 :        400828:       mov    (%rdx),%esi
             0 :        40082a:       mov    $0x0,%edx
      ...
      
      The reason is it was missed to set number of samples of
      source_line_samples, so set it ordinarily.
      
      After:
          $ perf annotate --stdio -l --show-total-period
      ...
             3 :        400816:       push   %rbp
             4 :        400817:       mov    %rsp,%rbp
             0 :        40081a:       mov    %edi,-0x24(%rbp)
             0 :        40081d:       mov    %rsi,-0x30(%rbp)
             1 :        400821:       mov    -0x24(%rbp),%eax
             2 :        400824:       mov    -0x30(%rbp),%rdx
             0 :        400828:       mov    (%rdx),%esi
             1 :        40082a:       mov    $0x0,%edx
      ...
      
      Signed-off-by: default avatarTaeung Song <treeze.taeung@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liska <mliska@suse.cz>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 0c4a5bce
      
       ("perf annotate: Display total number of samples with --show-total-period")
      Link: http://lkml.kernel.org/r/1490703125-13643-1-git-send-email-treeze.taeung@gmail.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      99094a5e
  2. Apr 04, 2017
  3. Apr 01, 2017
    • Ingo Molnar's avatar
      Merge tag 'perf-core-for-mingo-4.12-20170331' of... · fcc309e6
      Ingo Molnar authored
      
      Merge tag 'perf-core-for-mingo-4.12-20170331' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core
      
      Pull perf/core improvements and fixes from Arnaldo Carvalho de Melo:
      
      New features:
      
      - Beautify the statx syscall arguments in 'perf trace' (Arnaldo Carvalho de Melo)
      
          e.g.:
      
        System wide strace like session:
      
        # trace -e statx
         16612.967 ( 0.028 ms): statx/4562 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffef195d660) = 0
         36050.891 ( 0.007 ms): statx/4576 statx(dfd: CWD, filename: /etc/passwd, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffda9bf50f0) = 0
        ^C#
      
      User visible changes:
      
      - Handle unpaired raw_syscalls:sys_exit events in 'perf trace', i.e. we
        shouldn't try to calculate duration or print the timestamp for a missing
        matching raw_syscalls:sys_enter (Arnaldo Carvalho de Melo)
      
      - Do not print "cycles: 0" in perf report LBR lines in platforms not
        supporting 'cycles', such as Intel's Broadwell (Jin Yao)
      
      - Handle missing $HOME env var (Jiri Olsa)
      
      - Map 8-bit registers (al, bl, etc), not supported in uprobes_events, to
        the next best thing (ax, bx, etc) supported (Ravi Bangoria)
      
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      fcc309e6
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Beautify statx syscall 'flag' and 'mask' arguments · fd5cead2
      Arnaldo Carvalho de Melo authored
      
      
      To test it, build samples/statx/test_statx, which I did as:
      
        $ make headers_install
        $ cc -I ~/git/linux/usr/include samples/statx/test-statx.c -o /tmp/statx
      
      And then use perf trace on it:
      
        # perf trace -e statx /tmp/statx /etc/passwd
        statx(/etc/passwd) = 0
        results=7ff
          Size: 3496            Blocks: 8          IO Block: 4096    regular file
        Device: fd:00           Inode: 280156      Links: 1
        Access: (0644/-rw-r--r--)  Uid:     0   Gid:     0
        Access: 2017-03-29 16:01:01.650073438-0300
        Modify: 2017-03-10 16:25:14.156479354-0300
        Change: 2017-03-10 16:25:14.171479328-0300
           0.000 ( 0.007 ms): statx/30648 statx(dfd: CWD, filename: 0x7ef503f4, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff7ef4eb10) = 0
        #
      
      Using the test-stat.c options to change the mask:
      
        # perf trace -e statx /tmp/statx -O /etc/passwd > /dev/null
           0.000 ( 0.008 ms): statx/30745 statx(dfd: CWD, filename: 0x3a0753f4, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffd3a0735c0) = 0
        #
        # perf trace -e statx /tmp/statx -A /etc/passwd > /dev/null
           0.000 ( 0.010 ms): statx/30757 statx(dfd: CWD, filename: 0xa94e63f4, flags: SYMLINK_NOFOLLOW|NO_AUTOMOUNT, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffea94e49d0) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -F /etc/passwd > /dev/null
           0.000 ( 0.011 ms): statx(dfd: CWD, filename: 0x3b02d3f3, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffd3b02c850) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -F -L /etc/passwd > /dev/null
           0.000 ( 0.008 ms): statx(dfd: CWD, filename: 0x15cff3f3, flags: STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff15cfdda0) = 0
        #
        # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
           0.000 ( 0.009 ms): statx(dfd: CWD, filename: 0xfa37f3f3, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffffa37da20) = 0
        #
      
      Adding a probe to get the filename collected as well:
      
        # perf probe 'vfs_getname=getname_flags:72 pathname=result->name:string'
        Added new event:
          probe:vfs_getname    (on getname_flags:72 with pathname=result->name:string)
      
        You can now use it in all perf tools, such as:
      
      	  perf record -e probe:vfs_getname -aR sleep 1
      
        # trace --no-inherit -e statx /tmp/statx -D -O /etc/passwd > /dev/null
           0.169 ( 0.007 ms): statx(dfd: CWD, filename: /etc/passwd, flags: SYMLINK_NOFOLLOW|STATX_DONT_SYNC, mask: BTIME, buffer: 0x7ffda9bf50f0) = 0
        #
      
      Same technique could be used to collect and beautify the result put in
      the 'buffer' argument.
      
      Finally do a system wide 'perf trace' session looking for any use of statx,
      then run the test proggie with various flags:
      
        # trace -e statx
         16612.967 ( 0.028 ms): statx/4562 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffef195d660) = 0
         33064.447 ( 0.011 ms): statx/4569 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW|STATX_FORCE_SYNC, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7ffc5484c790) = 0
         36050.891 ( 0.023 ms): statx/4576 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: BTIME, buffer: 0x7ffeb18b66e0) = 0
         38039.889 ( 0.023 ms): statx/4584 statx(dfd: CWD, filename: /tmp/statx, flags: SYMLINK_NOFOLLOW, mask: TYPE|MODE|NLINK|UID|GID|ATIME|MTIME|CTIME|INO|SIZE|BLOCKS|BTIME, buffer: 0x7fff1db0ea90) = 0
        ^C#
      
      This one also starts moving the beautifiers from files directly included
      in builtin-trace.c to separate objects + a beauty.h header with
      prototypes, so that we can add test cases in tools/perf/tests/ to fire
      syscalls with various arguments and then get them intercepted as
      syscalls:sys_enter_foo or raw_syscalls:sys_enter + sys_exit to then
      format and check that the formatted output is the one we expect.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-xvzw8eynffvez5czyzidhrno@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fd5cead2
  4. Mar 31, 2017
  5. Mar 30, 2017
    • Colin Ian King's avatar
      perf utils: Fix spelling mistake: "Invalud" -> "Invalid" · a596a877
      Colin Ian King authored
      
      
      Trivial fix to spelling mistake in pr_debug message.
      
      Signed-off-by: default avatarColin King <colin.king@canonical.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Krister Johansen <kjlx@templeofstupid.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: kernel-janitors@vger.kernel.org
      Link: http://lkml.kernel.org/r/20170330095440.19444-1-colin.king@canonical.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      a596a877
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Enable support for multiple IOMMUs · 25df39f2
      Suravee Suthikulpanit authored
      
      
      Add support for multiple IOMMUs to perf by exposing an AMD IOMMU PMU for
      each IOMMU found in the system via:
      
        /bus/event_source/devices/amd_iommu_x
      
      where x is the IOMMU index. This allows users to specify different
      events to be programmed into the performance counters of each IOMMU.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      [ Improve readability, shorten names. ]
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1490166162-10002-11-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      25df39f2
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Add IOMMU-specific hw_perf_event struct · cf25f904
      Suravee Suthikulpanit authored
      
      
      Current AMD IOMMU perf PMU inappropriately uses the hardware struct
      inside the union in struct hw_perf_event, extra_reg in particular.
      
      Instead, introduce an AMD IOMMU-specific struct with required parameters
      to be programmed into the IOMMU performance counter control register.
      
      Update the pasid field from 16 to 20 bits while at it.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      [ Fixup macros, shorten get_next_avail_iommu_bnk_cntr() local vars, massage commit message. ]
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-10-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      cf25f904
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Fix sysfs perf attribute groups · 51686546
      Suravee Suthikulpanit authored
      
      
      Introduce static amd_iommu_attr_groups to simplify the
      sysfs attributes initialization code.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-9-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      51686546
    • Suravee Suthikulpanit's avatar
      x86/events, drivers/amd/iommu: Prepare for multiple IOMMUs support · 1650dfd1
      Suravee Suthikulpanit authored
      
      
      Currently, amd_iommu_pc_get_set_reg_val() cannot support multiple
      IOMMUs. Modify it to allow callers to specify an IOMMU. This is in
      preparation for supporting multiple IOMMUs.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-8-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      1650dfd1
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu.c: Modify functions to query max banks and counters · f5863a00
      Suravee Suthikulpanit authored
      
      
      Currently, amd_iommu_pc_get_max_[banks|counters]() use end-point device
      ID to locate an IOMMU and check the reported max banks/counters. The
      logic assumes that the IOMMU_BASE_DEVID belongs to the first IOMMU, and
      uses it to acquire a reference to the first IOMMU, which does not work
      on certain systems. Instead, modify the function to take an IOMMU index,
      and use it to query the corresponding AMD IOMMU instance.
      
      Currently, hardcode the IOMMU index to 0 since the current AMD IOMMU
      perf implementation supports only a single IOMMU. A subsequent patch
      will add support for multiple IOMMUs, and will use a proper IOMMU index.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-7-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f5863a00
    • Suravee Suthikulpanit's avatar
      x86/events, drivers/iommu/amd: Introduce amd_iommu_get_num_iommus() · 6b9376e3
      Suravee Suthikulpanit authored
      
      
      Introduce amd_iommu_get_num_iommus(), which returns the value of
      amd_iommus_present. The function is used to replace direct access to the
      variable, which is now declared as static.
      
      This function will also be used by AMD IOMMU perf driver.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-6-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6b9376e3
    • Suravee Suthikulpanit's avatar
      drivers/iommu/amd: Clean up iommu_pc_get_set_reg() · 0a6d80c7
      Suravee Suthikulpanit authored
      
      
      Clean up coding style and fix a bug in the 64-bit register read logic
      since it overwrites the upper 32-bit when reading the lower 32-bit.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-5-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      0a6d80c7
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Clean up perf_iommu_read() · dc6ca5e4
      Suravee Suthikulpanit authored
      
      
      Fix coding style and use GENMASK_ULL().
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-4-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      dc6ca5e4
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Clean up bitwise operations · 6aad0c62
      Suravee Suthikulpanit authored
      
      
      Clean up register initialization and make use of BIT_ULL(x) where
      appropriate. This should not affect logic and functionality.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-3-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      6aad0c62
    • Suravee Suthikulpanit's avatar
      x86/events/amd/iommu: Declare pr_fmt() format · f9573e53
      Suravee Suthikulpanit authored
      
      
      Declare pr_fmt() format for perf/amd_iommu and remove unnecessary
      pr_debug() calls.
      
      Also check return value when _init_events_attrs() fails and issue an
      error message.
      
      Signed-off-by: default avatarSuravee Suthikulpanit <suravee.suthikulpanit@amd.com>
      Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Jörg Rödel <joro@8bytes.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: iommu@lists.linux-foundation.org
      Link: http://lkml.kernel.org/r/1487926102-13073-2-git-send-email-Suravee.Suthikulpanit@amd.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      f9573e53
    • Alexander Shishkin's avatar
      perf/x86/intel/pt: Allow the disabling of branch tracing · d35869ba
      Alexander Shishkin authored
      
      
      Now that Intel PT supports more types of trace content than just branch
      tracing, it may be useful to allow the user to disable branch tracing
      when it is not needed.
      
      The special case is BDW, where not setting BranchEn is not supported.
      
      This is slightly trickier than necessary, because up to this moment
      the driver has been setting BranchEn automatically and the userspace
      assumes as much. Instead of reversing the semantics of BranchEn, we
      introduce a 'passthrough' bit, which will forego the default and allow
      the user to set BranchEn to their heart's content.
      
      Signed-off-by: default avatarAlexander Shishkin <alexander.shishkin@linux.intel.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@infradead.org>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Borislav Petkov <bp@suse.de>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: vince@deater.net
      Link: http://lkml.kernel.org/r/20170206144140.14402-1-alexander.shishkin@linux.intel.com
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      d35869ba
    • Ingo Molnar's avatar
      c69f203d
    • Arnaldo Carvalho de Melo's avatar
      perf trace: Handle unpaired raw_syscalls:sys_exit event · fd2b2975
      Arnaldo Carvalho de Melo authored
      
      
      Which may happen when we start a tracing session and a thread is waiting
      for something like "poll" to return, in which case we better print "?"
      both for the syscall entry timestamp and for the duration.
      
      E.g.:
      
      Tracing existing mutt session:
      
        # perf trace -p `pidof mutt`
                ? (     ?   ): mutt/17135  ... [continued]: poll()) = 1
            0.027 ( 0.013 ms): mutt/17135 read(buf: 0x7ffcb3c42cef, count: 1) = 1
            0.047 ( 0.008 ms): mutt/17135 poll(ufds: 0x7ffcb3c42c50, nfds: 1, timeout_msecs: 1000) = 1
            0.059 ( 0.008 ms): mutt/17135 read(buf: 0x7ffcb3c42cef, count: 1) = 1
        <SNIP>
      
      Before it would print a large number because we'd do:
      
        ttrace->entry_time - trace->base_time
      
      And entry_time would be 0, while base_time would be the timestamp for
      the first event 'perf trace' reads, oops.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Claudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: http://lkml.kernel.org/n/tip-wbcb93ofva2qdjd5ltn5eeqq@git.kernel.org
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      fd2b2975
  6. Mar 29, 2017
    • Jin Yao's avatar
      perf report: Drop cycles 0 for LBR print · c1dfcfad
      Jin Yao authored
      
      
      For some platforms, for example Broadwell, it doesn't support cycles
      for LBR. But the perf always prints cycles:0, it's not necessary.
      
      The patch refactors the LBR info print code and drops the cycles:0.
      
      For example: perf report --branch-history --no-children --stdio
      
      On Broadwell:
      --0.91%--__random_r random_r.c:394 (iterations:2)
                __random_r random_r.c:360 (predicted:0.0%)
                __random_r random_r.c:380 (predicted:0.0%)
                __random_r random_r.c:357
      
      On Skylake:
      --1.07%--main div.c:39 (predicted:52.4% cycles:1 iterations:17)
                main div.c:44 (predicted:52.4% cycles:1)
                main div.c:42 (cycles:2)
                compute_flag div.c:28 (cycles:2)
                compute_flag div.c:27 (cycles:1)
                rand rand.c:28 (cycles:1)
                rand rand.c:28 (cycles:1)
                __random random.c:298 (cycles:1)
                __random random.c:297 (cycles:1)
                __random random.c:295 (cycles:1)
                __random random.c:295 (cycles:1)
                __random random.c:295 (cycles:1)
      
      Signed-off-by: default avatarYao Jin <yao.jin@linux.intel.com>
      Reviewed-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: http://lkml.kernel.org/r/1489046786-10061-1-git-send-email-yao.jin@linux.intel.com
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      c1dfcfad
    • Linus Torvalds's avatar
      Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost · fe82203b
      Linus Torvalds authored
      Pull virtio fixes from Michael Tsirkin:
       "Fixes to multiple issues in virtio.
      
        Most notably a regression fix for crashes reported by Fedora users.
        Hibernate is still reportedly broken, working on it"
      
      * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
        virtio_balloon: prevent uninitialized variable use
        virtio-balloon: use actual number of stats for stats queue buffers
        virtio_balloon: init 1st buffer in stats vq
        virtio_pci: fix out of bound access for msix_names
      fe82203b
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 050fc52d
      Linus Torvalds authored
      Pull KVM fixes from Paolo Bonzini:
       "All x86-specific, apart from some arch-independent syzkaller fixes"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: x86: cleanup the page tracking SRCU instance
        KVM: nVMX: fix nested EPT detection
        KVM: pci-assign: do not map smm memory slot pages in vt-d page tables
        KVM: kvm_io_bus_unregister_dev() should never fail
        KVM: VMX: Fix enable VPID conditions
        KVM: nVMX: Fix nested VPID vmx exec control
        KVM: x86: correct async page present tracepoint
        kvm: vmx: Flush TLB when the APIC-access address changes
        KVM: x86: use pic/ioapic destructor when destroy vm
        KVM: x86: check existance before destroy
        KVM: x86: clear bus pointer when destroyed
        KVM: Documentation: document MCE ioctls
        KVM: nVMX: don't reset kvm mmu twice
        PTP: fix ptr_ret.cocci warnings
        kvm: fix usage of uninit spinlock in avic_vm_destroy()
        KVM: VMX: downgrade warning on unexpected exit code
      050fc52d
    • Arnd Bergmann's avatar
      virtio_balloon: prevent uninitialized variable use · f0bb2d50
      Arnd Bergmann authored
      The latest gcc-7.0.1 snapshot reports a new warning:
      
      virtio/virtio_balloon.c: In function 'update_balloon_stats':
      virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized]
      virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized]
      virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized]
      virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized]
      
      This seems absolutely right, so we should add an extra check to
      prevent copying uninitialized stack data into the statistics.
      >From all I can tell, this has been broken since the statistics code
      was originally added in 2.6.34.
      
      Fixes: 9564e138
      
       ("virtio: Add memory statistics reporting to the balloon driver (V4)")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarLadi Prosek <lprosek@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      f0bb2d50
    • Ladi Prosek's avatar
      virtio-balloon: use actual number of stats for stats queue buffers · 9646b26e
      Ladi Prosek authored
      
      
      The virtio balloon driver contained a not-so-obvious invariant that
      update_balloon_stats has to update exactly VIRTIO_BALLOON_S_NR counters
      in order to send valid stats to the host. This commit fixes it by having
      update_balloon_stats return the actual number of counters, and its
      callers use it when pushing buffers to the stats virtqueue.
      
      Note that it is still out of spec to change the number of counters
      at run-time. "Driver MUST supply the same subset of statistics in all
      buffers submitted to the statsq."
      
      Suggested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarLadi Prosek <lprosek@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      9646b26e
    • Ladi Prosek's avatar
      virtio_balloon: init 1st buffer in stats vq · fc865322
      Ladi Prosek authored
      
      
      When init_vqs runs, virtio_balloon.stats is either uninitialized or
      contains stale values. The host updates its state with garbage data
      because it has no way of knowing that this is just a marker buffer
      used for signaling.
      
      This patch updates the stats before pushing the initial buffer.
      
      Alternative fixes:
      * Push an empty buffer in init_vqs. Not easily done with the current
        virtio implementation and violates the spec "Driver MUST supply the
        same subset of statistics in all buffers submitted to the statsq".
      * Push a buffer with invalid tags in init_vqs. Violates the same
        spec clause, plus "invalid tag" is not really defined.
      
      Note: the spec says:
      	When using the legacy interface, the device SHOULD ignore all values in
      	the first buffer in the statsq supplied by the driver after device
      	initialization. Note: Historically, drivers supplied an uninitialized
      	buffer in the first buffer.
      
      Unfortunately QEMU does not seem to implement the recommendation
      even for the legacy interface.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLadi Prosek <lprosek@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      fc865322
    • Jason Wang's avatar
      virtio_pci: fix out of bound access for msix_names · de85ec8b
      Jason Wang authored
      Fedora has received multiple reports of crashes when running
      4.11 as a guest
      
      https://bugzilla.redhat.com/show_bug.cgi?id=1430297
      https://bugzilla.redhat.com/show_bug.cgi?id=1434462
      https://bugzilla.kernel.org/show_bug.cgi?id=194911
      https://bugzilla.redhat.com/show_bug.cgi?id=1433899
      
      The crashes are not always consistent but they are generally
      some flavor of oops or GPF in virtio related code. Multiple people
      have done bisections (Thank you Thorsten Leemhuis and
      Richard W.M. Jones) and found this commit to be at fault
      
      07ec5148 is the first bad commit
      commit 07ec5148
      Author: Christoph Hellwig <hch@lst.de>
      Date:   Sun Feb 5 18:15:19 2017 +0100
      
          virtio_pci: use shared interrupts for virtqueues
      
      The issue seems to be an out of bounds access to the msix_names
      array corrupting kernel memory.
      
      Fixes: 07ec5148
      
       ("virtio_pci: use shared interrupts for virtqueues")
      Reported-by: default avatarLaura Abbott <labbott@redhat.com>
      Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
      Tested-by: default avatarRichard W.M. Jones <rjones@redhat.com>
      Tested-by: default avatarThorsten Leemhuis <linux@leemhuis.info>
      de85ec8b