Skip to content

Commit d53c825

Browse files
James-A-ClarkSuzuki K Poulose
authored andcommitted
coresight: Make CPU id map a property of a trace ID map
The global CPU ID mappings won't work for per-sink ID maps so move it to the ID map struct. coresight_trace_id_release_all_pending() is hard coded to operate on the default map, but once Perf sessions use their own maps the pending release mechanism will be deleted. So it doesn't need to be extended to accept a trace ID map argument at this point. Signed-off-by: James Clark <[email protected]> Reviewed-by: Mike Leach <[email protected]> Tested-by: Leo Yan <[email protected]> Signed-off-by: James Clark <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 7e52877 commit d53c825

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

drivers/hwtracing/coresight/coresight-trace-id.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
#include "coresight-trace-id.h"
1414

1515
/* Default trace ID map. Used in sysfs mode and for system sources */
16-
static struct coresight_trace_id_map id_map_default;
16+
static DEFINE_PER_CPU(atomic_t, id_map_default_cpu_ids) = ATOMIC_INIT(0);
17+
static struct coresight_trace_id_map id_map_default = {
18+
.cpu_map = &id_map_default_cpu_ids
19+
};
1720

18-
/* maintain a record of the mapping of IDs and pending releases per cpu */
19-
static DEFINE_PER_CPU(atomic_t, cpu_id) = ATOMIC_INIT(0);
21+
/* maintain a record of the pending releases per cpu */
2022
static cpumask_t cpu_id_release_pending;
2123

2224
/* perf session active counter */
@@ -49,7 +51,7 @@ static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map,
4951
/* unlocked read of current trace ID value for given CPU */
5052
static int _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
5153
{
52-
return atomic_read(&per_cpu(cpu_id, cpu));
54+
return atomic_read(per_cpu_ptr(id_map->cpu_map, cpu));
5355
}
5456

5557
/* look for next available odd ID, return 0 if none found */
@@ -145,7 +147,7 @@ static void coresight_trace_id_release_all_pending(void)
145147
clear_bit(bit, id_map->pend_rel_ids);
146148
}
147149
for_each_cpu(cpu, &cpu_id_release_pending) {
148-
atomic_set(&per_cpu(cpu_id, cpu), 0);
150+
atomic_set(per_cpu_ptr(id_map_default.cpu_map, cpu), 0);
149151
cpumask_clear_cpu(cpu, &cpu_id_release_pending);
150152
}
151153
spin_unlock_irqrestore(&id_map_lock, flags);
@@ -181,7 +183,7 @@ static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map
181183
goto get_cpu_id_out_unlock;
182184

183185
/* allocate the new id to the cpu */
184-
atomic_set(&per_cpu(cpu_id, cpu), id);
186+
atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), id);
185187

186188
get_cpu_id_clr_pend:
187189
/* we are (re)using this ID - so ensure it is not marked for release */
@@ -215,7 +217,7 @@ static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_ma
215217
} else {
216218
/* otherwise clear id */
217219
coresight_trace_id_free(id, id_map);
218-
atomic_set(&per_cpu(cpu_id, cpu), 0);
220+
atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), 0);
219221
}
220222

221223
spin_unlock_irqrestore(&id_map_lock, flags);

include/linux/coresight.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ struct coresight_sysfs_link {
234234
struct coresight_trace_id_map {
235235
DECLARE_BITMAP(used_ids, CORESIGHT_TRACE_IDS_MAX);
236236
DECLARE_BITMAP(pend_rel_ids, CORESIGHT_TRACE_IDS_MAX);
237+
atomic_t __percpu *cpu_map;
237238
};
238239

239240
/**

0 commit comments

Comments
 (0)