提交 4ff1fdb4 编写于 作者: M Mike Leach 提交者: Suzuki K Poulose

coresight: perf: traceid: Add perf ID allocation and notifiers

Adds in calls to allocate and release Trace ID for the CPUs in use
by the perf session.

Adds in notifier calls to the trace ID allocator that perf
events are starting and stopping.

This ensures that Trace IDs associated with CPUs remain the same
throughout the perf session, and are only released when all perf
sessions are complete.
Signed-off-by: NMike Leach <mike.leach@linaro.org>
Reviewed-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: NSuzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20230116124928.5440-4-mike.leach@linaro.org
上级 bdeb62a3
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include "coresight-etm-perf.h" #include "coresight-etm-perf.h"
#include "coresight-priv.h" #include "coresight-priv.h"
#include "coresight-syscfg.h" #include "coresight-syscfg.h"
#include "coresight-trace-id.h"
static struct pmu etm_pmu; static struct pmu etm_pmu;
static bool etm_perf_up; static bool etm_perf_up;
...@@ -228,8 +229,12 @@ static void free_event_data(struct work_struct *work) ...@@ -228,8 +229,12 @@ static void free_event_data(struct work_struct *work)
if (!(IS_ERR_OR_NULL(*ppath))) if (!(IS_ERR_OR_NULL(*ppath)))
coresight_release_path(*ppath); coresight_release_path(*ppath);
*ppath = NULL; *ppath = NULL;
coresight_trace_id_put_cpu_id(cpu);
} }
/* mark perf event as done for trace id allocator */
coresight_trace_id_perf_stop();
free_percpu(event_data->path); free_percpu(event_data->path);
kfree(event_data); kfree(event_data);
} }
...@@ -300,6 +305,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, ...@@ -300,6 +305,7 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
{ {
u32 id, cfg_hash; u32 id, cfg_hash;
int cpu = event->cpu; int cpu = event->cpu;
int trace_id;
cpumask_t *mask; cpumask_t *mask;
struct coresight_device *sink = NULL; struct coresight_device *sink = NULL;
struct coresight_device *user_sink = NULL, *last_sink = NULL; struct coresight_device *user_sink = NULL, *last_sink = NULL;
...@@ -316,6 +322,9 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, ...@@ -316,6 +322,9 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
sink = user_sink = coresight_get_sink_by_id(id); sink = user_sink = coresight_get_sink_by_id(id);
} }
/* tell the trace ID allocator that a perf event is starting up */
coresight_trace_id_perf_start();
/* check if user wants a coresight configuration selected */ /* check if user wants a coresight configuration selected */
cfg_hash = (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32); cfg_hash = (u32)((event->attr.config2 & GENMASK_ULL(63, 32)) >> 32);
if (cfg_hash) { if (cfg_hash) {
...@@ -388,6 +397,13 @@ static void *etm_setup_aux(struct perf_event *event, void **pages, ...@@ -388,6 +397,13 @@ static void *etm_setup_aux(struct perf_event *event, void **pages,
continue; continue;
} }
/* ensure we can allocate a trace ID for this CPU */
trace_id = coresight_trace_id_get_cpu_id(cpu);
if (!IS_VALID_CS_TRACE_ID(trace_id)) {
cpumask_clear_cpu(cpu, mask);
continue;
}
*etm_event_cpu_path_ptr(event_data, cpu) = path; *etm_event_cpu_path_ptr(event_data, cpu) = path;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册