1. 20 12月, 2018 2 次提交
  2. 25 11月, 2018 1 次提交
    • B
      powerpc/perf: Declare static identifier a such · 4851f750
      Breno Leitao 提交于
      There are three symbols (two variables and a function) that are being used
      solely in the same file (imc-pmu.c), thus, these symbols should be static,
      but they are not. This was detected by sparse:
      
      	arch/powerpc/perf/imc-pmu.c:31:20: warning: symbol 'nest_imc_refc' was not declared. Should it be static?
      	arch/powerpc/perf/imc-pmu.c:37:20: warning: symbol 'core_imc_refc' was not declared. Should it be static?
      	arch/powerpc/perf/imc-pmu.c:46:16: warning: symbol 'imc_event_to_pmu' was not declared. Should it be static?
      
      This patch simply adds the 'static' storage-class definition to these
      symbols, thus, restricting their usage only in the imc-pmu.c file.
      Signed-off-by: NBreno Leitao <leitao@debian.org>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      4851f750
  3. 26 10月, 2018 1 次提交
  4. 18 10月, 2018 1 次提交
    • M
      powerpc: Add -Werror at arch/powerpc level · 23ad1a27
      Michael Ellerman 提交于
      Back when I added -Werror in commit ba55bd74 ("powerpc: Add
      configurable -Werror for arch/powerpc") I did it by adding it to most
      of the arch Makefiles.
      
      At the time we excluded math-emu, because apparently it didn't build
      cleanly. But that seems to have been fixed somewhere in the interim.
      
      So move the -Werror addition to the top-level of the arch, this saves
      us from repeating it in every Makefile and means we won't forget to
      add it to any new sub-dirs.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      23ad1a27
  5. 13 10月, 2018 1 次提交
  6. 03 10月, 2018 1 次提交
    • M
      powerpc/perf: Add missing break in power7_marked_instr_event() · db6711b7
      Michael Ellerman 提交于
      In power7_marked_instr_event() there is a switch case that is missing
      a break or an explicit fallthrough, it's not immediately clear which
      it should be.
      
      The function determines based on the PMU event code, whether the event
      is a "marked" event (which then requires us to configure the PMU in a
      certain way). On Power7 there is no specific bit(s) in the event to
      tell us that, we just have to know.
      
      Rather than having a full list of every event and whether they are
      marked, we pull apart the event code and for events with certain
      values of certain fields we can say that those are all marked events.
      
      We take the psel (bits 0-7) of the event, and look at bits 4-7. For a
      value of 6 we say that if the entire psel == 0x64 then if the pmc == 3
      the event is marked, else not, and otherwise we continue.
      
      It is then that we fallthrough to the 8 case, where we return true if
      the unit == 0xd.
      
      The question is should the 6 case also fallthrough and check for
      unit == 0xd, or should it return.
      
      Looking at the full list of events we see that there are zero events
      where (psel >> 4) == 0x6 and unit == 0xd.
      
      So the answer is it doesn't really matter, there are no valid event
      codes that will return a different result whether we fallthrough or
      break.
      
      But equally, testing the 6 case events against unit == 0xd is slightly
      bogus, as there are no such events. So to make the code clearer, and
      avoid any future confusion, have the 6 case break rather than falling
      through.
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Reviewed-by: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      db6711b7
  7. 07 8月, 2018 1 次提交
    • A
      powerpc/perf: Remove sched_task function defined for thread-imc · 7ccc4fe5
      Anju T Sudhakar 提交于
      Call trace observed while running perf-fuzzer:
      
        CPU: 43 PID: 9088 Comm: perf_fuzzer Not tainted 4.13.0-32-generic #35~lp1746225
        task: c000003f776ac900 task.stack: c000003f77728000
        NIP: c000000000299b70 LR: c0000000002a4534 CTR: c00000000029bb80
        REGS: c000003f7772b760 TRAP: 0700   Not tainted  (4.13.0-32-generic)
        MSR: 900000000282b033 <SF,HV,VEC,VSX,EE,FP,ME,IR,DR,RI,LE>
          CR: 24008822  XER: 00000000
        CFAR: c000000000299a70 SOFTE: 0
        GPR00: c0000000002a4534 c000003f7772b9e0 c000000001606200 c000003fef858908
        GPR04: c000003f776ac900 0000000000000001 ffffffffffffffff 0000003fee730000
        GPR08: 0000000000000000 0000000000000000 c0000000011220d8 0000000000000002
        GPR12: c00000000029bb80 c000000007a3d900 0000000000000000 0000000000000000
        GPR16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
        GPR20: 0000000000000000 0000000000000000 c000003f776ad090 c000000000c71354
        GPR24: c000003fef716780 0000003fee730000 c000003fe69d4200 c000003f776ad330
        GPR28: c0000000011220d8 0000000000000001 c0000000014c6108 c000003fef858900
        NIP [c000000000299b70] perf_pmu_sched_task+0x170/0x180
        LR [c0000000002a4534] __perf_event_task_sched_in+0xc4/0x230
        Call Trace:
          perf_iterate_sb+0x158/0x2a0 (unreliable)
          __perf_event_task_sched_in+0xc4/0x230
          finish_task_switch+0x21c/0x310
          __schedule+0x304/0xb80
          schedule+0x40/0xc0
          do_wait+0x254/0x2e0
          kernel_wait4+0xa0/0x1a0
          SyS_wait4+0x64/0xc0
          system_call+0x58/0x6c
        Instruction dump:
        3beafea0 7faa4800 409eff18 e8010060 eb610028 ebc10040 7c0803a6 38210050
        eb81ffe0 eba1ffe8 ebe1fff8 4e800020 <0fe00000> 4bffffbc 60000000 60420000
        ---[ end trace 8c46856d314c1811 ]---
      
      The context switch call-backs for thread-imc are defined in sched_task function.
      So when thread-imc events are grouped with software pmu events,
      perf_pmu_sched_task hits the WARN_ON_ONCE condition, since software PMUs are
      assumed not to have a sched_task defined.
      
      Patch to move the thread_imc enable/disable opal call back from sched_task to
      event_[add/del] function
      
      Fixes: f74c89bd ("powerpc/perf: Add thread IMC PMU support")
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Tested-by: NJoel Stanley <joel@jms.id.au>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      7ccc4fe5
  8. 30 7月, 2018 1 次提交
  9. 16 7月, 2018 2 次提交
  10. 03 6月, 2018 5 次提交
  11. 25 5月, 2018 1 次提交
  12. 18 5月, 2018 1 次提交
    • A
      powerpc/perf: Fix memory allocation for core-imc based on num_possible_cpus() · d2032678
      Anju T Sudhakar 提交于
      Currently memory is allocated for core-imc based on cpu_present_mask,
      which has bit 'cpu' set iff cpu is populated. We use (cpu number / threads
      per core) as the array index to access the memory.
      
      Under some circumstances firmware marks a CPU as GUARDed CPU and boot the
      system, until cleared of errors, these CPU's are unavailable for all
      subsequent boots. GUARDed CPUs are possible but not present from linux
      view, so it blows a hole when we assume the max length of our allocation
      is driven by our max present cpus, where as one of the cpus might be online
      and be beyond the max present cpus, due to the hole.
      So (cpu number / threads per core) value bounds the array index and leads
      to memory overflow.
      
      Call trace observed during a guard test:
      
      Faulting instruction address: 0xc000000000149f1c
      cpu 0x69: Vector: 380 (Data Access Out of Range) at [c000003fea303420]
          pc:c000000000149f1c: prefetch_freepointer+0x14/0x30
          lr:c00000000014e0f8: __kmalloc+0x1a8/0x1ac
          sp:c000003fea3036a0
         msr:9000000000009033
         dar:c9c54b2c91dbf6b7
        current = 0xc000003fea2c0000
        paca    = 0xc00000000fddd880	 softe: 3	 irq_happened: 0x01
          pid   = 1, comm = swapper/104
      Linux version 4.16.7-openpower1 (smc@smc-desktop) (gcc version 6.4.0
      (Buildroot 2018.02.1-00006-ga8d1126)) #2 SMP Fri May 4 16:44:54 PDT 2018
      enter ? for help
      call trace:
      	 __kmalloc+0x1a8/0x1ac
      	 (unreliable)
      	 init_imc_pmu+0x7f4/0xbf0
      	 opal_imc_counters_probe+0x3fc/0x43c
      	 platform_drv_probe+0x48/0x80
      	 driver_probe_device+0x22c/0x308
      	 __driver_attach+0xa0/0xd8
      	 bus_for_each_dev+0x88/0xb4
      	 driver_attach+0x2c/0x40
      	 bus_add_driver+0x1e8/0x228
      	 driver_register+0xd0/0x114
      	 __platform_driver_register+0x50/0x64
      	 opal_imc_driver_init+0x24/0x38
      	 do_one_initcall+0x150/0x15c
      	 kernel_init_freeable+0x250/0x254
      	 kernel_init+0x1c/0x150
      	 ret_from_kernel_thread+0x5c/0xc8
      
      Allocating memory for core-imc based on cpu_possible_mask, which has
      bit 'cpu' set iff cpu is populatable, will fix this issue.
      Reported-by: NPridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: NBalbir Singh <bsingharora@gmail.com>
      Tested-by: NPridhiviraj Paidipeddi <ppaidipe@linux.vnet.ibm.com>
      Fixes: 39a846db ("powerpc/perf: Add core IMC PMU support")
      Cc: stable@vger.kernel.org # v4.14+
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      d2032678
  13. 31 3月, 2018 1 次提交
  14. 27 3月, 2018 6 次提交
  15. 17 3月, 2018 1 次提交
  16. 16 3月, 2018 1 次提交
  17. 12 3月, 2018 1 次提交
    • P
      perf/core: Remove perf_event::group_entry · 8343aae6
      Peter Zijlstra 提交于
      Now that all the grouping is done with RB trees, we no longer need
      group_entry and can replace the whole thing with sibling_list.
      Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
      Acked-by: NMark Rutland <mark.rutland@arm.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Alexey Budankov <alexey.budankov@linux.intel.com>
      Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
      Cc: David Carrillo-Cisneros <davidcc@google.com>
      Cc: Dmitri Prokhorov <Dmitry.Prohorov@intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Kan Liang <kan.liang@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Valery Cherepennikov <valery.cherepennikov@intel.com>
      Cc: Vince Weaver <vincent.weaver@maine.edu>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      8343aae6
  18. 19 1月, 2018 6 次提交
  19. 16 1月, 2018 1 次提交
  20. 13 12月, 2017 3 次提交
    • A
      powerpc/perf: Fix kfree memory allocated for nest pmus · 110df8bd
      Anju T Sudhakar 提交于
      imc_common_cpuhp_mem_free() is the common function for all
      IMC (In-memory Collection counters) domains to unregister cpuhotplug
      callback and free memory. Since kfree of memory allocated for
      nest-imc (per_nest_pmu_arr) is in the common code, all
      domains (core/nest/thread) can do the kfree in the failure case.
      
      This could potentially create a call trace as shown below, where
      core(/thread/nest) imc pmu initialization fails and in the failure
      path imc_common_cpuhp_mem_free() free the memory(per_nest_pmu_arr),
      which is allocated by successfully registered nest units.
      
      The call trace is generated in a scenario where core-imc
      initialization is made to fail and a cpuhotplug is performed in a p9
      system. During cpuhotplug ppc_nest_imc_cpu_offline() tries to access
      per_nest_pmu_arr, which is already freed by core-imc.
      
        NIP [c000000000cb6a94] mutex_lock+0x34/0x90
        LR [c000000000cb6a88] mutex_lock+0x28/0x90
        Call Trace:
          mutex_lock+0x28/0x90 (unreliable)
          perf_pmu_migrate_context+0x90/0x3a0
          ppc_nest_imc_cpu_offline+0x190/0x1f0
          cpuhp_invoke_callback+0x160/0x820
          cpuhp_thread_fun+0x1bc/0x270
          smpboot_thread_fn+0x250/0x290
          kthread+0x1a8/0x1b0
          ret_from_kernel_thread+0x5c/0x74
      
      To address this scenario do the kfree(per_nest_pmu_arr) only in case
      of nest-imc initialization failure, and when there is no other nest
      units registered.
      
      Fixes: 73ce9aec ("powerpc/perf: Fix IMC_MAX_PMU macro")
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      110df8bd
    • A
      powerpc/perf/imc: Fix nest-imc cpuhotplug callback failure · ad2b6e01
      Anju T Sudhakar 提交于
      Oops is observed during boot:
      
        Faulting instruction address: 0xc000000000248340
        cpu 0x0: Vector: 380 (Data Access Out of Range) at [c000000ff66fb850]
            pc: c000000000248340: event_function_call+0x50/0x1f0
            lr: c00000000024878c: perf_remove_from_context+0x3c/0x100
            sp: c000000ff66fbad0
           msr: 9000000000009033
           dar: 7d20e2a6f92d03c0
          pid = 14, comm = cpuhp/0
      
      While registering the cpuhotplug callbacks for nest-imc, if we fail in
      the cpuhotplug online path for any random node in a multi node
      system (because the opal call to stop nest-imc counters fails for that
      node), ppc_nest_imc_cpu_offline() will get invoked for other nodes who
      successfully returned from cpuhotplug online path.
      
      This call trace is generated since in the ppc_nest_imc_cpu_offline()
      path we are trying to migrate the event context, when nest-imc
      counters are not even initialized.
      
      Patch to add a check to ensure that nest-imc is registered before
      migrating the event context.
      
      Fixes: 885dcd70 ("powerpc/perf: Add nest IMC PMU support")
      Signed-off-by: NAnju T Sudhakar <anju@linux.vnet.ibm.com>
      Reviewed-by: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      ad2b6e01
    • R
      powerpc/perf: Dereference BHRB entries safely · f41d84dd
      Ravi Bangoria 提交于
      It's theoretically possible that branch instructions recorded in
      BHRB (Branch History Rolling Buffer) entries have already been
      unmapped before they are processed by the kernel. Hence, trying to
      dereference such memory location will result in a crash. eg:
      
          Unable to handle kernel paging request for data at address 0xd000000019c41764
          Faulting instruction address: 0xc000000000084a14
          NIP [c000000000084a14] branch_target+0x4/0x70
          LR [c0000000000eb828] record_and_restart+0x568/0x5c0
          Call Trace:
          [c0000000000eb3b4] record_and_restart+0xf4/0x5c0 (unreliable)
          [c0000000000ec378] perf_event_interrupt+0x298/0x460
          [c000000000027964] performance_monitor_exception+0x54/0x70
          [c000000000009ba4] performance_monitor_common+0x114/0x120
      
      Fix it by deferefencing the addresses safely.
      
      Fixes: 69123184 ("powerpc/perf: Fix setting of "to" addresses for BHRB")
      Cc: stable@vger.kernel.org # v3.10+
      Suggested-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      [mpe: Use probe_kernel_read() which is clearer, tweak change log]
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      f41d84dd
  21. 04 12月, 2017 1 次提交
    • R
      powerpc/perf: Fix oops when grouping different pmu events · 5aa04b3e
      Ravi Bangoria 提交于
      When user tries to group imc (In-Memory Collections) event with
      normal event, (sometime) kernel crashes with following log:
      
          Faulting instruction address: 0x00000000
          [link register   ] c00000000010ce88 power_check_constraints+0x128/0x980
          ...
          c00000000010e238 power_pmu_event_init+0x268/0x6f0
          c0000000002dc60c perf_try_init_event+0xdc/0x1a0
          c0000000002dce88 perf_event_alloc+0x7b8/0xac0
          c0000000002e92e0 SyS_perf_event_open+0x530/0xda0
          c00000000000b004 system_call+0x38/0xe0
      
      'event_base' field of 'struct hw_perf_event' is used as flags for
      normal hw events and used as memory address for imc events. While
      grouping these two types of events, collect_events() tries to
      interpret imc 'event_base' as a flag, which causes a corruption
      resulting in a crash.
      
      Consider only those events which belongs to 'perf_hw_context' in
      collect_events().
      Signed-off-by: NRavi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
      Reviewed-By: NMadhavan Srinivasan <maddy@linux.vnet.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      5aa04b3e
  22. 22 11月, 2017 1 次提交