提交 083122ee 编写于 作者: H He Chuyue 提交者: guzitao

sw64: maintain PMU counter usage status with bitmap

Sunway inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I56X48

--------------------------------

It's easier to manage usage status of performance counters with
bitmap operations, and this patch removes some data structures
that are no longer needed.
Signed-off-by: NHe Chuyue <hechuyue@wxiat.com>
Reviewed-by: NHe Sheng <hesheng@wxiat.com>
Signed-off-by: NGu Zitao <guzitao@wxiat.com>
上级 2654ebb7
......@@ -10,15 +10,11 @@
/* For tracking PMCs and the hw events they monitor on each CPU. */
struct cpu_hw_events {
/* Number of events currently scheduled onto this cpu.
* This tells how many entries in the arrays below
* are valid.
/*
* Set the bit (indexed by the counter number) when the counter
* is used for an event.
*/
int n_events;
/* Track counter usage of each counter */
#define PMC_IN_USE 1
#define PMC_NOT_USE 0
int pmcs[MAX_HWEVENTS];
unsigned long used_mask[BITS_TO_LONGS(MAX_HWEVENTS)];
/* Array of events current scheduled on this cpu. */
struct perf_event *event[MAX_HWEVENTS];
};
......@@ -433,17 +429,13 @@ static int sw64_pmu_add(struct perf_event *event, int flags)
local_irq_save(irq_flags);
if (cpuc->pmcs[hwc->idx] == PMC_IN_USE) {
if (__test_and_set_bit(hwc->idx, cpuc->used_mask)) {
err = -ENOSPC;
goto out;
}
cpuc->pmcs[hwc->idx] = PMC_IN_USE;
cpuc->event[hwc->idx] = event;
cpuc->n_events++;
hwc->state = PERF_HES_STOPPED | PERF_HES_UPTODATE;
if (flags & PERF_EF_START)
sw64_pmu_start(event, PERF_EF_RELOAD);
......@@ -470,8 +462,7 @@ static void sw64_pmu_del(struct perf_event *event, int flags)
sw64_pmu_stop(event, PERF_EF_UPDATE);
cpuc->event[hwc->idx] = NULL;
cpuc->pmcs[hwc->idx] = PMC_NOT_USE;
cpuc->n_events--;
__clear_bit(event->hw.idx, cpuc->used_mask);
/* Absorb the final count and turn off the event. */
perf_event_update_userpage(event);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册