lkml.org 
[lkml]   [2021]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 10/49] perf/x86/intel: Factor out intel_pmu_check_num_counters
    Date
    From: Kan Liang <kan.liang@linux.intel.com>

    Each Hybrid PMU has to check its own number of counters and mask fixed
    counters before registration.

    The intel_pmu_check_num_counters will be reused later when registering a
    dedicated hybrid PMU.

    Reviewed-by: Andi Kleen <ak@linux.intel.com>
    Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
    ---
    arch/x86/events/intel/core.c | 38 ++++++++++++++++++++++++--------------
    1 file changed, 24 insertions(+), 14 deletions(-)

    diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c
    index 582d191..2c02e1e 100644
    --- a/arch/x86/events/intel/core.c
    +++ b/arch/x86/events/intel/core.c
    @@ -4219,6 +4219,26 @@ static void flip_smm_bit(void *data)
    }
    }

    +static void intel_pmu_check_num_counters(int *num_counters,
    + int *num_counters_fixed,
    + u64 *intel_ctrl, u64 fixed_mask)
    +{
    + if (*num_counters > INTEL_PMC_MAX_GENERIC) {
    + WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!",
    + *num_counters, INTEL_PMC_MAX_GENERIC);
    + *num_counters = INTEL_PMC_MAX_GENERIC;
    + }
    + *intel_ctrl = (1ULL << *num_counters) - 1;
    +
    + if (*num_counters_fixed > INTEL_PMC_MAX_FIXED) {
    + WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
    + *num_counters_fixed, INTEL_PMC_MAX_FIXED);
    + *num_counters_fixed = INTEL_PMC_MAX_FIXED;
    + }
    +
    + *intel_ctrl |= fixed_mask << INTEL_PMC_IDX_FIXED;
    +}
    +
    static void intel_pmu_cpu_starting(int cpu)
    {
    struct cpu_hw_events *cpuc = &per_cpu(cpu_hw_events, cpu);
    @@ -5707,20 +5727,10 @@ __init int intel_pmu_init(void)

    x86_pmu.attr_update = attr_update;

    - if (x86_pmu.num_counters > INTEL_PMC_MAX_GENERIC) {
    - WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!",
    - x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC);
    - x86_pmu.num_counters = INTEL_PMC_MAX_GENERIC;
    - }
    - x86_pmu.intel_ctrl = (1ULL << x86_pmu.num_counters) - 1;
    -
    - if (x86_pmu.num_counters_fixed > INTEL_PMC_MAX_FIXED) {
    - WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",
    - x86_pmu.num_counters_fixed, INTEL_PMC_MAX_FIXED);
    - x86_pmu.num_counters_fixed = INTEL_PMC_MAX_FIXED;
    - }
    -
    - x86_pmu.intel_ctrl |= (u64)fixed_mask << INTEL_PMC_IDX_FIXED;
    + intel_pmu_check_num_counters(&x86_pmu.num_counters,
    + &x86_pmu.num_counters_fixed,
    + &x86_pmu.intel_ctrl,
    + (u64)fixed_mask);

    /* AnyThread may be deprecated on arch perfmon v5 or later */
    if (x86_pmu.intel_cap.anythread_deprecated)
    --
    2.7.4
    \
     
     \ /
      Last update: 2021-02-08 19:06    [W:4.069 / U:0.356 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site