1. 27 4月, 2018 16 次提交
  2. 26 4月, 2018 1 次提交
  3. 25 4月, 2018 3 次提交
    • K
      perf stat: Fix duplicate PMU name for interval print · 80ee8c58
      Kan Liang 提交于
      PMU name is printed repeatedly for interval print, for example:
      
        perf stat --no-merge -e 'unc_m_clockticks' -a -I 1000
        #           time             counts unit events
           1.001053069        243,702,144      unc_m_clockticks [uncore_imc_4]
           1.001053069        244,268,304      unc_m_clockticks [uncore_imc_2]
           1.001053069        244,427,386      unc_m_clockticks [uncore_imc_0]
           1.001053069        244,583,760      unc_m_clockticks [uncore_imc_5]
           1.001053069        244,738,971      unc_m_clockticks [uncore_imc_3]
           1.001053069        244,880,309      unc_m_clockticks [uncore_imc_1]
           2.002024821        240,818,200      unc_m_clockticks [uncore_imc_4] [uncore_imc_4]
           2.002024821        240,767,812      unc_m_clockticks [uncore_imc_2] [uncore_imc_2]
           2.002024821        240,764,215      unc_m_clockticks [uncore_imc_0] [uncore_imc_0]
           2.002024821        240,759,504      unc_m_clockticks [uncore_imc_5] [uncore_imc_5]
           2.002024821        240,755,992      unc_m_clockticks [uncore_imc_3] [uncore_imc_3]
           2.002024821        240,750,403      unc_m_clockticks [uncore_imc_1] [uncore_imc_1]
      
      For each print, the PMU name is unconditionally appended to the
      counter->name.
      
      Need to check the counter->name first. If the PMU name is already
      appended, do nothing.
      
      Committer notes:
      
      Add and use perf_evsel->uniquified_name bool instead of doing the more
      expensive strstr(event->name, pmu->name).
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Fixes: 8c5421c0 ("perf pmu: Display pmu name when printing unmerged events in stat")
      Link: http://lkml.kernel.org/r/1524594014-79243-5-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      80ee8c58
    • K
      perf evsel: Only fall back group read for leader · 121f325f
      Kan Liang 提交于
      Perf doesn't support mixed events from different PMUs (except software
      event) in a group. The perf stat should output <not counted>/<not
      supported> for all events, but it doesn't. For example,
      
        perf stat -e '{cycles,uncore_imc_5/umask=0xF,event=0x4/,instructions}'
             <not counted>      cycles
             <not supported>    uncore_imc_5/umask=0xF,event=0x4/
                 1,024,300      instructions
      
      If perf fails to open an event, it doesn't error out directly. It will
      disable some features and retry, until the event is opened or all
      features are disabled. The disabled features will not be re-enabled. The
      group read is one of these features.
      
      For the example as above, the IMC event and the leader event "cycles"
      are from different PMUs. Opening the IMC event must fail. The group read
      feature must be disabled for IMC event and the followed event
      "instructions". The "instructions" event has the same PMU as the leader
      "cycles". It can be opened successfully. Since the group read feature
      has been disabled, the "instructions" event will be read as a single
      event, which definitely has a value.
      
      The group read fallback is still useful for the case which kernel
      doesn't support group read. It is good enough to be handled only by the
      leader.
      
      For the fallback request from members, it must be caused by an error.
      The fallback only breaks the semantics of group.  Limit the group read
      fallback only for the leader.
      
      Committer testing:
      
      On a broadwell t450s notebook:
      
      Before:
      
        # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1
      
        Performance counter stats for 'sleep 1':
      
           <not counted>      cycles
         <not supported>      unc_cbo_cache_lookup.read_i
                 818,206      instructions
      
             1.003170887 seconds time elapsed
      
        Some events weren't counted. Try disabling the NMI watchdog:
      	echo 0 > /proc/sys/kernel/nmi_watchdog
      	perf stat ...
      	echo 1 > /proc/sys/kernel/nmi_watchdog
      
      After:
      
        # perf stat -e '{cycles,unc_cbo_cache_lookup.read_i,instructions}' sleep 1
      
        Performance counter stats for 'sleep 1':
      
           <not counted>      cycles
         <not supported>      unc_cbo_cache_lookup.read_i
           <not counted>      instructions
      
             1.001380511 seconds time elapsed
      
        Some events weren't counted. Try disabling the NMI watchdog:
      	echo 0 > /proc/sys/kernel/nmi_watchdog
      	perf stat ...
      	echo 1 > /proc/sys/kernel/nmi_watchdog
        #
      Reported-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Fixes:  82bf311e ("perf stat: Use group read for event groups")
      Link: http://lkml.kernel.org/r/1524594014-79243-3-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      121f325f
    • K
      perf pmu: Fix core PMU alias list for X86 platform · 292c34c1
      Kan Liang 提交于
      When counting uncore event with alias, core event is mistakenly
      involved, for example:
      
        perf stat --no-merge -e "unc_m_cas_count.all" -C0  sleep 1
      
        Performance counter stats for 'CPU(s) 0':
      
                       0      unc_m_cas_count.all [uncore_imc_4]
                       0      unc_m_cas_count.all [uncore_imc_2]
                       0      unc_m_cas_count.all [uncore_imc_0]
                 153,640      unc_m_cas_count.all [cpu]
                       0      unc_m_cas_count.all [uncore_imc_5]
                  25,026      unc_m_cas_count.all [uncore_imc_3]
                       0      unc_m_cas_count.all [uncore_imc_1]
      
             1.001447890 seconds time elapsed
      
      The reason is that current implementation doesn't check PMU name of a
      event when adding its alias into the alias list for core PMU. The
      uncore event aliases are mistakenly added.
      
      This bug was introduced in:
        commit 14b22ae0 ("perf pmu: Add helper function is_pmu_core to
        detect PMU CORE devices")
      
      Checking the PMU name for all PMUs on X86 and other architectures except
      ARM.
      There is no behavior change for ARM.
      Signed-off-by: NKan Liang <kan.liang@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Agustin Vega-Frias <agustinv@codeaurora.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ganapatrao Kulkarni <ganapatrao.kulkarni@cavium.com>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
      Cc: Will Deacon <will.deacon@arm.com>
      Fixes: 14b22ae0 ("perf pmu: Add helper function is_pmu_core to detect PMU CORE devices")
      Link: http://lkml.kernel.org/r/1524594014-79243-1-git-send-email-kan.liang@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      292c34c1
  4. 23 4月, 2018 5 次提交
  5. 19 4月, 2018 3 次提交
  6. 17 4月, 2018 2 次提交
    • T
      perf list: Add s390 support for detailed/verbose PMU event description · 038586c3
      Thomas Richter 提交于
      'perf list' with flags -d and -v print a description (-d) or a very
      verbose explanation (-v) of CPU specific counter events.  These
      descriptions are provided with the json files in directory
      pmu-events/arch/s390/*.json.
      
      Display of these descriptions on s390 requires the corresponding json
      files.
      
      On s390 this does not work because function is_pmu_core() does not
      detect the s390 directory name where the CPU specific events are listed.
      On x86 it is:
      
        /sys/bus/event_source/devices/cpu
      
      whereas on s390 it is:
      
        /sys/bus/event_source/devices/cpum_cf
        /sys/bus/event_source/devices/cpum_sf
      
      Fix this by adding s390 directory name testing to function
      is_pmu_core(). This is the same approach as taken for the ARM platform.
      
      Output before:
      
      [root@s35lp76 perf]# ./perf list -d pmu
      List of pre-defined events (to be used in -e):
      
        cpum_cf/AES_BLOCKED_CYCLES/      [Kernel PMU event]
        cpum_cf/AES_BLOCKED_FUNCTIONS/   [Kernel PMU event]
        cpum_cf/AES_CYCLES/              [Kernel PMU event]
        cpum_cf/AES_FUNCTIONS/           [Kernel PMU event]
        ....
        cpum_cf/TX_NC_TEND/              [Kernel PMU event]
        cpum_cf/VX_BCD_EXECUTION_SLOTS/  [Kernel PMU event]
        cpum_sf/SF_CYCLES_BASIC/         [Kernel PMU event]
      
      Output after:
      
      [root@s35lp76 perf]# ./perf list -d pmu
      List of pre-defined events (to be used in -e):
      
        cpum_cf/AES_BLOCKED_CYCLES/      [Kernel PMU event]
        cpum_cf/AES_BLOCKED_FUNCTIONS/   [Kernel PMU event]
        cpum_cf/AES_CYCLES/              [Kernel PMU event]
        cpum_cf/AES_FUNCTIONS/           [Kernel PMU event]
        ....
        cpum_cf/TX_NC_TEND/              [Kernel PMU event]
        cpum_cf/VX_BCD_EXECUTION_SLOTS/  [Kernel PMU event]
        cpum_sf/SF_CYCLES_BASIC/         [Kernel PMU event]
      
      3906:
        bcd_dfp_execution_slots
             [BCD DFP Execution Slots]
        decimal_instructions
             [Decimal Instructions]
        dtlb2_gpage_writes
             [DTLB2 GPAGE Writes]
        dtlb2_hpage_writes
             [DTLB2 HPAGE Writes]
        dtlb2_misses
             [DTLB2 Misses]
        dtlb2_writes
             [DTLB2 Writes]
        itlb2_misses
             [ITLB2 Misses]
        itlb2_writes
             [ITLB2 Writes]
        l1c_tlb2_misses
             [L1C TLB2 Misses]
        .....
      
      cfvn 3:
        cpu_cycles
             [CPU Cycles]
        instructions
             [Instructions]
        l1d_dir_writes
             [L1D Directory Writes]
        l1d_penalty_cycles
             [L1D Penalty Cycles]
        l1i_dir_writes
             [L1I Directory Writes]
        l1i_penalty_cycles
             [L1I Penalty Cycles]
        problem_state_cpu_cycles
             [Problem State CPU Cycles]
        problem_state_instructions
             [Problem State Instructions]
        ....
      
      csvn generic:
        aes_blocked_cycles
             [AES Blocked Cycles]
        aes_blocked_functions
             [AES Blocked Functions]
        aes_cycles
             [AES Cycles]
        aes_functions
             [AES Functions]
        dea_blocked_cycles
             [DEA Blocked Cycles]
        dea_blocked_functions
             [DEA Blocked Functions]
        ....
      Signed-off-by: NThomas Richter <tmricht@linux.vnet.ibm.com>
      Reviewed-by: NHendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180416132314.33249-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      038586c3
    • A
      perf report: Extend raw dump (-D) out with switch out event type · b3f35b5d
      Alexey Budankov 提交于
      Print additional 'preempt' tag for PERF_RECORD_SWITCH[_CPU_WIDE] OUT records when
      event header misc field contains PERF_RECORD_MISC_SWITCH_OUT_PREEMPT bit set
      designating preemption context switch out event:
      
      tools/perf/perf report -D -i perf.data | grep _SWITCH
      
      0 768361415226 0x27f076 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     8/8
      4 768362216813 0x28f45e [0x28]: PERF_RECORD_SWITCH_CPU_WIDE OUT          next pid/tid:     0/0
      4 768362217824 0x28f486 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:  4073/4073
      0 768362414027 0x27f0ce [0x28]: PERF_RECORD_SWITCH_CPU_WIDE OUT preempt  next pid/tid:     8/8
      0 768362414367 0x27f0f6 [0x28]: PERF_RECORD_SWITCH_CPU_WIDE IN           prev pid/tid:     0/0
      Signed-off-by: NAlexey Budankov <alexey.budankov@linux.intel.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/6f5aebb9-b96c-f304-f08f-8f046d38de4f@linux.intel.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      b3f35b5d
  7. 13 4月, 2018 3 次提交
    • A
      perf annotate: Allow setting the offset level in .perfconfig · 43c40231
      Arnaldo Carvalho de Melo 提交于
      The default is 1 (jump_target):
      
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        Samples: 3K of event 'cycles:ppp', 3000 Hz, Event count (approx.): 2766398574
        _raw_spin_lock_irqsave() /proc/kcore
          0.26        nop
          4.61        push   %rbx
         19.33        pushfq
          7.97        pop    %rax
          0.32        nop
          0.06        mov    %rax,%rbx
         14.63        cli
          0.06        nop
                      xor    %eax,%eax
                      mov    $0x1,%edx
         49.94        lock   cmpxchg %edx,(%rdi)
          0.16        test   %eax,%eax
                    ↓ jne    2b
          2.66        mov    %rbx,%rax
                      pop    %rbx
                    ← retq
                2b:   mov    %eax,%esi
                    → callq  *ffffffffb30eaed0
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
        #
      
      But one can ask for showing offsets for call instructions by setting
      this:
      
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        Samples: 3K of event 'cycles:ppp', 3000 Hz, Event count (approx.): 2766398574
        _raw_spin_lock_irqsave() /proc/kcore
          0.26        nop
          4.61        push   %rbx
         19.33        pushfq
          7.97        pop    %rax
          0.32        nop
          0.06        mov    %rax,%rbx
         14.63        cli
          0.06        nop
                      xor    %eax,%eax
                      mov    $0x1,%edx
         49.94        lock   cmpxchg %edx,(%rdi)
          0.16        test   %eax,%eax
                    ↓ jne    2b
          2.66        mov    %rbx,%rax
                      pop    %rbx
                    ← retq
                2b:   mov    %eax,%esi
                2d: → callq  *ffffffffb30eaed0
                      mov    %rbx,%rax
                      pop    %rbx
                    ← retq
        #
      
      Or using a big value to ask for all offsets to be shown:
      
        # cat ~/.perfconfig
        [annotate]
      
      	offset_level = 100
      
      	hide_src_code = true
        # perf annotate --ignore-vmlinux --stdio2 _raw_spin_lock_irqsave
        Samples: 3K of event 'cycles:ppp', 3000 Hz, Event count (approx.): 2766398574
        _raw_spin_lock_irqsave() /proc/kcore
          0.26   0:   nop
          4.61   5:   push   %rbx
         19.33   6:   pushfq
          7.97   7:   pop    %rax
          0.32   8:   nop
          0.06   d:   mov    %rax,%rbx
         14.63  10:   cli
          0.06  11:   nop
                17:   xor    %eax,%eax
                19:   mov    $0x1,%edx
         49.94  1e:   lock   cmpxchg %edx,(%rdi)
          0.16  22:   test   %eax,%eax
                24: ↓ jne    2b
          2.66  26:   mov    %rbx,%rax
                29:   pop    %rbx
                2a: ← retq
                2b:   mov    %eax,%esi
                2d: → callq  *ffffffffb30eaed0
                32:   mov    %rbx,%rax
                35:   pop    %rbx
                36: ← retq
         #
      
      This also affects the TUI, i.e. the default 'perf annotate' and 'perf
      top/report' -> A hotkey -> annotate interfaces, when slang-devel is present
      in the build, i.e.:
      
        # perf version --build-options | grep slang
                    libslang: [ on  ]  # HAVE_SLANG_SUPPORT
        #
      
      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: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-venm6x5zrt40eu8hxdsmqxz6@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      43c40231
    • A
      perf report: Fix switching to another perf.data file · 7b366142
      Arnaldo Carvalho de Melo 提交于
      In the TUI the 's' hotkey can be used to switch to another perf.data
      file in the current directory, but that got broken in Fixes:
      b01141f4 ("perf annotate: Initialize the priv are in symbol__new()"),
      that would show this once another file was chosen:
      
          ┌─Fatal Error─────────────────────────────────────┐
          │Annotation needs to be init before symbol__init()│
          │                                                 │
          │                                                 │
          │Press any key...                                 │
          └─────────────────────────────────────────────────┘
      
      Fix it by just silently bailing out if symbol__annotation_init() was already
      called, just like is done with symbol__init(), i.e. they are done just once at
      session start, not when switching to a new perf.data file.
      
      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: Martin Liška <mliska@suse.cz>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Cc: Thomas Richter <tmricht@linux.vnet.ibm.com>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: b01141f4 ("perf annotate: Initialize the priv are in symbol__new()")
      Link: https://lkml.kernel.org/n/tip-ogppdtpzfax7y1h6gjdv5s6u@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7b366142
    • T
      perf record: Change warning for missing sysfs entry to debug · 4f75f1cb
      Thomas Richter 提交于
      Using perf on 4.16.0 kernel on s390 shows this warning:
      
         failed: can't open node sysfs data
      
      each time I run command perf record ... for example:
      
        [root@s35lp76 perf]# ./perf record -e rB0000 -- sleep 1
        [ perf record: Woken up 1 times to write data ]
        failed: can't open node sysfs data
        [ perf record: Captured and wrote 0.001 MB perf.data (4 samples) ]
        [root@s35lp76 perf]#
      
      It turns out commit e2091ced ("perf tools: Add MEM_TOPOLOGY feature
      to perf data file") tries to open directory named /sys/devices/system/node/
      which does not exist on s390.
      
      This is the call stack:
       __cmd_record
       +---> perf_session__write_header
             +---> perf_header__adds_write
                   +---> do_write_feat
      	           +---> write_mem_topology
      		         +---> build_mem_topology
      			       prints warning
      
      The issue starts in do_write_feat() which unconditionally loops over all
      features and now includes HEADER_MEM_TOPOLOGY and calls write_mem_topology().
      
      Function record__init_features() at the beginning of __cmd_record() sets
      all features and then turns off some of them.
      
      Fix this by changing the warning to a level 2 debug output statement.
      
      So it is only shown when debug level 2 or higher is set.
      Signed-off-by: NThomas Richter <tmricht@linux.ibm.com>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Link: http://lkml.kernel.org/r/20180412133246.92801-1-tmricht@linux.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4f75f1cb
  8. 12 4月, 2018 3 次提交
  9. 09 4月, 2018 3 次提交
    • 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
    • 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
  10. 06 4月, 2018 1 次提交