Skip to content

Commit

Permalink
coresight: perf: Refactor function free_event_data()
Browse files Browse the repository at this point in the history
Function free_event_data() is already busy and is bound to become
worse with the addition of CPU-wide trace scenarios.  As such spin
off a new function to strickly take care of the sink buffers.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Tested-by: Leo Yan <leo.yan@linaro.org>
Tested-by: Robert Walker <robert.walker@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
mathieupoirier authored and gregkh committed Apr 25, 2019
1 parent 02d5c89 commit f5200aa
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions drivers/hwtracing/coresight/coresight-etm-perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,22 +120,34 @@ static int etm_event_init(struct perf_event *event)
return ret;
}

static void free_sink_buffer(struct etm_event_data *event_data)
{
int cpu;
cpumask_t *mask = &event_data->mask;
struct coresight_device *sink;

if (WARN_ON(cpumask_empty(mask)))
return;

if (!event_data->snk_config)
return;

cpu = cpumask_first(mask);
sink = coresight_get_sink(etm_event_cpu_path(event_data, cpu));
sink_ops(sink)->free_buffer(event_data->snk_config);
}

static void free_event_data(struct work_struct *work)
{
int cpu;
cpumask_t *mask;
struct etm_event_data *event_data;
struct coresight_device *sink;

event_data = container_of(work, struct etm_event_data, work);
mask = &event_data->mask;

/* Free the sink buffers, if there are any */
if (event_data->snk_config && !WARN_ON(cpumask_empty(mask))) {
cpu = cpumask_first(mask);
sink = coresight_get_sink(etm_event_cpu_path(event_data, cpu));
sink_ops(sink)->free_buffer(event_data->snk_config);
}
free_sink_buffer(event_data);

for_each_cpu(cpu, mask) {
struct list_head **ppath;
Expand Down

0 comments on commit f5200aa

Please sign in to comment.