1. 10 4月, 2018 4 次提交
    • S
      perf/core: Fix perf_uprobe_init() · 0eadcc7a
      Song Liu 提交于
      Similarly to the uprobe PMU fix in perf_kprobe_init(), fix error
      handling in perf_uprobe_init() as well.
      Reported-by: N范龙飞 <long7573@126.com>
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Acked-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: e12f03d7 ("perf/core: Implement the 'perf_kprobe' PMU")
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      0eadcc7a
    • M
      perf/core: Fix perf_kprobe_init() · 5da13ab8
      Masami Hiramatsu 提交于
      Fix error handling in perf_kprobe_init():
      
      	==================================================================
      	BUG: KASAN: slab-out-of-bounds in strlen+0x8e/0xa0 lib/string.c:482
      	Read of size 1 at addr ffff88003f9cc5c0 by task syz-executor2/23095
      
      	CPU: 0 PID: 23095 Comm: syz-executor2 Not tainted 4.16.0+ #24
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
      	Call Trace:
      	 __dump_stack lib/dump_stack.c:77 [inline]
      	 dump_stack+0xca/0x13e lib/dump_stack.c:113
      	 print_address_description+0x6e/0x2c0 mm/kasan/report.c:256
      	 kasan_report_error mm/kasan/report.c:354 [inline]
      	 kasan_report+0x256/0x380 mm/kasan/report.c:412
      	 strlen+0x8e/0xa0 lib/string.c:482
      	 kstrdup+0x21/0x70 mm/util.c:55
      	 alloc_trace_kprobe+0xc8/0x930 kernel/trace/trace_kprobe.c:325
      	 create_local_trace_kprobe+0x4f/0x3a0 kernel/trace/trace_kprobe.c:1438
      	 perf_kprobe_init+0x149/0x1f0 kernel/trace/trace_event_perf.c:264
      	 perf_kprobe_event_init+0xa8/0x120 kernel/events/core.c:8407
      	 perf_try_init_event+0xcb/0x2a0 kernel/events/core.c:9719
      	 perf_init_event kernel/events/core.c:9750 [inline]
      	 perf_event_alloc+0x1367/0x1e20 kernel/events/core.c:10022
      	 SYSC_perf_event_open+0x242/0x2330 kernel/events/core.c:10477
      	 do_syscall_64+0x198/0x640 arch/x86/entry/common.c:287
      	 entry_SYSCALL_64_after_hwframe+0x42/0xb7
      Reported-by: N范龙飞 <long7573@126.com>
      Signed-off-by: NMasami Hiramatsu <mhiramat@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Song Liu <songliubraving@fb.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: e12f03d7 ("perf/core: Implement the 'perf_kprobe' PMU")
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5da13ab8
    • I
      Merge tag 'perf-urgent-for-mingo-4.17-20180409' of... · e31193a9
      Ingo Molnar 提交于
      Merge tag 'perf-urgent-for-mingo-4.17-20180409' 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 the --stdio2/TUI annotate output to include group details,
        be it for a recorded '{a,b,f}' explicit event group or when
        forcing group display using 'perf report --group' for a set of
        events not recorded as a group (Arnaldo Carvalho de Melo)
      
      . Fix display artifacts in the ui browser (base class for the
        annotate and main report/top TUI browser) related to the extra
        title lines work (Arnaldo Carvalho de Melo)
      
      . perf auxtrace refactorings, leftovers from a previously partially
        processed patchset (Adrian Hunter)
      
      . Fix the builtin clang build (Sandipan Das, Arnaldo Carvalho de Melo)
      
      - Synchronize i915_drm.h, silencing a perf build warning and
        in the process automagically adding support for a new ioctl
        command (Arnaldo Carvalho de Melo)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      e31193a9
    • P
      perf/core: Fix use-after-free in uprobe_perf_close() · 621b6d2e
      Prashant Bhole 提交于
      A use-after-free bug was caught by KASAN while running usdt related
      code (BCC project. bcc/tests/python/test_usdt2.py):
      
      	==================================================================
      	BUG: KASAN: use-after-free in uprobe_perf_close+0x222/0x3b0
      	Read of size 4 at addr ffff880384f9b4a4 by task test_usdt2.py/870
      
      	CPU: 4 PID: 870 Comm: test_usdt2.py Tainted: G        W         4.16.0-next-20180409 #215
      	Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
      	Call Trace:
      	 dump_stack+0xc7/0x15b
      	 ? show_regs_print_info+0x5/0x5
      	 ? printk+0x9c/0xc3
      	 ? kmsg_dump_rewind_nolock+0x6e/0x6e
      	 ? uprobe_perf_close+0x222/0x3b0
      	 print_address_description+0x83/0x3a0
      	 ? uprobe_perf_close+0x222/0x3b0
      	 kasan_report+0x1dd/0x460
      	 ? uprobe_perf_close+0x222/0x3b0
      	 uprobe_perf_close+0x222/0x3b0
      	 ? probes_open+0x180/0x180
      	 ? free_filters_list+0x290/0x290
      	 trace_uprobe_register+0x1bb/0x500
      	 ? perf_event_attach_bpf_prog+0x310/0x310
      	 ? probe_event_disable+0x4e0/0x4e0
      	 perf_uprobe_destroy+0x63/0xd0
      	 _free_event+0x2bc/0xbd0
      	 ? lockdep_rcu_suspicious+0x100/0x100
      	 ? ring_buffer_attach+0x550/0x550
      	 ? kvm_sched_clock_read+0x1a/0x30
      	 ? perf_event_release_kernel+0x3e4/0xc00
      	 ? __mutex_unlock_slowpath+0x12e/0x540
      	 ? wait_for_completion+0x430/0x430
      	 ? lock_downgrade+0x3c0/0x3c0
      	 ? lock_release+0x980/0x980
      	 ? do_raw_spin_trylock+0x118/0x150
      	 ? do_raw_spin_unlock+0x121/0x210
      	 ? do_raw_spin_trylock+0x150/0x150
      	 perf_event_release_kernel+0x5d4/0xc00
      	 ? put_event+0x30/0x30
      	 ? fsnotify+0xd2d/0xea0
      	 ? sched_clock_cpu+0x18/0x1a0
      	 ? __fsnotify_update_child_dentry_flags.part.0+0x1b0/0x1b0
      	 ? pvclock_clocksource_read+0x152/0x2b0
      	 ? pvclock_read_flags+0x80/0x80
      	 ? kvm_sched_clock_read+0x1a/0x30
      	 ? sched_clock_cpu+0x18/0x1a0
      	 ? pvclock_clocksource_read+0x152/0x2b0
      	 ? locks_remove_file+0xec/0x470
      	 ? pvclock_read_flags+0x80/0x80
      	 ? fcntl_setlk+0x880/0x880
      	 ? ima_file_free+0x8d/0x390
      	 ? lockdep_rcu_suspicious+0x100/0x100
      	 ? ima_file_check+0x110/0x110
      	 ? fsnotify+0xea0/0xea0
      	 ? kvm_sched_clock_read+0x1a/0x30
      	 ? rcu_note_context_switch+0x600/0x600
      	 perf_release+0x21/0x40
      	 __fput+0x264/0x620
      	 ? fput+0xf0/0xf0
      	 ? do_raw_spin_unlock+0x121/0x210
      	 ? do_raw_spin_trylock+0x150/0x150
      	 ? SyS_fchdir+0x100/0x100
      	 ? fsnotify+0xea0/0xea0
      	 task_work_run+0x14b/0x1e0
      	 ? task_work_cancel+0x1c0/0x1c0
      	 ? copy_fd_bitmaps+0x150/0x150
      	 ? vfs_read+0xe5/0x260
      	 exit_to_usermode_loop+0x17b/0x1b0
      	 ? trace_event_raw_event_sys_exit+0x1a0/0x1a0
      	 do_syscall_64+0x3f6/0x490
      	 ? syscall_return_slowpath+0x2c0/0x2c0
      	 ? lockdep_sys_exit+0x1f/0xaa
      	 ? syscall_return_slowpath+0x1a3/0x2c0
      	 ? lockdep_sys_exit+0x1f/0xaa
      	 ? prepare_exit_to_usermode+0x11c/0x1e0
      	 ? enter_from_user_mode+0x30/0x30
      	random: crng init done
      	 ? __put_user_4+0x1c/0x30
      	 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      	RIP: 0033:0x7f41d95f9340
      	RSP: 002b:00007fffe71e4268 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
      	RAX: 0000000000000000 RBX: 000000000000000d RCX: 00007f41d95f9340
      	RDX: 0000000000000000 RSI: 0000000000002401 RDI: 000000000000000d
      	RBP: 0000000000000000 R08: 00007f41ca8ff700 R09: 00007f41d996dd1f
      	R10: 00007fffe71e41e0 R11: 0000000000000246 R12: 00007fffe71e4330
      	R13: 0000000000000000 R14: fffffffffffffffc R15: 00007fffe71e4290
      
      	Allocated by task 870:
      	 kasan_kmalloc+0xa0/0xd0
      	 kmem_cache_alloc_node+0x11a/0x430
      	 copy_process.part.19+0x11a0/0x41c0
      	 _do_fork+0x1be/0xa20
      	 do_syscall_64+0x198/0x490
      	 entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      
      	Freed by task 0:
      	 __kasan_slab_free+0x12e/0x180
      	 kmem_cache_free+0x102/0x4d0
      	 free_task+0xfe/0x160
      	 __put_task_struct+0x189/0x290
      	 delayed_put_task_struct+0x119/0x250
      	 rcu_process_callbacks+0xa6c/0x1b60
      	 __do_softirq+0x238/0x7ae
      
      	The buggy address belongs to the object at ffff880384f9b480
      	 which belongs to the cache task_struct of size 12928
      
      It occurs because task_struct is freed before perf_event which refers
      to the task and task flags are checked while teardown of the event.
      perf_event_alloc() assigns task_struct to hw.target of perf_event,
      but there is no reference counting for it.
      
      As a fix we get_task_struct() in perf_event_alloc() at above mentioned
      assignment and put_task_struct() in _free_event().
      Signed-off-by: NPrashant Bhole <bhole_prashant_q7@lab.ntt.co.jp>
      Reviewed-by: NOleg Nesterov <oleg@redhat.com>
      Acked-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Cc: <stable@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Fixes: 63b6da39 ("perf: Fix perf_event_exit_task() race")
      Link: http://lkml.kernel.org/r/20180409100346.6416-1-bhole_prashant_q7@lab.ntt.co.jpSigned-off-by: NIngo Molnar <mingo@kernel.org>
      621b6d2e
  2. 09 4月, 2018 4 次提交
    • S
      perf tests clang: Fix function name for clang IR test · fcbd8fa4
      Sandipan Das 提交于
      As stated in tests/llvm-src-base.c, the name of the bpf function should
      be "bpf_func__SyS_epoll_pwait" but this clang test fails as it tries to
      lookup "bpf_func__SyS_epoll_wait".
      
      Before applying patch:
      
      55: builtin clang support                                 :
      55.1: builtin clang compile C source to IR                : FAILED!
      55.2: builtin clang compile C source to ELF object        : Skip
      
      After applying patch:
      
      55: builtin clang support                                 :
      55.1: builtin clang compile C source to IR                : Ok
      55.2: builtin clang compile C source to ELF object        : Ok
      Signed-off-by: NSandipan Das <sandipan@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Fixes: e67d52d4 ("perf clang: Update test case to use real BPF script")
      Link: http://lkml.kernel.org/r/20180404180419.19056-3-sandipan@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fcbd8fa4
    • S
      perf clang: Add support for recent clang versions · 7854e499
      Sandipan Das 提交于
      The clang API calls used by perf have changed in recent releases and
      builds succeed with libclang-3.9 only. This introduces compatibility
      with libclang-4.0 and above.
      
      Without this patch, we will see the following compilation errors with
      libclang-4.0+:
      
       util/c++/clang.cpp: In function ‘clang::CompilerInvocation* perf::createCompilerInvocation(llvm::opt::ArgStringList, llvm::StringRef&, clang::DiagnosticsEngine&)’:
       util/c++/clang.cpp:62:33: error: ‘IK_C’ was not declared in this scope
         Opts.Inputs.emplace_back(Path, IK_C);
                                        ^~~~
       util/c++/clang.cpp: In function ‘std::unique_ptr<llvm::Module> perf::getModuleFromSource(llvm::opt::ArgStringList, llvm::StringRef, llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem>)’:
       util/c++/clang.cpp:75:26: error: no matching function for call to ‘clang::CompilerInstance::setInvocation(clang::CompilerInvocation*)’
         Clang.setInvocation(&*CI);
                                 ^
       In file included from util/c++/clang.cpp:14:0:
       /usr/include/clang/Frontend/CompilerInstance.h:231:8: note: candidate: void clang::CompilerInstance::setInvocation(std::shared_ptr<clang::CompilerInvocation>)
          void setInvocation(std::shared_ptr<CompilerInvocation> Value);
               ^~~~~~~~~~~~~
      
      Committer testing:
      
      Tested on Fedora 27 after installing the clang-devel and llvm-devel
      packages, versions:
      
        # rpm -qa | egrep llvm\|clang
        llvm-5.0.1-6.fc27.x86_64
        clang-libs-5.0.1-5.fc27.x86_64
        clang-5.0.1-5.fc27.x86_64
        clang-tools-extra-5.0.1-5.fc27.x86_64
        llvm-libs-5.0.1-6.fc27.x86_64
        llvm-devel-5.0.1-6.fc27.x86_64
        clang-devel-5.0.1-5.fc27.x86_64
        #
      
      Make sure you don't have some older version lying around in /usr/local,
      etc, then:
      
        $ make LIBCLANGLLVM=1 -C tools/perf install-bin
      
      And in the end perf will be linked agains these libraries:
      
        # ldd ~/bin/perf | egrep -i llvm\|clang
      	libclangAST.so.5 => /lib64/libclangAST.so.5 (0x00007f8bb2eb4000)
      	libclangBasic.so.5 => /lib64/libclangBasic.so.5 (0x00007f8bb29e3000)
      	libclangCodeGen.so.5 => /lib64/libclangCodeGen.so.5 (0x00007f8bb23f7000)
      	libclangDriver.so.5 => /lib64/libclangDriver.so.5 (0x00007f8bb2060000)
      	libclangFrontend.so.5 => /lib64/libclangFrontend.so.5 (0x00007f8bb1d06000)
      	libclangLex.so.5 => /lib64/libclangLex.so.5 (0x00007f8bb1a3e000)
      	libclangTooling.so.5 => /lib64/libclangTooling.so.5 (0x00007f8bb17d4000)
      	libclangEdit.so.5 => /lib64/libclangEdit.so.5 (0x00007f8bb15c5000)
      	libclangSema.so.5 => /lib64/libclangSema.so.5 (0x00007f8bb0cc9000)
      	libclangAnalysis.so.5 => /lib64/libclangAnalysis.so.5 (0x00007f8bb0a23000)
      	libclangParse.so.5 => /lib64/libclangParse.so.5 (0x00007f8bb0725000)
      	libclangSerialization.so.5 => /lib64/libclangSerialization.so.5 (0x00007f8bb039a000)
      	libLLVM-5.0.so => /lib64/libLLVM-5.0.so (0x00007f8bace98000)
      	libclangASTMatchers.so.5 => /lib64/../lib64/libclangASTMatchers.so.5 (0x00007f8bab735000)
      	libclangFormat.so.5 => /lib64/../lib64/libclangFormat.so.5 (0x00007f8bab4b2000)
      	libclangRewrite.so.5 => /lib64/../lib64/libclangRewrite.so.5 (0x00007f8bab2a1000)
      	libclangToolingCore.so.5 => /lib64/../lib64/libclangToolingCore.so.5 (0x00007f8bab08e000)
        #
      Signed-off-by: NSandipan Das <sandipan@linux.vnet.ibm.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Fixes: 00b86691 ("perf clang: Add builtin clang support ant test case")
      Link: http://lkml.kernel.org/r/20180404180419.19056-2-sandipan@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7854e499
    • S
      perf tools: Fix perf builds with clang support · c2fb54a1
      Sandipan Das 提交于
      For libclang, some distro packages provide static libraries (.a) while
      some provide shared libraries (.so). Currently, perf code can only be
      linked with static libraries. This makes perf build possible for both
      cases.
      Signed-off-by: NSandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Fixes: d58ac0bf ("perf build: Add clang and llvm compile and linking support")
      Link: http://lkml.kernel.org/r/20180404180419.19056-1-sandipan@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c2fb54a1
    • A
      perf tools: No need to include namespaces.h in util.h · ad0902e0
      Arnaldo Carvalho de Melo 提交于
      The only thing that is needed there is a forward declaration for 'struct
      nsinfo', so disentanble this, which in turns allows built-in clang
      builds, i.e. 'make LIBCLANGLLVM=1 -C tools/perf'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Sandipan Das <sandipan@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-vq26rsuwq1cqylpcyvq89c84@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ad0902e0
  3. 06 4月, 2018 6 次提交
    • A
      perf hists browser: Remove leftover from row returned from refresh · 94e87a8b
      Arnaldo Carvalho de Melo 提交于
      The per-browser screen refresh routine (ui_browser->refresh()) should
      return the first row that should be cleaned after the rows just printed,
      in case not all rows available on the screen gets filled.
      
      When moving the extra title lines logic from the hists browser to the
      generic ui_browser class, one piece of that logic remained in the hists
      browser and then when going back from the annotate browser to the hists
      browser in a case where fewer lines were displayed in the hists browser,
      for instance when filtering the entries per substring, one line of the
      annotate browser would remain on the screen, fix that.
      
      Example of the screen artifact:
      
      ================================================================================
      Samples: 73K of event 'cycles:ppp', 4000 Hz, Event count (approx.): 45172901394
      Overhead  Shared O  Symbol
         0.30%  [kernel]  [k] __indirect_thunk_start
         0.09%  [kernel]  [k] __x86_indirect_thunk_r10
             │      lfence
      ================================================================================
      
      Here from 'perf top' the view was zoomed with '/thunk' to functions
      having that substring, then the first was annotated and from the
      annotate browser ESC was pressed, then the first lines were overwritten,
      but the 'lfence' line remained due to the off by one bug fixed in this
      cset.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: ef9ff601 ("perf ui browser: Move the extra title lines from the hists browser")
      Link: https://lkml.kernel.org/n/tip-odryfso74eaarm0z3e4v9owx@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      94e87a8b
    • A
      perf hists browser: Show extra_title_lines in the 'D' debug hotkey · fdae6400
      Arnaldo Carvalho de Melo 提交于
      To help in fixing problems in the browser.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-uj0n76yqh5bf98i0edckd47t@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      fdae6400
    • A
      perf auxtrace: Make auxtrace_queues__add_buffer() do CPU filtering · b238db65
      Adrian Hunter 提交于
      In preparation for supporting AUX area sampling buffers,
      auxtrace_queues__add_buffer() needs to be more generic. To that end, move
      CPU filtering into it.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1520327598-1317-8-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b238db65
    • I
      Merge tag 'perf-urgent-for-mingo-4.17-20180406' of... · ce9f85c3
      Ingo Molnar 提交于
      Merge tag 'perf-urgent-for-mingo-4.17-20180406' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
      
      Pull perf/urgent fixes from Arnaldo Carvalho de Melo:
      
      - Show group details on the title line in the annotate browser
        and 'perf annotate --stdio2' output, so that the per-event
        columns can have headers (Arnaldo Carvalho de Melo)
      
      - Fixup vertical line separating metrics from instructions and
        cleaning unused lines at the bottom, both in the annotate TUI
        browser (Arnaldo Carvalho de Melo)
      
      - Remove duplicated 'samples' in lost samples warning in
        'perf report' (Arnaldo Carvalho de Melo)
      
      - Synchronize i915_drm.h, silencing the perf build process,
        automagically adding support for the new DRM_I915_QUERY
        ioctl (Arnaldo Carvalho de Melo)
      
      - Make auxtrace_queues__add_buffer() allocate struct buffer,
        from a patchkit already applied (Adrian Hunter)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ce9f85c3
    • A
      tools headers uapi: Synchronize i915_drm.h · 01f97511
      Arnaldo Carvalho de Melo 提交于
      To pick up the changes in:
      
        c822e059 drm/i915: expose rcs topology through query uAPI
        a446ae2c drm/i915: add query uAPI
      
      This affects 'perf trace', that automagically gets the definition of the
      new I915_QUERY DRM ioctl:
      
        --- /tmp/build/perf/trace/beauty/generated/ioctl/drm_ioctl_array.c.old 2018-04-05 14:38:33.660111995 -0300
        +++ /tmp/build/perf/trace/beauty/generated/ioctl/drm_ioctl_array.c 2018-04-05 14:40:17.923283914 -0300
        @@ -158,4 +158,5 @@
                [DRM_COMMAND_BASE + 0x36] = "I915_PERF_OPEN",
                [DRM_COMMAND_BASE + 0x37] = "I915_PERF_ADD_CONFIG",
                [DRM_COMMAND_BASE + 0x38] = "I915_PERF_REMOVE_CONFIG",
        +       [DRM_COMMAND_BASE + 0x39] = "I915_QUERY",
         };
      
      I.e. on systems where this is used it will appear when, for instance,
      one does a system wide 'perf trace' session looking for ioctl calls,
      just like it does with the previously implemented DRM_I915 ioctls:
      
        # perf trace -e ioctl --filter-pids 2190
      <SNIP>
        4346.232 ( 0.012 ms): gnome-shell/1455 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_BUSY, arg: 0x7fff3b0cd910) = 0
        4346.246 ( 0.002 ms): gnome-shell/1455 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_MADVISE, arg: 0x7fff3b0cd980) = 0
        4346.252 ( 0.002 ms): gnome-shell/1455 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_BUSY, arg: 0x7fff3b0cdb00) = 0
      <SNIP>
      
      This silences this perf tools build warning:
      
        Warning: Kernel ABI header at 'tools/include/uapi/drm/i915_drm.h' differs from latest version at 'include/uapi/drm/i915_drm.h'
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
      Cc: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-5kxuvruuzdbojvf90f8j2wat@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      01f97511
    • A
      perf report: Remove duplicated 'samples' in lost samples warning · 41a43dac
      Arnaldo Carvalho de Melo 提交于
      The following message, emitted when samples are lost due to system
      overload, had one 'samples' too many, ditch it:
      
         Processed 25333 samples and lost 20.88% samples!
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Link: https://lkml.kernel.org/n/tip-oev1469y02hmfere6r2kkxp6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      41a43dac
  4. 05 4月, 2018 5 次提交
    • A
      perf ui browser: Fixup cleaning unused lines at the bottom · caf61de3
      Arnaldo Carvalho de Melo 提交于
      Now that we can have extra title lines we should use ui_browser->rows
      and not ->height when drawing lines, as well as adding
      ui_browser->extra_title_lines to browser->y when cleaning unused lines
      at the bottom, otherwise we end up clobbering with spaces the last line
      just shown by ui_browser->refresh() routine.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: ef9ff601 ("perf ui browser: Move the extra title lines from the hists browser")
      Link: https://lkml.kernel.org/n/tip-dfcpokt1pm5ixm8n9pxwtstz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      caf61de3
    • A
      perf annotate browser: Fixup vertical line separating metrics from instructions · e726c851
      Arnaldo Carvalho de Melo 提交于
      Now that we can have extra title lines we should use ui_browser->rows
      and not ->height when drawing lines, as it will use ui_browser__gotorc()
      and that will take the extra title lines into account, which was causing
      an off by one at the end of the vertical line drawn by
      __ui_browser__vline(), fix it.
      
      The visual effect was that the last line, with status messages, was
      being overwritten by the vertical line, looking like:
      
      Press 'h' for help on│key bindings
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: ef9ff601 ("perf ui browser: Move the extra title lines from the hists browser")
      Link: https://lkml.kernel.org/n/tip-08y1ln3xjn76zvizz1i1dsvn@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e726c851
    • A
      perf annotate: Show group details on the title line · c0459a09
      Arnaldo Carvalho de Melo 提交于
      To match what is shown in the main 'perf report/top' title lines, i.e.
      if a group is being shown, either a real group (recorded with "-e
      '{a,b,c}') or a forced group (using 'perf report --group' for a
      perf.data file recorded without {}) we will show multiple columns,
      one per event, but we were failing to show the group details, so, for:
      
       # perf report --header-only | grep cmdline
       # cmdline : /home/acme/bin/perf record -e {cycles,instructions,cache-misses}
       # perf report --group
      
      The first line was showing just "cycles", now it shows the correct line,
      which is:
      
        Samples: 578  of events 'anon group { cycles, instructions, cache-misses }', 4000 Hz, Event count (approx.): 487421794
        syscall_return_via_sysret  /lib/modules/4.16.0-rc7/build/vmlinux
          0.22   2.97   0.00 │    ↓ jmp    6c
                             │      mov    %cr3,%rdi
          1.33  10.89   4.00 │    ↓ jmp    62
                             │      mov    %rdi,%rax
      <SNIP>
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: 6920e285 ("perf annotate browser: Show extra title line with event information")
      Link: https://lkml.kernel.org/n/tip-i41tqh17c2dabnyzjh99r1oz@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      c0459a09
    • A
      perf auxtrace: Make auxtrace_queues__add_buffer() allocate struct buffer · 0d75f123
      Adrian Hunter 提交于
      In preparation for supporting AUX area sampling buffers,
      auxtrace_queues__add_buffer() needs to be more generic. To that end,
      move memory allocation for struct buffer into it.
      Signed-off-by: NAdrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Link: http://lkml.kernel.org/r/1520327598-1317-7-git-send-email-adrian.hunter@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0d75f123
    • S
      perf/x86/intel: Move regs->flags EXACT bit init · d1e7e602
      Stephane Eranian 提交于
      This patch removes a redundant store on regs->flags introduced
      by commit:
      
        71eb9ee9 ("perf/x86/intel: Fix linear IP of PEBS real_ip on Haswell and later CPUs")
      
      We were clearing the PERF_EFLAGS_EXACT but it was overwritten by
      regs->flags = pebs->flags later on.
      
      The PERF_EFLAGS_EXACT is a software flag using bit 3 of regs->flags.
      X86 marks this bit as Reserved. To make sure this bit is zero before
      we do any IP processing, we clear it explicitly.
      
      Patch also removes the following assignment:
      
      	regs->flags = pebs->flags | (regs->flags & PERF_EFLAGS_VM);
      
      Because there is no regs->flags to preserve anymore because
      set_linear_ip() is not called until later.
      Signed-off-by: NStephane Eranian <eranian@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: kan.liang@intel.com
      Link: http://lkml.kernel.org/r/1522909791-32498-1-git-send-email-eranian@google.com
      [ Improve capitalization, punctuation and clarity of comments. ]
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d1e7e602
  5. 04 4月, 2018 5 次提交
    • I
      Merge tag 'perf-core-for-mingo-4.17-20180403' of... · b89e7914
      Ingo Molnar 提交于
      Merge tag 'perf-core-for-mingo-4.17-20180403' 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:
      
      - Show only failing syscalls with 'perf trace --failure' (Arnaldo Carvalho de Melo)
      
      	e.g: See what 'openat' syscalls are failing:
      
        # perf trace --failure -e openat
         762.323 ( 0.007 ms): VideoCapture/4566 openat(dfd: CWD, filename: /dev/video2) = -1 ENOENT No such file or directory
         <SNIP N /dev/videoN open attempts... sigh, where is that improvised camera lid?!? >
         790.228 ( 0.008 ms): VideoCapture/4566 openat(dfd: CWD, filename: /dev/video63) = -1 ENOENT No such file or directory
        ^C#
      
      - Show information about the event (freq, nr_samples, total period/nr_events) in
        the annotate --tui and --stdio2 'perf annotate' output, similar to the
        first line in the 'perf report --tui', but just for the samples for a
        the annotated symbol (Arnaldo Carvalho de Melo)
      
      - Introduce 'perf version --build-options' to show what features were
        linked, aliased as well as a shorter 'perf -vv' (Jin Yao)
      
      - Add a "dso_size" sort order (Kim Phillips)
      
      - Remove redundant ')' in the tracepoint output in 'perf trace' (Changbin Du)
      
      - Synchronize x86's cpufeatures.h, no effect on toolss (Arnaldo Carvalho de Melo)
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b89e7914
    • C
      perf trace: Remove redundant ')' · 51125a29
      Changbin Du 提交于
      There is a redundant ')' at the tail of each event. So remove it.
      
      $ sudo perf trace --no-syscalls -e 'kmem:*' -a
         899.342 kmem:kfree:(vfs_writev+0xb9) call_site=ffffffff9c453979 ptr=(nil))
         899.344 kmem:kfree:(___sys_recvmsg+0x188) call_site=ffffffff9c9b8b88 ptr=(nil))
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/1520937601-24952-1-git-send-email-changbin.du@intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      51125a29
    • A
      perf annotate stdio2: Print more descriptive event information header · 520d3f01
      Arnaldo Carvalho de Melo 提交于
      To match the recently added event header information to --tui, e.g.:
      
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        Samples: 128  of event 'cycles:ppp', 4000 Hz, Event count (approx.): 48617682
        _raw_spin_lock_irqsave() /proc/kcore
          0.78        nop
          7.03        push   %rbx
          3.12        pushfq
          6.25        pop    %rax
                      nop
                      mov    %rax,%rbx
          3.12        cli
                      nop
                      xor    %eax,%eax
                      mov    $0x1,%edx
         79.69        lock   cmpxchg %edx,(%rdi)
                      test   %eax,%eax
                    ↓ jne    2b
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
                2b:   mov    %eax,%esi
                    → callq  *ffffffffb30eaed0
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-ujy46x7cldyhyxelyf2b9quy@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      520d3f01
    • A
      perf annotate browser: Show extra title line with event information · 6920e285
      Arnaldo Carvalho de Melo 提交于
      So at the top we'll have two lines, like this, from 'perf report':
      
        # perf report --group --ignore-vmlinux
      =====================================================================================================
      Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
      _raw_spin_lock_irqsave  /proc/kcore
      Percent              │      nop
                           │      push   %rbx
        0.00  14.29   0.00 │      pushfq
        9.09   0.00   0.00 │      pop    %rax
        9.09   0.00  20.00 │      nop
                           │      mov    %rax,%rbx
                           │      cli
        4.55   7.14   0.00 │      nop
                           │      xor    %eax,%eax
                           │      mov    $0x1,%edx
                           │      lock   cmpxchg %edx,(%rdi)
       77.27  78.57  70.00 │      test   %eax,%eax
                           │    ↓ jne    2b
                           │      mov    %rbx,%rax
        0.00   0.00  10.00 │      pop    %rbx
                           │    ← retq
                           │2b:   mov    %eax,%esi
                           │    → callq  queued_spin_lock_slowpath
                           │      mov    %rbx,%rax
                           │      pop    %rbx
      Press 'h' for help on│key bindings
      =====================================================================================================
      
       9.09 + 9.09 + 4.55 + 77.27 = 100
      14.29 + 7.14 + 78.57 = 100
      20 + 70 + 10 = 100
      
      We can do the math by using 't' to toggle from 'percent' to nr
      
      =====================================================================================================
      Samples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
      _raw_spin_lock_irqsave  /proc/kcore
      Period                              │      nop
                                          │      push   %rbx
                0       79273           0 │      pushfq
           190455           0           0 │      pop    %rax
           198038           0        3045 │      nop
                                          │      mov    %rax,%rbx
                                          │      cli
           217233       32562           0 │      nop
                                          │      xor    %eax,%eax
                                          │      mov    $0x1,%edx
                                          │      lock   cmpxchg %edx,(%rdi)
          3421649      979174       28273 │      test   %eax,%eax
                                          │    ↓ jne    2b
                                          │      mov    %rbx,%rax
                0           0        5193 │      pop    %rbx
                                          │    ← retq
                                          │2b:   mov    %eax,%esi
                                          │    → callq  queued_spin_lock_slowpath
                                          │      mov    %rbx,%rax
                                          │      pop    %rbx
      Press 'h' for help on│key bindings
      =====================================================================================================
      
      79273 + 190455 + 198038 + 3045 + 217233 + 32562 + 3421649 + 979174 + 28273 + 5193 = 5154895
      
      Or number of samples:
      
      =====================================================================================================
      ooSamples: 46  of events 'cycles', 4000 Hz, Event count (approx.): 5154895
      _raw_spin_lock_irqsave  /proc/kcore
      Samples              │      nop
                           │      push   %rbx
           0      2      0 │      pushfq
           2      0      0 │      pop    %rax
           2      0      2 │      nop
                           │      mov    %rax,%rbx
                           │      cli
           1      1      0 │      nop
                           │      xor    %eax,%eax
                           │      mov    $0x1,%edx
                           │      lock   cmpxchg %edx,(%rdi)
          17     11      7 │      test   %eax,%eax
                           │    ↓ jne    2b
                           │      mov    %rbx,%rax
           0      0      1 │      pop    %rbx
                           │    ← retq
                           │2b:   mov    %eax,%esi
                           │    → callq  queued_spin_lock_slowpath
                           │      mov    %rbx,%rax
                           │      pop    %rbx
      Press 'h' for help on key bindings
      =====================================================================================================
      
      2 + 2 + 2 + 2 + 1 + 1 + 17 + 11 + 7 + 1 = 46
      Suggested-by: NMartin Liška <mliska@suse.cz>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-ezccyxld50wtwyt66np6aomo@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6920e285
    • A
      perf annotate: Introduce annotation__scnprintf_samples_period() method · b213eac2
      Arnaldo Carvalho de Melo 提交于
      To print a string using the total period (nr_events) and the number of
      samples for a given annotation, i.e. for a given symbol, the counterpart
      to hists__scnprintf_samples_period(), that is for all the samples in a
      session (be it a live session, think 'perf top' or a perf.data file,
      think 'perf report').
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-goj2wu4fxutc8vd46mw3yg14@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b213eac2
  6. 03 4月, 2018 16 次提交
    • A
      perf ui browser: Move the extra title lines from the hists browser · ef9ff601
      Arnaldo Carvalho de Melo 提交于
      This will be useful for the annotate browser as well, that wants to have
      extra title lines, i.e. the current ui_browser unconditionally reserves
      the first line for a browser title and the last one for status messages.
      
      But some browsers, like the buckets one (hists browser) needs extra
      lines to show headers, allowing it to be shown or not, press 'H' in
      'perf top' or 'perf report' to see this feature.
      
      So move that logic to the core ui_browser used by the hists_browser
      ('perf top' and 'perf report' main interface) so that it can be used by
      the annotate browser too.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-r38xm3ut37ulbg1o5tn5iise@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ef9ff601
    • A
      perf hists: Move hists__scnprintf_title() away from the TUI code · 25c312db
      Arnaldo Carvalho de Melo 提交于
      The previous patch made this function useful to non-TUI parts of the
      tools, but left it where the function from what it was carved, so that
      the patch showed more clearly the process.
      
      Now just move it outside the TUI parts so that we can finally use it,
      even when the TUI code doesn't get built/linked.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-hqj7hvcr3mu5lvcqp3cssio6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      25c312db
    • A
      perf hists: Introduce hists__scnprint_title() · 967a464a
      Arnaldo Carvalho de Melo 提交于
      That is not use any struct hists_browser internals, so that it can be
      shared with the other UIs and tools.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-w8mczjnqnbcj9yzfkv9ja6ro@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      967a464a
    • A
      perf hists browser: Rename perf_evsel_browser_title to a more descriptive name · f016d24a
      Arnaldo Carvalho de Melo 提交于
      Rename it to hists_browser__scnprintf_title() to better reflect that it
      provides a scnprintf-like function operating on a hists_browser
      instance.
      
      This paves the way to have a non-hists_browser specific function to
      scnprintf format a title with per evsel information to use in other
      tools or UIs.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196935
      Link: https://lkml.kernel.org/n/tip-sntpyzxsnme9jvuz2qntwoh2@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f016d24a
    • L
      Merge branch 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux · 642e7fd2
      Linus Torvalds 提交于
      Pull removal of in-kernel calls to syscalls from Dominik Brodowski:
       "System calls are interaction points between userspace and the kernel.
        Therefore, system call functions such as sys_xyzzy() or
        compat_sys_xyzzy() should only be called from userspace via the
        syscall table, but not from elsewhere in the kernel.
      
        At least on 64-bit x86, it will likely be a hard requirement from
        v4.17 onwards to not call system call functions in the kernel: It is
        better to use use a different calling convention for system calls
        there, where struct pt_regs is decoded on-the-fly in a syscall wrapper
        which then hands processing over to the actual syscall function. This
        means that only those parameters which are actually needed for a
        specific syscall are passed on during syscall entry, instead of
        filling in six CPU registers with random user space content all the
        time (which may cause serious trouble down the call chain). Those
        x86-specific patches will be pushed through the x86 tree in the near
        future.
      
        Moreover, rules on how data may be accessed may differ between kernel
        data and user data. This is another reason why calling sys_xyzzy() is
        generally a bad idea, and -- at most -- acceptable in arch-specific
        code.
      
        This patchset removes all in-kernel calls to syscall functions in the
        kernel with the exception of arch/. On top of this, it cleans up the
        three places where many syscalls are referenced or prototyped, namely
        kernel/sys_ni.c, include/linux/syscalls.h and include/linux/compat.h"
      
      * 'syscalls-next' of git://git.kernel.org/pub/scm/linux/kernel/git/brodo/linux: (109 commits)
        bpf: whitelist all syscalls for error injection
        kernel/sys_ni: remove {sys_,sys_compat} from cond_syscall definitions
        kernel/sys_ni: sort cond_syscall() entries
        syscalls/x86: auto-create compat_sys_*() prototypes
        syscalls: sort syscall prototypes in include/linux/compat.h
        net: remove compat_sys_*() prototypes from net/compat.h
        syscalls: sort syscall prototypes in include/linux/syscalls.h
        kexec: move sys_kexec_load() prototype to syscalls.h
        x86/sigreturn: use SYSCALL_DEFINE0
        x86: fix sys_sigreturn() return type to be long, not unsigned long
        x86/ioport: add ksys_ioperm() helper; remove in-kernel calls to sys_ioperm()
        mm: add ksys_readahead() helper; remove in-kernel calls to sys_readahead()
        mm: add ksys_mmap_pgoff() helper; remove in-kernel calls to sys_mmap_pgoff()
        mm: add ksys_fadvise64_64() helper; remove in-kernel call to sys_fadvise64_64()
        fs: add ksys_fallocate() wrapper; remove in-kernel calls to sys_fallocate()
        fs: add ksys_p{read,write}64() helpers; remove in-kernel calls to syscalls
        fs: add ksys_truncate() wrapper; remove in-kernel calls to sys_truncate()
        fs: add ksys_sync_file_range helper(); remove in-kernel calls to syscall
        kernel: add ksys_setsid() helper; remove in-kernel call to sys_setsid()
        kernel: add ksys_unshare() helper; remove in-kernel calls to sys_unshare()
        ...
      642e7fd2
    • O
      bitmap: fix memset optimization on big-endian systems · 21035965
      Omar Sandoval 提交于
      Commit 2a98dc02 ("include/linux/bitmap.h: turn bitmap_set and
      bitmap_clear into memset when possible") introduced an optimization to
      bitmap_{set,clear}() which uses memset() when the start and length are
      constants aligned to a byte.
      
      This is wrong on big-endian systems; our bitmaps are arrays of unsigned
      long, so bit n is not at byte n / 8 in memory.  This was caught by the
      Btrfs selftests, but the bitmap selftests also fail when run on a
      big-endian machine.
      
      We can still use memset if the start and length are aligned to an
      unsigned long, so do that on big-endian.  The same problem applies to
      the memcmp in bitmap_equal(), so fix it there, too.
      
      Fixes: 2a98dc02 ("include/linux/bitmap.h: turn bitmap_set and bitmap_clear into memset when possible")
      Fixes: 2c6deb01 ("bitmap: use memcmp optimisation in more situations")
      Cc: stable@kernel.org
      Reported-by: N"Erhard F." <erhard_f@mailbox.org>
      Cc: Matthew Wilcox <mawilcox@microsoft.com>
      Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Signed-off-by: NOmar Sandoval <osandov@fb.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      21035965
    • L
      Merge tag 'arch-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic · f5a8eb63
      Linus Torvalds 提交于
      Pul removal of obsolete architecture ports from Arnd Bergmann:
       "This removes the entire architecture code for blackfin, cris, frv,
        m32r, metag, mn10300, score, and tile, including the associated device
        drivers.
      
        I have been working with the (former) maintainers for each one to
        ensure that my interpretation was right and the code is definitely
        unused in mainline kernels. Many had fond memories of working on the
        respective ports to start with and getting them included in upstream,
        but also saw no point in keeping the port alive without any users.
      
        In the end, it seems that while the eight architectures are extremely
        different, they all suffered the same fate: There was one company in
        charge of an SoC line, a CPU microarchitecture and a software
        ecosystem, which was more costly than licensing newer off-the-shelf
        CPU cores from a third party (typically ARM, MIPS, or RISC-V). It
        seems that all the SoC product lines are still around, but have not
        used the custom CPU architectures for several years at this point. In
        contrast, CPU instruction sets that remain popular and have actively
        maintained kernel ports tend to all be used across multiple licensees.
      
        [ See the new nds32 port merged in the previous commit for the next
          generation of "one company in charge of an SoC line, a CPU
          microarchitecture and a software ecosystem"   - Linus ]
      
        The removal came out of a discussion that is now documented at
        https://lwn.net/Articles/748074/. Unlike the original plans, I'm not
        marking any ports as deprecated but remove them all at once after I
        made sure that they are all unused. Some architectures (notably tile,
        mn10300, and blackfin) are still being shipped in products with old
        kernels, but those products will never be updated to newer kernel
        releases.
      
        After this series, we still have a few architectures without mainline
        gcc support:
      
         - unicore32 and hexagon both have very outdated gcc releases, but the
           maintainers promised to work on providing something newer. At least
           in case of hexagon, this will only be llvm, not gcc.
      
         - openrisc, risc-v and nds32 are still in the process of finishing
           their support or getting it added to mainline gcc in the first
           place. They all have patched gcc-7.3 ports that work to some
           degree, but complete upstream support won't happen before gcc-8.1.
           Csky posted their first kernel patch set last week, their situation
           will be similar
      
        [ Palmer Dabbelt points out that RISC-V support is in mainline gcc
          since gcc-7, although gcc-7.3.0 is the recommended minimum  - Linus ]"
      
      This really says it all:
      
       2498 files changed, 95 insertions(+), 467668 deletions(-)
      
      * tag 'arch-removal' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic: (74 commits)
        MAINTAINERS: UNICORE32: Change email account
        staging: iio: remove iio-trig-bfin-timer driver
        tty: hvc: remove tile driver
        tty: remove bfin_jtag_comm and hvc_bfin_jtag drivers
        serial: remove tile uart driver
        serial: remove m32r_sio driver
        serial: remove blackfin drivers
        serial: remove cris/etrax uart drivers
        usb: Remove Blackfin references in USB support
        usb: isp1362: remove blackfin arch glue
        usb: musb: remove blackfin port
        usb: host: remove tilegx platform glue
        pwm: remove pwm-bfin driver
        i2c: remove bfin-twi driver
        spi: remove blackfin related host drivers
        watchdog: remove bfin_wdt driver
        can: remove bfin_can driver
        mmc: remove bfin_sdh driver
        input: misc: remove blackfin rotary driver
        input: keyboard: remove bf54x driver
        ...
      f5a8eb63
    • L
      Merge tag 'nds32-for-linus-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux · c9297d28
      Linus Torvalds 提交于
      Pull nds32 architecture support from Greentime Hu:
       "This contains the core nds32 Linux port (including interrupt
        controller driver and timer driver), which has been through seven
        rounds of review on mailing list.
      
        It is able to boot to shell and passes most LTP-2017 testsuites in
        nds32 AE3XX platform:
      
          Total Tests: 1901
          Total Skipped Tests: 618
          Total Failures: 78"
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      
      * tag 'nds32-for-linus-4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/greentime/linux: (44 commits)
        nds32: To use the generic dump_stack()
        nds32: fix building failed if using elf toolchain.
        nios2: add ioremap_nocache declaration before include asm-generic/io.h.
        nds32: fix building failed if using older version gcc.
        dt-bindings: timer: Add andestech atcpit100 timer binding doc
        clocksource/drivers/atcpit100: VDSO support
        clocksource/drivers/atcpit100: Add andestech atcpit100 timer
        net: faraday add nds32 support.
        irqchip: Andestech Internal Vector Interrupt Controller driver
        dt-bindings: interrupt-controller: Andestech Internal Vector Interrupt Controller
        dt-bindings: nds32 SoC Bindings
        dt-bindings: nds32 L2 cache controller Bindings
        dt-bindings: nds32 CPU Bindings
        MAINTAINERS: Add nds32
        nds32: Build infrastructure
        nds32: defconfig
        nds32: Miscellaneous header files
        nds32: Device tree support
        nds32: Generic timers support
        nds32: Loadable modules
        ...
      c9297d28
    • L
      Merge tag 'm68k-for-v4.17-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k · 17e3cd22
      Linus Torvalds 提交于
      Pull m68k updates from Geert Uytterhoeven:
      
       - Macintosh enhancements and fixes
      
       - Remove useless memory layout printing using hashed pointers
      
       - Add missing Amiga Zorro bus DMA mask
      
       - Small fixes and cleanups
      
       - Defconfig updates
      
      * tag 'm68k-for-v4.17-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k:
        m68k/mac: Remove bogus "FIXME" comment
        m68k/mac: Enable RTC for 100-series PowerBooks
        m68k/mac: Clean up whitespace and remove redundant parentheses
        m68k/defconfig: Update defconfigs for v4.16-rc5
        zorro: Set up z->dev.dma_mask for the DMA API
        m68k/time: Stop validating rtc_time in .read_time
        m68k/mm: Stop printing the virtual memory layout
        macintosh/via-pmu68k: Initialize PMU driver with setup_arch and arch_initcall
        m68k/mac: Fix apparent race condition in Baboon interrupt dispatch
        m68k/mac: Enable PDMA support for PowerBook 190
      17e3cd22
    • L
      Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · bc16d405
      Linus Torvalds 提交于
      Pull EFI updates from Ingo Molnar:
       "The main EFI changes in this cycle were:
      
         - Fix the apple-properties code (Andy Shevchenko)
      
         - Add WARN() on arm64 if UEFI Runtime Services corrupt the reserved
           x18 register (Ard Biesheuvel)
      
         - Use efi_switch_mm() on x86 instead of manipulating %cr3 directly
           (Sai Praneeth)
      
         - Fix early memremap leak in ESRT code (Ard Biesheuvel)
      
         - Switch to L"xxx" notation for wide string literals (Ard Biesheuvel)
      
         - ... plus misc other cleanups and bugfixes"
      
      * 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/efi: Use efi_switch_mm() rather than manually twiddling with %cr3
        x86/efi: Replace efi_pgd with efi_mm.pgd
        efi: Use string literals for efi_char16_t variable initializers
        efi/esrt: Fix handling of early ESRT table mapping
        efi: Use efi_mm in x86 as well as ARM
        efi: Make const array 'apple' static
        efi/apple-properties: Use memremap() instead of ioremap()
        efi: Reorder pr_notice() with add_device_randomness() call
        x86/efi: Replace GFP_ATOMIC with GFP_KERNEL in efi_query_variable_store()
        efi/arm64: Check whether x18 is preserved by runtime services calls
        efi/arm*: Stop printing addresses of virtual mappings
        efi/apple-properties: Remove redundant attribute initialization from unmarshal_key_value_pairs()
        efi/arm*: Only register page tables when they exist
      bc16d405
    • L
      Merge branch 'x86-dma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 2fcd2b30
      Linus Torvalds 提交于
      Pull x86 dma mapping updates from Ingo Molnar:
       "This tree, by Christoph Hellwig, switches over the x86 architecture to
        the generic dma-direct and swiotlb code, and also unifies more of the
        dma-direct code between architectures. The now unused x86-only
        primitives are removed"
      
      * 'x86-dma-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        dma-mapping: Don't clear GFP_ZERO in dma_alloc_attrs
        swiotlb: Make swiotlb_{alloc,free}_buffer depend on CONFIG_DMA_DIRECT_OPS
        dma/swiotlb: Remove swiotlb_{alloc,free}_coherent()
        dma/direct: Handle force decryption for DMA coherent buffers in common code
        dma/direct: Handle the memory encryption bit in common code
        dma/swiotlb: Remove swiotlb_set_mem_attributes()
        set_memory.h: Provide set_memory_{en,de}crypted() stubs
        x86/dma: Remove dma_alloc_coherent_gfp_flags()
        iommu/intel-iommu: Enable CONFIG_DMA_DIRECT_OPS=y and clean up intel_{alloc,free}_coherent()
        iommu/amd_iommu: Use CONFIG_DMA_DIRECT_OPS=y and dma_direct_{alloc,free}()
        x86/dma/amd_gart: Use dma_direct_{alloc,free}()
        x86/dma/amd_gart: Look at dev->coherent_dma_mask instead of GFP_DMA
        x86/dma: Use generic swiotlb_ops
        x86/dma: Use DMA-direct (CONFIG_DMA_DIRECT_OPS=y)
        x86/dma: Remove dma_alloc_coherent_mask()
      2fcd2b30
    • L
      Merge branch 'sched-wait-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · ce6eba3d
      Linus Torvalds 提交于
      Pull wait_var_event updates from Ingo Molnar:
       "This introduces the new wait_var_event() API, which is a more flexible
        waiting primitive than wait_on_atomic_t().
      
        All wait_on_atomic_t() users are migrated over to the new API and
        wait_on_atomic_t() is removed. The migration fixes one bug and should
        result in no functional changes for the other usecases"
      
      * 'sched-wait-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        sched/wait: Improve __var_waitqueue() code generation
        sched/wait: Remove the wait_on_atomic_t() API
        sched/wait, arch/mips: Fix and convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, fs/ocfs2: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, fs/nfs: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, fs/fscache: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, fs/btrfs: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, fs/afs: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, drivers/media: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait, drivers/drm: Convert wait_on_atomic_t() usage to the new wait_var_event() API
        sched/wait: Introduce wait_var_event()
      ce6eba3d
    • L
      Merge branch 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · a5532439
      Linus Torvalds 提交于
      Pull x86 timer updates from Ingo Molnar:
       "Two changes: add the new convert_art_ns_to_tsc() API for upcoming
        Intel Goldmont+ drivers, and remove the obsolete rdtscll() API"
      
      * 'x86-timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/tsc: Get rid of rdtscll()
        x86/tsc: Convert ART in nanoseconds to TSC
      a5532439
    • L
      Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · cea061e4
      Linus Torvalds 提交于
      Pull x86 platform updates from Ingo Molnar:
       "The main changes in this cycle were:
      
         - Add "Jailhouse" hypervisor support (Jan Kiszka)
      
         - Update DeviceTree support (Ivan Gorinov)
      
         - Improve DMI date handling (Andy Shevchenko)"
      
      * 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/PCI: Fix a potential regression when using dmi_get_bios_year()
        firmware/dmi_scan: Uninline dmi_get_bios_year() helper
        x86/devicetree: Use CPU description from Device Tree
        of/Documentation: Specify local APIC ID in "reg"
        MAINTAINERS: Add entry for Jailhouse
        x86/jailhouse: Allow to use PCI_MMCONFIG without ACPI
        x86: Consolidate PCI_MMCONFIG configs
        x86: Align x86_64 PCI_MMCONFIG with 32-bit variant
        x86/jailhouse: Enable PCI mmconfig access in inmates
        PCI: Scan all functions when running over Jailhouse
        jailhouse: Provide detection for non-x86 systems
        x86/devicetree: Fix device IRQ settings in DT
        x86/devicetree: Initialize device tree before using it
        pci: Simplify code by using the new dmi_get_bios_year() helper
        ACPI/sleep: Simplify code by using the new dmi_get_bios_year() helper
        x86/pci: Simplify code by using the new dmi_get_bios_year() helper
        dmi: Introduce the dmi_get_bios_year() helper function
        x86/platform/quark: Re-use DEFINE_SHOW_ATTRIBUTE() macro
        x86/platform/atom: Re-use DEFINE_SHOW_ATTRIBUTE() macro
      cea061e4
    • L
      Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · d22fff81
      Linus Torvalds 提交于
      Pull x86 mm updates from Ingo Molnar:
      
       - Extend the memmap= boot parameter syntax to allow the redeclaration
         and dropping of existing ranges, and to support all e820 range types
         (Jan H. Schönherr)
      
       - Improve the W+X boot time security checks to remove false positive
         warnings on Xen (Jan Beulich)
      
       - Support booting as Xen PVH guest (Juergen Gross)
      
       - Improved 5-level paging (LA57) support, in particular it's possible
         now to have a single kernel image for both 4-level and 5-level
         hardware (Kirill A. Shutemov)
      
       - AMD hardware RAM encryption support (SME/SEV) fixes (Tom Lendacky)
      
       - Preparatory commits for hardware-encrypted RAM support on Intel CPUs.
         (Kirill A. Shutemov)
      
       - Improved Intel-MID support (Andy Shevchenko)
      
       - Show EFI page tables in page_tables debug files (Andy Lutomirski)
      
       - ... plus misc fixes and smaller cleanups
      
      * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (56 commits)
        x86/cpu/tme: Fix spelling: "configuation" -> "configuration"
        x86/boot: Fix SEV boot failure from change to __PHYSICAL_MASK_SHIFT
        x86/mm: Update comment in detect_tme() regarding x86_phys_bits
        x86/mm/32: Remove unused node_memmap_size_bytes() & CONFIG_NEED_NODE_MEMMAP_SIZE logic
        x86/mm: Remove pointless checks in vmalloc_fault
        x86/platform/intel-mid: Add special handling for ACPI HW reduced platforms
        ACPI, x86/boot: Introduce the ->reduced_hw_early_init() ACPI callback
        ACPI, x86/boot: Split out acpi_generic_reduce_hw_init() and export
        x86/pconfig: Provide defines and helper to run MKTME_KEY_PROG leaf
        x86/pconfig: Detect PCONFIG targets
        x86/tme: Detect if TME and MKTME is activated by BIOS
        x86/boot/compressed/64: Handle 5-level paging boot if kernel is above 4G
        x86/boot/compressed/64: Use page table in trampoline memory
        x86/boot/compressed/64: Use stack from trampoline memory
        x86/boot/compressed/64: Make sure we have a 32-bit code segment
        x86/mm: Do not use paravirtualized calls in native_set_p4d()
        kdump, vmcoreinfo: Export pgtable_l5_enabled value
        x86/boot/compressed/64: Prepare new top-level page table for trampoline
        x86/boot/compressed/64: Set up trampoline memory
        x86/boot/compressed/64: Save and restore trampoline memory
        ...
      d22fff81
    • L
      Merge branch 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 986b37c0
      Linus Torvalds 提交于
      Pull x86 cleanups and msr updates from Ingo Molnar:
       "The main change is a performance/latency improvement to /dev/msr
        access. The rest are misc cleanups"
      
      * 'x86-cleanups-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
        x86/msr: Make rdmsrl_safe_on_cpu() scheduling safe as well
        x86/cpuid: Allow cpuid_read() to schedule
        x86/msr: Allow rdmsr_safe_on_cpu() to schedule
        x86/rtc: Stop using deprecated functions
        x86/dumpstack: Unify show_regs()
        x86/fault: Do not print IP in show_fault_oops()
        x86/MSR: Move native_* variants to msr.h
      986b37c0