lkml.org 
[lkml]   [2016]   [Jan]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH v2 4/6] perf/amd/iommu: Introduce data structure for tracking prev count.
    Date
    To enable AMD IOMMU PMU to support multiple IOMMUs, this patch introduces
    a new data structure, perf_amd_iommu.prev_cnts, to track previous counts
    of IOMMU performance counters in multi-IOMMU environment.

    Also, this patch allocates perf_iommu_cnts for internal use
    when manages counters.

    Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
    ---
    arch/x86/kernel/cpu/perf_event_amd_iommu.c | 26 ++++++++++++++++++++++----
    1 file changed, 22 insertions(+), 4 deletions(-)

    diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
    index e6d2485..99fcd10 100644
    --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
    +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
    @@ -42,6 +42,7 @@ struct perf_amd_iommu {
    u64 cntr_assign_mask;
    raw_spinlock_t lock;
    const struct attribute_group *attr_groups[4];
    + local64_t *prev_cnts;
    };

    #define format_group attr_groups[0]
    @@ -126,6 +127,8 @@ static struct amd_iommu_event_desc amd_iommu_v2_event_descs[] = {
    { /* end: all zeroes */ },
    };

    +static u64 *perf_iommu_cnts;
    +
    /*---------------------------------------------
    * sysfs cpumask attributes
    *---------------------------------------------*/
    @@ -423,10 +426,14 @@ static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)

    static __init void amd_iommu_pc_exit(void)
    {
    - if (__perf_iommu.events_group != NULL) {
    - kfree(__perf_iommu.events_group);
    - __perf_iommu.events_group = NULL;
    - }
    + kfree(__perf_iommu.events_group);
    + __perf_iommu.events_group = NULL;
    +
    + kfree(__perf_iommu.prev_cnts);
    + __perf_iommu.prev_cnts = NULL;
    +
    + kfree(perf_iommu_cnts);
    + perf_iommu_cnts = NULL;
    }

    static __init int _init_perf_amd_iommu(
    @@ -456,6 +463,17 @@ static __init int _init_perf_amd_iommu(
    perf_iommu->null_group = NULL;
    perf_iommu->pmu.attr_groups = perf_iommu->attr_groups;

    + perf_iommu->prev_cnts = kzalloc(sizeof(*perf_iommu->prev_cnts) *
    + (amd_iommu_get_num_iommus() * perf_iommu->max_banks *
    + perf_iommu->max_counters), GFP_KERNEL);
    + if (!perf_iommu->prev_cnts)
    + return -ENOMEM;
    +
    + perf_iommu_cnts = kzalloc(sizeof(*perf_iommu_cnts) *
    + amd_iommu_get_num_iommus(), GFP_KERNEL);
    + if (!perf_iommu_cnts)
    + return -ENOMEM;
    +
    ret = perf_pmu_register(&perf_iommu->pmu, name, -1);
    if (ret) {
    pr_err("perf: amd_iommu: Failed to initialized.\n");
    --
    1.9.1


    \
     
     \ /
      Last update: 2016-01-01 19:41    [W:8.816 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site