1. 19 Jun, 2017 8 commits
  2. 16 Jun, 2017 2 commits
    • Ingo Molnar's avatar
      Merge tag 'perf-urgent-for-mingo-4.12-20170616' of... · 531c221d
      Ingo Molnar authored
      Merge tag 'perf-urgent-for-mingo-4.12-20170616' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
      - Fix probing of precise_ip level for default cycles event, that
        got broken recently on x86_64 when its arch code started
        considering invalid requesting precise samples when not sampling
        (i.e. when attr.sample_period == 0).
      
        This also fixes another problem in s/390 where the precision
        probing with sample_period == 0 returned precise_ip > 0, that
        then, when setting up the real cycles event (not probing) would
        return EOPNOTSUPP for precise_ip > 0 (as determined previously
        by probing) and sample_period > 0.
      
        These problems resulted in attr_precise not being set to the
        highest precision available on x86.64 when no event was specified,
        i.e. the canonical:
      
      	perf record ./workload
      
        would end up using attr.precise_ip = 0. As a workaround this would
        need to be done:
      
      	perf record -e cycles:P ./workload
      
        And on s/390 it would plain not work, requiring using:
      
              perf record -e cycles ./workload
      
        as a workaround.  (Arnaldo Carvalho de Melo)
      
      - Fix perf build with ARCH=x86_64, when ARCH should be transformed
        into ARCH=x86, just like with the main kernel Makefile and
        tools/objtool's, i.e. use SRCARCH. (Jiada Wang)
      
      - Avoid accessing uninitialized data structures when unwinding with
        elfutils's libdw, making it more closely mimic libunwind's unwinder.
        (Milian Wolff)
      Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
      531c221d
    • Milian Wolff's avatar
      perf unwind: Report module before querying isactivation in dwfl unwind · 9126cbba
      Milian Wolff authored
      The PC returned by dwfl_frame_pc() may map into a not-yet-reported
      module. We have to report it before we continue unwinding. But when we
      query for the isactivation flag in dwfl_frame_pc, libdw will actually do
      one more unwinding step internally which can then break and lead to
      missed frames or broken stacks.
      
      With libunwind we get e.g.:
      
      ~~~~~
        heaptrack_gui  2228 135073.400474:     613969 cycles:
      	          108c8e [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1093bc [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          109e7b QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
      	          1470ff [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          147f67 QSystemLocale::query (/usr/lib/libQt5Core.so.5.8.0)
      	          109fbf QLocalePrivate::updateSystemPrivate (/usr/lib/libQt5Core.so.5.8.0)
      	          10aa27 QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
      	          1e02c3 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          2113bb [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          211505 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1b5df0 QFileInfo::exists (/usr/lib/libQt5Core.so.5.8.0)
      	           92eb2 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	           93423 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	           93d2a QLibraryInfo::location (/usr/lib/libQt5Core.so.5.8.0)
      	          2170af [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          297c53 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
      	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
      	          1589e8 QApplicationPrivate::init (/usr/lib/libQt5Widgets.so.5.8.0)
      	           78622 main (/home/milian/projects/compiled/other/bin/heaptrack_gui)
      	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
      	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
      
        heaptrack_gui  2228 135073.401156:     569521 cycles:
      	          131633 QString::endsWith (/usr/lib/libQt5Core.so.5.8.0)
      	          1a0701 QDir::cleanPath (/usr/lib/libQt5Core.so.5.8.0)
      	          21b82d [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1b3727 QFileInfo::canonicalFilePath (/usr/lib/libQt5Core.so.5.8.0)
      	          2780c7 QFactoryLoader::update (/usr/lib/libQt5Core.so.5.8.0)
      	          279525 QFactoryLoader::QFactoryLoader (/usr/lib/libQt5Core.so.5.8.0)
      	           e5bd0 QPlatformIntegrationFactory::create (/usr/lib/libQt5Gui.so.5.8.0)
      	           f5a1c QGuiApplicationPrivate::createPlatformIntegration (/usr/lib/libQt5Gui.so.5.8.0)
      	           f650c QGuiApplicationPrivate::createEventDispatcher (/usr/lib/libQt5Gui.so.5.8.0)
      	          298524 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
      	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
      	          1589e8 QApplicationPrivate::init (/usr/lib/libQt5Widgets.so.5.8.0)
      	           78622 main (/home/milian/projects/compiled/other/bin/heaptrack_gui)
      	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
      	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
      ~~~~~
      
      Note the two frames 1589e8 and 78622 in the first sample. These are
      missing when unwinding with libdw. The second sample's breakage is
      more obvious:
      
      ~~~~~
        heaptrack_gui  2228 135073.400474:     613969 cycles:
      	          108c8e [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1093bc [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          109e7b QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
      	          1470ff [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          147f67 QSystemLocale::query (/usr/lib/libQt5Core.so.5.8.0)
      	          109fbf QLocalePrivate::updateSystemPrivate (/usr/lib/libQt5Core.so.5.8.0)
      	          10aa27 QLocale::QLocale (/usr/lib/libQt5Core.so.5.8.0)
      	          1e02c3 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          2113bb [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          211505 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1b5df0 QFileInfo::exists (/usr/lib/libQt5Core.so.5.8.0)
      	           92eb2 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	           93423 [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	           93d2a QLibraryInfo::location (/usr/lib/libQt5Core.so.5.8.0)
      	          2170af [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          297c53 QCoreApplicationPrivate::init (/usr/lib/libQt5Core.so.5.8.0)
      	           f7cde QGuiApplicationPrivate::init (/usr/lib/libQt5Gui.so.5.8.0)
      	           20439 __libc_start_main (/usr/lib/libc-2.25.so)
      	           78299 _start (/home/milian/projects/compiled/other/bin/heaptrack_gui)
      
      heaptrack_gui  2228 135073.401156:     569521 cycles:
      	          131633 QString::endsWith (/usr/lib/libQt5Core.so.5.8.0)
      	          1a0701 QDir::cleanPath (/usr/lib/libQt5Core.so.5.8.0)
      	          21b82d [unknown] (/usr/lib/libQt5Core.so.5.8.0)
      	          1b3727 QFileInfo::canonicalFilePath (/usr/lib/libQt5Core.so.5.8.0)
      	          2780c7 QFactoryLoader::update (/usr/lib/libQt5Core.so.5.8.0)
      	          279525 QFactoryLoader::QFactoryLoader (/usr/lib/libQt5Core.so.5.8.0)
      	           e5bd0 QPlatformIntegrationFactory::create (/usr/lib/libQt5Gui.so.5.8.0)
      	          723dbf [unknown] ([unknown])
      ~~~~~
      
      This patch fixes this issue and the libdw unwinder mimicks the libunwind
      behavior more closely.
      Signed-off-by: default avatarMilian Wolff <milian.wolff@kdab.com>
      Acked-by: default avatarJan Kratochvil <jan.kratochvil@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lkml.kernel.org/r/20170602143753.16907-2-milian.wolff@kdab.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      9126cbba
  3. 14 Jun, 2017 2 commits
    • Jiada Wang's avatar
      perf tools: Fix build with ARCH=x86_64 · 7a759cd8
      Jiada Wang authored
      With commit: 0a943cb1 (tools build: Add HOSTARCH Makefile variable)
      when building for ARCH=x86_64, ARCH=x86_64 is passed to perf instead of
      ARCH=x86, so the perf build process searchs header files from
      tools/arch/x86_64/include, which doesn't exist.
      
      The following build failure is seen:
      
        In file included from util/event.c:2:0:
          tools/include/uapi/linux/mman.h:4:27: fatal error: uapi/asm/mman.h: No such file or directory
          compilation terminated.
      
      Fix this issue by using SRCARCH instead of ARCH in perf, just like the
      main kernel Makefile and tools/objtool's.
      Signed-off-by: default avatarJiada Wang <jiada_wang@mentor.com>
      Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      Acked-by: default avatarJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Eugeniu Rosca <erosca@de.adit-jv.com>
      Cc: Jan Stancek <jstancek@redhat.com>
      Cc: Masami Hiramatsu <mhiramat@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Rui Teng <rui.teng@linux.vnet.ibm.com>
      Cc: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 0a943cb1 ("tools build: Add HOSTARCH Makefile variable")
      Link: http://lkml.kernel.org/r/1491793357-14977-2-git-send-email-jiada_wang@mentor.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a759cd8
    • Arnaldo Carvalho de Melo's avatar
      perf evsel: Fix probing of precise_ip level for default cycles event · 7a1ac110
      Arnaldo Carvalho de Melo authored
      Since commit 18e7a45a ("perf/x86: Reject non sampling events with
      precise_ip") returns -EINVAL for sys_perf_event_open() with an attribute
      with (attr.precise_ip > 0 && attr.sample_period == 0), just like is done
      in the routine used to probe the max precise level when no events were
      passed to 'perf record' or 'perf top', i.e.:
      
      	perf_evsel__new_cycles()
      		perf_event_attr__set_max_precise_ip()
      
      The x86 code, in x86_pmu_hw_config(), which is called all the way from
      sys_perf_event_open() did, starting with the aforementioned commit:
      
                      /* There's no sense in having PEBS for non sampling events: */
                      if (!is_sampling_event(event))
                              return -EINVAL;
      
      Which makes it fail for cycles:ppp, cycles:pp and cycles:p, always using
      just the non precise cycles variant.
      
      To make sure that this is the case, I tested it, before this patch,
      with:
      
        # perf probe -L x86_pmu_hw_config
        <x86_pmu_hw_config@/home/acme/git/linux/arch/x86/events/core.c:0>
              0  int x86_pmu_hw_config(struct perf_event *event)
              1  {
              2         if (event->attr.precise_ip) {
      <SNIP>
             17                 if (event->attr.precise_ip > precise)
             18                         return -EOPNOTSUPP;
      
                                /* There's no sense in having PEBS for non sampling events: */
             21                 if (!is_sampling_event(event))
             22                         return -EINVAL;
                        }
      <SNIP>
        # perf probe x86_pmu_hw_config:22
        Added new events:
          probe:x86_pmu_hw_config (on x86_pmu_hw_config:22)
          probe:x86_pmu_hw_config_1 (on x86_pmu_hw_config:22)
      
        You can now use it in all perf tools, such as:
      
              perf record -e probe:x86_pmu_hw_config_1 -aR sleep 1
      
        # perf trace -e perf_event_open,probe:x86_pmu_hwconfig*/max-stack=16/ perf record usleep 1
           0.000 ( 0.015 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110, cpu: -1, group_fd: -1      ) ...
           0.015 (         ): probe:x86_pmu_hw_config:(ffffffff9c0065e1))
                                             x86_pmu_hw_config ([kernel.kallsyms])
                                             hsw_hw_config ([kernel.kallsyms])
                                             x86_pmu_event_init ([kernel.kallsyms])
                                             perf_try_init_event ([kernel.kallsyms])
                                             perf_event_alloc ([kernel.kallsyms])
                                             SYSC_perf_event_open ([kernel.kallsyms])
                                             sys_perf_event_open ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             return_from_SYSCALL_64 ([kernel.kallsyms])
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_event_attr__set_max_precise_ip (/home/acme/bin/perf)
                                             perf_evsel__new_cycles (/home/acme/bin/perf)
                                             perf_evlist__add_default (/home/acme/bin/perf)
                                             cmd_record (/home/acme/bin/perf)
                                             run_builtin (/home/acme/bin/perf)
                                             handle_internal_command (/home/acme/bin/perf)
           0.000 ( 0.021 ms): perf/4150  ... [continued]: perf_event_open()) = -1 EINVAL Invalid argument
           0.023 ( 0.002 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110, cpu: -1, group_fd: -1      ) ...
           0.025 (         ): probe:x86_pmu_hw_config:(ffffffff9c0065e1))
                                             x86_pmu_hw_config ([kernel.kallsyms])
                                             hsw_hw_config ([kernel.kallsyms])
                                             x86_pmu_event_init ([kernel.kallsyms])
                                             perf_try_init_event ([kernel.kallsyms])
                                             perf_event_alloc ([kernel.kallsyms])
                                             SYSC_perf_event_open ([kernel.kallsyms])
                                             sys_perf_event_open ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             return_from_SYSCALL_64 ([kernel.kallsyms])
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_event_attr__set_max_precise_ip (/home/acme/bin/perf)
                                             perf_evsel__new_cycles (/home/acme/bin/perf)
                                             perf_evlist__add_default (/home/acme/bin/perf)
                                             cmd_record (/home/acme/bin/perf)
                                             run_builtin (/home/acme/bin/perf)
                                             handle_internal_command (/home/acme/bin/perf)
           0.023 ( 0.004 ms): perf/4150  ... [continued]: perf_event_open()) = -1 EINVAL Invalid argument
           0.028 ( 0.002 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8ba110, cpu: -1, group_fd: -1      ) ...
           0.030 (         ): probe:x86_pmu_hw_config:(ffffffff9c0065e1))
                                             x86_pmu_hw_config ([kernel.kallsyms])
                                             hsw_hw_config ([kernel.kallsyms])
                                             x86_pmu_event_init ([kernel.kallsyms])
                                             perf_try_init_event ([kernel.kallsyms])
                                             perf_event_alloc ([kernel.kallsyms])
                                             SYSC_perf_event_open ([kernel.kallsyms])
                                             sys_perf_event_open ([kernel.kallsyms])
                                             do_syscall_64 ([kernel.kallsyms])
                                             return_from_SYSCALL_64 ([kernel.kallsyms])
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_event_attr__set_max_precise_ip (/home/acme/bin/perf)
                                             perf_evsel__new_cycles (/home/acme/bin/perf)
                                             perf_evlist__add_default (/home/acme/bin/perf)
                                             cmd_record (/home/acme/bin/perf)
                                             run_builtin (/home/acme/bin/perf)
                                             handle_internal_command (/home/acme/bin/perf)
           0.028 ( 0.004 ms): perf/4150  ... [continued]: perf_event_open()) = -1 EINVAL Invalid argument
          41.018 ( 0.012 ms): perf/4150 perf_event_open(attr_uptr: 0x7ffebc8b5dd0, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
          41.065 ( 0.011 ms): perf/4150 perf_event_open(attr_uptr: 0x3c7db78, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
          41.080 ( 0.006 ms): perf/4150 perf_event_open(attr_uptr: 0x3c7db78, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
          41.103 ( 0.010 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid: 4151 (perf), group_fd: -1, flags: FD_CLOEXEC) = 4
          41.115 ( 0.006 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid: 4151 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 5
          41.122 ( 0.004 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid: 4151 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 6
          41.128 ( 0.008 ms): perf/4150 perf_event_open(attr_uptr: 0x3c4e748, pid: 4151 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 8
        [ perf record: Woken up 1 times to write data ]
        [ perf record: Captured and wrote 0.017 MB perf.data (2 samples) ]
        #
      
      I.e. that return -EINVAL in x86_pmu_hw_config() is hit three times.
      
      So fix it by just setting attr.sample_period
      
      Now, after this patch:
      
        # perf trace --max-stack=2 -e perf_event_open,probe:x86_pmu_hw_config* perf record usleep 1
        [ perf record: Woken up 1 times to write data ]
           0.000 ( 0.017 ms): perf/8469 perf_event_open(attr_uptr: 0x7ffe36c27d10, pid: -1, cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 4
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_event_open_cloexec_flag (/home/acme/bin/perf)
           0.050 ( 0.031 ms): perf/8469 perf_event_open(attr_uptr: 0x24ebb78, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evlist__config (/home/acme/bin/perf)
           0.092 ( 0.040 ms): perf/8469 perf_event_open(attr_uptr: 0x24ebb78, pid: -1, group_fd: -1, flags: FD_CLOEXEC) = 4
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evlist__config (/home/acme/bin/perf)
           0.143 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, cpu: -1, group_fd: -1           ) = 4
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_event_attr__set_max_precise_ip (/home/acme/bin/perf)
           0.161 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid: 8470 (perf), group_fd: -1, flags: FD_CLOEXEC) = 4
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evsel__open (/home/acme/bin/perf)
           0.171 ( 0.005 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid: 8470 (perf), cpu: 1, group_fd: -1, flags: FD_CLOEXEC) = 5
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evsel__open (/home/acme/bin/perf)
           0.180 ( 0.007 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid: 8470 (perf), cpu: 2, group_fd: -1, flags: FD_CLOEXEC) = 6
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evsel__open (/home/acme/bin/perf)
           0.190 ( 0.005 ms): perf/8469 perf_event_open(attr_uptr: 0x24bc748, pid: 8470 (perf), cpu: 3, group_fd: -1, flags: FD_CLOEXEC) = 8
                                             syscall (/usr/lib64/libc-2.24.so)
                                             perf_evsel__open (/home/acme/bin/perf)
        [ perf record: Captured and wrote 0.017 MB perf.data (7 samples) ]
        #
      
      The probe one called from perf_event_attr__set_max_precise_ip() works
      the first time, with attr.precise_ip = 3, wit hthe next ones being the
      per cpu ones for the cycles:ppp event.
      
      And here is the text from a report and alternative proposed patch by
      Thomas-Mich Richter:
      
       ---
      
      On s390 the counter and sampling facility do not support a precise IP
      skid level and sometimes returns EOPNOTSUPP when structure member
      precise_ip in struct perf_event_attr is not set to zero.
      
      On s390 commnd 'perf record -- true' fails with error EOPNOTSUPP.  This
      happens only when no events are specified on command line.
      
      The functions called are
      ...
        --> perf_evlist__add_default
            --> perf_evsel__new_cycles
                --> perf_event_attr__set_max_precise_ip
      
      The last function determines the value of structure member precise_ip by
      invoking the perf_event_open() system call and checking the return code.
      The first successful open is the value for precise_ip.
      
      However the value is determined without setting member sample_period and
      indicates no sampling.
      
      On s390 the counter facility and sampling facility are different.  The
      above procedure determines a precise_ip value of 3 using the counter
      facility. Later it uses the sampling facility with a value of 3 and
      fails with EOPNOTSUPP.
      
       ---
      
      v2: Older compilers (e.g. gcc 4.4.7) don't support referencing members
          of unnamed union members in the container struct initialization, so
          move from:
      
      	struct perf_event_attr attr = {
      		...
      		.sample_period = 1,
      	};
      
      to right after it as:
      
      	struct perf_event_attr attr = {
      		...
      	};
      
      	attr.sample_period = 1;
      
      v3: We need to reset .sample_period to 0 to let the users of
      perf_evsel__new_cycles() to properly setup attr.sample_period or
      attr.sample_freq. Reported by Ingo Molnar.
      Reported-and-Acked-by: default avatarThomas-Mich Richter <tmricht@linux.vnet.ibm.com>
      Acked-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Acked-by: default avatarJiri Olsa <jolsa@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 18e7a45a ("perf/x86: Reject non sampling events with precise_ip")
      Link: http://lkml.kernel.org/n/tip-yv6nnkl7tzqocrm0hl3x7vf1@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      7a1ac110
  4. 13 Jun, 2017 2 commits
    • Linus Torvalds's avatar
      Merge tag 'xtensa-20170612' of git://github.com/jcmvbkbc/linux-xtensa · 63f700aa
      Linus Torvalds authored
      Pull Xtensa fixes from Max Filippov:
      
       - don't use linux IRQ #0 in legacy irq domains: fixes timer interrupt
         assignment when it's hardware IRQ # is 0 and the kernel is built w/o
         device tree support
      
       - reduce reservation size for double exception vector literals from 48
         to 20 bytes: fixes build on cores with small user exception vector
      
       - cleanups: use kmalloc_array instead of kmalloc in simdisk_init and
         seq_puts instead of seq_printf in c_show.
      
      * tag 'xtensa-20170612' of git://github.com/jcmvbkbc/linux-xtensa:
        xtensa: don't use linux IRQ #0
        xtensa: reduce double exception literal reservation
        xtensa: ISS: Use kmalloc_array() in simdisk_init()
        xtensa: Use seq_puts() in c_show()
      63f700aa
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · 2ab99b00
      Linus Torvalds authored
      Pull s390 fixes from Martin Schwidefsky:
      
       - A fix for KVM to avoid kernel oopses in case of host protection
         faults due to runtime instrumentation
      
       - A fix for the AP bus to avoid dead devices after unbind / bind
      
       - A fix for a compile warning merged from the vfio_ccw tree
      
       - Updated default configurations
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390: update defconfig
        s390/zcrypt: Fix blocking queue device after unbind/bind.
        s390/vfio_ccw: make some symbols static
        s390/kvm: do not rely on the ILC on kvm host protection fauls
      2ab99b00
  5. 11 Jun, 2017 15 commits
    • Linus Torvalds's avatar
      Linux 4.12-rc5 · 32c1431e
      Linus Torvalds authored
      32c1431e
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security · 32627645
      Linus Torvalds authored
      Pull key subsystem fixes from James Morris:
       "Here are a bunch of fixes for Linux keyrings, including:
      
         - Fix up the refcount handling now that key structs use the
           refcount_t type and the refcount_t ops don't allow a 0->1
           transition.
      
         - Fix a potential NULL deref after error in x509_cert_parse().
      
         - Don't put data for the crypto algorithms to use on the stack.
      
         - Fix the handling of a null payload being passed to add_key().
      
         - Fix incorrect cleanup an uninitialised key_preparsed_payload in
           key_update().
      
         - Explicit sanitisation of potentially secure data before freeing.
      
         - Fixes for the Diffie-Helman code"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (23 commits)
        KEYS: fix refcount_inc() on zero
        KEYS: Convert KEYCTL_DH_COMPUTE to use the crypto KPP API
        crypto : asymmetric_keys : verify_pefile:zero memory content before freeing
        KEYS: DH: add __user annotations to keyctl_kdf_params
        KEYS: DH: ensure the KDF counter is properly aligned
        KEYS: DH: don't feed uninitialized "otherinfo" into KDF
        KEYS: DH: forbid using digest_null as the KDF hash
        KEYS: sanitize key structs before freeing
        KEYS: trusted: sanitize all key material
        KEYS: encrypted: sanitize all key material
        KEYS: user_defined: sanitize key payloads
        KEYS: sanitize add_key() and keyctl() key payloads
        KEYS: fix freeing uninitialized memory in key_update()
        KEYS: fix dereferencing NULL payload with nonzero length
        KEYS: encrypted: use constant-time HMAC comparison
        KEYS: encrypted: fix race causing incorrect HMAC calculations
        KEYS: encrypted: fix buffer overread in valid_master_desc()
        KEYS: encrypted: avoid encrypting/decrypting stack buffers
        KEYS: put keyring if install_session_keyring_to_cred() fails
        KEYS: Delete an error message for a failed memory allocation in get_derived_key()
        ...
      32627645
    • Linus Torvalds's avatar
      compiler, clang: properly override 'inline' for clang · 6d53cefb
      Linus Torvalds authored
      Commit abb2ea7d ("compiler, clang: suppress warning for unused
      static inline functions") just caused more warnings due to re-defining
      the 'inline' macro.
      
      So undef it before re-defining it, and also add the 'notrace' attribute
      like the gcc version that this is overriding does.
      
      Maybe this makes clang happier.
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      6d53cefb
    • Linus Torvalds's avatar
      Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random · 5ad9345d
      Linus Torvalds authored
      Pull randomness fixes from Ted Ts'o:
       "Improve performance by using a lockless update mechanism suggested by
        Linus, and make sure we refresh per-CPU entropy returned get_random_*
        as soon as the CRNG is initialized"
      
      * tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random:
        random: invalidate batched entropy after crng init
        random: use lockless method of accessing and updating f->reg_idx
      5ad9345d
    • Linus Torvalds's avatar
      Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4 · 5e38b72a
      Linus Torvalds authored
      Pull ext4 fixes from Ted Ts'o:
       "Fix various bug fixes in ext4 caused by races and memory allocation
        failures"
      
      * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4:
        ext4: fix fdatasync(2) after extent manipulation operations
        ext4: fix data corruption for mmap writes
        ext4: fix data corruption with EXT4_GET_BLOCKS_ZERO
        ext4: fix quota charging for shared xattr blocks
        ext4: remove redundant check for encrypted file on dio write path
        ext4: remove unused d_name argument from ext4_search_dir() et al.
        ext4: fix off-by-one error when writing back pages before dio read
        ext4: fix off-by-one on max nr_pages in ext4_find_unwritten_pgoff()
        ext4: keep existing extra fields when inode expands
        ext4: handle the rest of ext4_mb_load_buddy() ENOMEM errors
        ext4: fix off-by-in in loop termination in ext4_find_unwritten_pgoff()
        ext4: fix SEEK_HOLE
        jbd2: preserve original nofs flag during journal restart
        ext4: clear lockdep subtype for quota files on quota off
      5e38b72a
    • Linus Torvalds's avatar
      Merge tag 'gpio-v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio · f986e31b
      Linus Torvalds authored
      Pull GPIO fixes from Linus Walleij:
       "A few overdue GPIO patches for the v4.12 kernel.
      
         - Fix debounce logic on the Aspeed platform.
      
         - Fix the "virtual gpio" things on the Intel Crystal Cove.
      
         - Fix the blink counter selection on the MVEBU platform"
      
      * tag 'gpio-v4.12-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio:
        gpio: mvebu: fix gpio bank registration when pwm is used
        gpio: mvebu: fix blink counter register selection
        MAINTAINERS: remove self from GPIO maintainers
        gpio: crystalcove: Do not write regular gpio registers for virtual GPIOs
        gpio: aspeed: Don't attempt to debounce if disabled
      f986e31b
    • Linus Torvalds's avatar
      Merge tag 'char-misc-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc · 9cd9cb0b
      Linus Torvalds authored
      Pull char/misc driver fixes from Greg KH:
       "Here are some small driver fixes for 4.12-rc5. Nothing major here,
        just some small bugfixes found by people testing, and a MAINTAINERS
        file update for the genwqe driver.
      
        All have been in linux-next with no reported issues"
      
      [ The cxl driver fix came in through the powerpc tree earlier ]
      
      * tag 'char-misc-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc:
        cxl: Avoid double free_irq() for psl,slice interrupts
        mei: make sysfs modalias format similar as uevent modalias
        drivers: char: mem: Fix wraparound check to allow mappings up to the end
        MAINTAINERS: Change maintainer of genwqe driver
        goldfish_pipe: use GFP_ATOMIC under spin lock
        firmware: vpd: do not leak kobjects
        firmware: vpd: avoid potential use-after-free when destroying section
        firmware: vpd: do not leave freed section attributes to the list
      9cd9cb0b
    • Linus Torvalds's avatar
      Merge tag 'staging-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging · 21c9eb7c
      Linus Torvalds authored
      Pull staging/IIO fixes from Greg KH:
       "These are mostly all IIO driver fixes, resolving a number of tiny
        issues. There's also a ccree and lustre fix in here as well, both fix
        problems found in those codebases.
      
        All have been in linux-next with no reported issues"
      
      * tag 'staging-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
        staging: ccree: fix buffer copy
        staging/lustre/lov: remove set_fs() call from lov_getstripe()
        staging: ccree: add CRYPTO dependency
        iio: adc: sun4i-gpadc-iio: fix parent device being used in devm function
        iio: light: ltr501 Fix interchanged als/ps register field
        iio: adc: bcm_iproc_adc: swap primary and secondary isr handler's
        iio: trigger: fix NULL pointer dereference in iio_trigger_write_current()
        iio: adc: max9611: Fix attribute measure unit
        iio: adc: ti_am335x_adc: allocating too much in probe
        iio: adc: sun4i-gpadc-iio: Fix module autoload when OF devices are registered
        iio: adc: sun4i-gpadc-iio: Fix module autoload when PLATFORM devices are registered
        iio: proximity: as3935: fix iio_trigger_poll issue
        iio: proximity: as3935: fix AS3935_INT mask
        iio: adc: Max9611: checking for ERR_PTR instead of NULL in probe
        iio: proximity: as3935: recalibrate RCO after resume
      21c9eb7c
    • Linus Torvalds's avatar
      Merge tag 'usb-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb · 246baac2
      Linus Torvalds authored
      Pull USB fixes from Greg KH:
       "Here are some small USB fixes for 4.12-rc5
      
        They are for some reported issues in the chipidea and gadget drivers.
        Nothing major. All have been in linux-next for a while with no
        reported issues"
      
      * tag 'usb-4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb:
        usb: gadget: udc: renesas_usb3: Fix PN_INT_ENA disabling timing
        usb: gadget: udc: renesas_usb3: lock for PN_ registers access
        usb: gadget: udc: renesas_usb3: fix deadlock by spinlock
        usb: gadget: udc: renesas_usb3: fix pm_runtime functions calling
        usb: gadget: f_mass_storage: Serialize wake and sleep execution
        usb: dwc2: add support for the DWC2 controller on Meson8 SoCs
        phy: qualcomm: phy-qcom-qmp: fix application of sizeof to pointer
        usb: musb: dsps: keep VBUS on for host-only mode
        usb: chipidea: core: check before accessing ci_role in ci_role_show
        usb: chipidea: debug: check before accessing ci_role
        phy: qcom-qmp: fix return value check in qcom_qmp_phy_create()
        usb: chipidea: udc: fix NULL pointer dereference if udc_start failed
        usb: chipidea: imx: Do not access CLKONOFF on i.MX51
      246baac2
    • Linus Torvalds's avatar
      Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · ef918d3c
      Linus Torvalds authored
      Pull SCSI fixes from James Bottomley:
       "This is a set of user visible fixes (excepting one format string
        change).
      
        Four of the qla2xxx fixes only affect the firmware dump path, but it's
        still important to the enterprise. The rest are various NULL pointer
        crash conditions or outright driver hangs"
      
      * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
        scsi: cxgb4i: libcxgbi: in error case RST tcp conn
        scsi: scsi_debug: Avoid PI being disabled when TPGS is enabled
        scsi: qla2xxx: Fix extraneous ref on sp's after adapter break
        scsi: lpfc: prevent potential null pointer dereference
        scsi: lpfc: Avoid NULL pointer dereference in lpfc_els_abort()
        scsi: lpfc: nvmet_fc: fix format string
        scsi: qla2xxx: Fix crash due to NULL pointer dereference of ctx
        scsi: qla2xxx: Fix mailbox pointer error in fwdump capture
        scsi: qla2xxx: Set bit 15 for DIAG_ECHO_TEST MBC
        scsi: qla2xxx: Modify T262 FW dump template to specify same start/end to debug customer issues
        scsi: qla2xxx: Fix crash due to mismatch mumber of Q-pair creation for Multi queue
        scsi: qla2xxx: Fix NULL pointer access due to redundant fc_host_port_name call
        scsi: qla2xxx: Fix recursive loop during target mode configuration for ISP25XX leaving system unresponsive
        scsi: bnx2fc: fix race condition in bnx2fc_get_host_stats()
        scsi: qla2xxx: don't disable a not previously enabled PCI device
      ef918d3c
    • Linus Torvalds's avatar
      Merge branch 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm · 8f56821d
      Linus Torvalds authored
      Pull libnvdimm fix from Dan Williams:
       "We expanded the device-dax fs type in 4.12 to be a generic provider of
        a struct dax_device with an embedded inode. However, Sasha found some
        basic negative testing was not run to verify that this fs cleanly
        handles being mounted directly.
      
        Note that the fresh rebase was done to remove an unnecessary Cc:
        <stable> tag, but this commit otherwise had a build success
        notification from the 0day robot."
      
      * 'libnvdimm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
        device-dax: fix 'dax' device filesystem inode destruction crash
      8f56821d
    • Linus Torvalds's avatar
      Merge tag 'hexagon-for-linus-v4.12-rc5' of... · 9d66af6b
      Linus Torvalds authored
      Merge tag 'hexagon-for-linus-v4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
      
      Pull hexagon fix from Guenter Roeck:
       "This fixes a build error seen when building hexagon images.
      
        Richard sent me an Ack, but didn't reply when asked if he wants me to
        send the patch to you directly, so I figured I'd just do it"
      
      * tag 'hexagon-for-linus-v4.12-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging:
        hexagon: Use raw_copy_to_user
      9d66af6b
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm · 9d0eb462
      Linus Torvalds authored
      Pull KVM fixes from Paolo Bonzini:
       "Bug fixes (ARM, s390, x86)"
      
      * tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm:
        KVM: async_pf: avoid async pf injection when in guest mode
        KVM: cpuid: Fix read/write out-of-bounds vulnerability in cpuid emulation
        arm: KVM: Allow unaligned accesses at HYP
        arm64: KVM: Allow unaligned accesses at EL2
        arm64: KVM: Preserve RES1 bits in SCTLR_EL2
        KVM: arm/arm64: Handle possible NULL stage2 pud when ageing pages
        KVM: nVMX: Fix exception injection
        kvm: async_pf: fix rcu_irq_enter() with irqs enabled
        KVM: arm/arm64: vgic-v3: Fix nr_pre_bits bitfield extraction
        KVM: s390: fix ais handling vs cpu model
        KVM: arm/arm64: Fix isues with GICv2 on GICv3 migration
      9d0eb462
    • Wanpeng Li's avatar
      KVM: async_pf: avoid async pf injection when in guest mode · 9bc1f09f
      Wanpeng Li authored
       INFO: task gnome-terminal-:1734 blocked for more than 120 seconds.
             Not tainted 4.12.0-rc4+ #8
       "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
       gnome-terminal- D    0  1734   1015 0x00000000
       Call Trace:
        __schedule+0x3cd/0xb30
        schedule+0x40/0x90
        kvm_async_pf_task_wait+0x1cc/0x270
        ? __vfs_read+0x37/0x150
        ? prepare_to_swait+0x22/0x70
        do_async_page_fault+0x77/0xb0
        ? do_async_page_fault+0x77/0xb0
        async_page_fault+0x28/0x30
      
      This is triggered by running both win7 and win2016 on L1 KVM simultaneously,
      and then gives stress to memory on L1, I can observed this hang on L1 when
      at least ~70% swap area is occupied on L0.
      
      This is due to async pf was injected to L2 which should be injected to L1,
      L2 guest starts receiving pagefault w/ bogus %cr2(apf token from the host
      actually), and L1 guest starts accumulating tasks stuck in D state in
      kvm_async_pf_task_wait() since missing PAGE_READY async_pfs.
      
      This patch fixes the hang by doing async pf when executing L1 guest.
      
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krčmář <rkrcmar@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarWanpeng Li <wanpeng.li@hotmail.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      9bc1f09f
    • Guenter Roeck's avatar
      hexagon: Use raw_copy_to_user · 4d801cca
      Guenter Roeck authored
      Commit ac4691fa ("hexagon: switch to RAW_COPY_USER") replaced
      __copy_to_user_hexagon() with raw_copy_to_user(), but did not catch
      all callers, resulting in the following build error.
      
      arch/hexagon/mm/uaccess.c: In function '__clear_user_hexagon':
      arch/hexagon/mm/uaccess.c:40:3: error:
      	implicit declaration of function '__copy_to_user_hexagon'
      
      Fixes: ac4691fa ("hexagon: switch to RAW_COPY_USER")
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Acked-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      Acked-by: default avatarRichard Kuo <rkuo@codeaurora.org>
      Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
      4d801cca
  6. 10 Jun, 2017 11 commits