perf/x86/core: Refactor hw->idx checks and cleanup
authorLike Xu <like.xu@linux.intel.com>
Sat, 13 Jun 2020 08:09:47 +0000 (16:09 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Thu, 2 Jul 2020 13:51:46 +0000 (15:51 +0200)
commit027440b5d426a51f33b515bbd236cc479d1e051f
tree8e405cb6646ebc5ef11b7c5e7d4efe2cb9b43918
parent3cb9d5464c1ceea86f6225089b2f7965989cf316
perf/x86/core: Refactor hw->idx checks and cleanup

For intel_pmu_en/disable_event(), reorder the branches checks for hw->idx
and make them sorted by probability: gp,fixed,bts,others.

Clean up the x86_assign_hw_event() by converting multiple if-else
statements to a switch statement.

To skip x86_perf_event_update() and x86_perf_event_set_period(),
it's generic to replace "idx == INTEL_PMC_IDX_FIXED_BTS" check with
'!hwc->event_base' because that should be 0 for all non-gp/fixed cases.

Wrap related bit operations into intel_set/clear_masks() and make the main
path more cleaner and readable.

No functional changes.

Signed-off-by: Like Xu <like.xu@linux.intel.com>
Original-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20200613080958.132489-3-like.xu@linux.intel.com
arch/x86/events/core.c
arch/x86/events/intel/core.c