id_map
if (!id_map[i]) {
id_map[i] = 1;
static u8 id_map[ADF_MAX_DEVICES];
id_map[accel_dev->accel_id] = 0;
id_map[map->id] = 0;
struct ida *id_map = &hd->cport_id_map;
return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL);
struct ida *id_map = &hd->cport_id_map;
ret = ida_alloc_range(id_map, cport_id, cport_id, GFP_KERNEL);
struct ida *id_map = &hd->cport_id_map;
ida_free(id_map, cport_id);
struct ida *id_map = &hd->cport_id_map;
return ida_alloc_range(id_map, ida_start, ida_end, GFP_KERNEL);
id = find_next_zero_bit(id_map->used_ids, CORESIGHT_TRACE_ID_RES_TOP, 1);
set_bit(id, id_map->used_ids);
static void coresight_trace_id_free(int id, struct coresight_trace_id_map *id_map)
if (WARN(!test_bit(id, id_map->used_ids), "Freeing unused ID %d\n", id))
clear_bit(id, id_map->used_ids);
static void coresight_trace_id_release_all(struct coresight_trace_id_map *id_map)
raw_spin_lock_irqsave(&id_map->lock, flags);
bitmap_zero(id_map->used_ids, CORESIGHT_TRACE_IDS_MAX);
atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), 0);
raw_spin_unlock_irqrestore(&id_map->lock, flags);
DUMP_ID_MAP(id_map);
static int _coresight_trace_id_get_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
raw_spin_lock_irqsave(&id_map->lock, flags);
id = _coresight_trace_id_read_cpu_id(cpu, id_map);
id = coresight_trace_id_alloc_new_id(id_map,
atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), id);
raw_spin_unlock_irqrestore(&id_map->lock, flags);
DUMP_ID_MAP(id_map);
static void _coresight_trace_id_put_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
id = _coresight_trace_id_read_cpu_id(cpu, id_map);
raw_spin_lock_irqsave(&id_map->lock, flags);
coresight_trace_id_free(id, id_map);
atomic_set(per_cpu_ptr(id_map->cpu_map, cpu), 0);
raw_spin_unlock_irqrestore(&id_map->lock, flags);
DUMP_ID_MAP(id_map);
static int coresight_trace_id_map_get_system_id(struct coresight_trace_id_map *id_map,
raw_spin_lock_irqsave(&id_map->lock, flags);
id = coresight_trace_id_alloc_new_id(id_map, preferred_id, traceid_flags);
raw_spin_unlock_irqrestore(&id_map->lock, flags);
DUMP_ID_MAP(id_map);
static void coresight_trace_id_map_put_system_id(struct coresight_trace_id_map *id_map, int id)
raw_spin_lock_irqsave(&id_map->lock, flags);
coresight_trace_id_free(id, id_map);
raw_spin_unlock_irqrestore(&id_map->lock, flags);
DUMP_ID_MAP(id_map);
int coresight_trace_id_get_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
return _coresight_trace_id_get_cpu_id(cpu, id_map);
void coresight_trace_id_put_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
_coresight_trace_id_put_cpu_id(cpu, id_map);
int coresight_trace_id_read_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map)
return _coresight_trace_id_read_cpu_id(cpu, id_map);
void coresight_trace_id_perf_start(struct coresight_trace_id_map *id_map)
atomic_inc(&id_map->perf_cs_etm_session_active);
PERF_SESSION(atomic_read(&id_map->perf_cs_etm_session_active));
void coresight_trace_id_perf_stop(struct coresight_trace_id_map *id_map)
if (!atomic_dec_return(&id_map->perf_cs_etm_session_active))
coresight_trace_id_release_all(id_map);
PERF_SESSION(atomic_read(&id_map->perf_cs_etm_session_active));
static void coresight_trace_id_dump_table(struct coresight_trace_id_map *id_map,
pr_debug("Used = %*pb\n", CORESIGHT_TRACE_IDS_MAX, id_map->used_ids);
static int _coresight_trace_id_read_cpu_id(int cpu, struct coresight_trace_id_map *id_map)
return atomic_read(per_cpu_ptr(id_map->cpu_map, cpu));
static int coresight_trace_id_find_odd_id(struct coresight_trace_id_map *id_map)
next_id = find_next_zero_bit(id_map->used_ids,
static int coresight_trace_id_alloc_new_id(struct coresight_trace_id_map *id_map,
if (!test_bit(preferred_id, id_map->used_ids)) {
id = coresight_trace_id_find_odd_id(id_map);
int coresight_trace_id_read_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
void coresight_trace_id_perf_start(struct coresight_trace_id_map *id_map);
void coresight_trace_id_perf_stop(struct coresight_trace_id_map *id_map);
int coresight_trace_id_get_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
void coresight_trace_id_put_cpu_id_map(int cpu, struct coresight_trace_id_map *id_map);
ret = ida_alloc_range(&fw_download->id_map, 1, 255, GFP_KERNEL);
ida_free(&fw_download->id_map, fw_req->firmware_id);
struct ida id_map;
ida_init(&fw_download->id_map);
ida_destroy(&fw_download->id_map);
ida_destroy(&fw_download->id_map);
ida_free(&fw_req->fw_download->id_map, fw_req->firmware_id);
ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL);
ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id);
ida_free(&fw_mgmt->id_map, fw_mgmt->intf_fw_request_id);
struct ida id_map;
ret = ida_alloc_range(&fw_mgmt->id_map, 1, 255, GFP_KERNEL);
ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id);
ida_free(&fw_mgmt->id_map, fw_mgmt->backend_fw_request_id);
ida_init(&fw_mgmt->id_map);
ida_destroy(&fw_mgmt->id_map);
__u32 *permute_ids = NULL, *id_map = NULL;
id_map = calloc(nr_types, sizeof(*id_map));
if (!id_map) {
id_map[id] = i + start_id;
err = btf__permute(btf, id_map, nr_types, NULL);
free(id_map);
int *id_map;
if (dist->id_map[*id] > 0)
dist->id_map[*id] = *id;
if (!dist->id_map[i])
dist->id_map[i] = id++;
if (dist->id_map[*id])
*id = dist->id_map[*id];
dist.id_map = calloc(n, sizeof(*dist.id_map));
if (!dist.id_map) {
free(dist.id_map);
__u32 *id_map;
*type_id = p->id_map[new_id - p->btf->start_id + p->start_offs];
int btf__permute(struct btf *btf, __u32 *id_map, __u32 id_map_cnt,
if (id_map[0] != 0)
order_map = calloc(id_map_cnt, sizeof(*id_map));
id = id_map[i];
p.id_map = id_map;
LIBBPF_API int btf__permute(struct btf *btf, __u32 *id_map, __u32 id_map_cnt,
r->id_map[next_id] = BTF_IS_EMBEDDED;
if (r->id_map[dist_info->id] == BTF_IS_EMBEDDED &&
if (r->id_map[dist_info->id] &&
r->id_map[dist_info->id] != BTF_IS_EMBEDDED) {
base_t->size, id, r->id_map[dist_info->id]);
r->id_map[dist_info->id] = id;
if (r->id_map[id] && r->id_map[id] != BTF_IS_EMBEDDED)
int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map)
r.id_map = calloc(nr_types, sizeof(*r.id_map));
if (!r.id_map || !r.str_map) {
__u32 *id_map;
r.id_map[id] = id + r.nr_base_types - r.nr_dist_base_types;
if (id_map) {
*id_map = r.id_map;
r.id_map = NULL;
free(r.id_map);
*id = r->id_map[*id];
int btf_relocate(struct btf *btf, const struct btf *base_btf, __u32 **id_map);
char id_map[4096];
snprintf(id_map, sizeof(id_map), "0 %d 1\n", getuid());
ret = write_id_mapping(UID_MAP, pid, id_map, strlen(id_map));
snprintf(id_map, sizeof(id_map), "0 %d 1\n", getgid());
ret = write_id_mapping(GID_MAP, pid, id_map, strlen(id_map));
struct id_map *map = iterator->elem;
struct id_map uid_map = {
struct id_map gid_map = {
ret = map_ids_from_idmap(&h->id_map, pid);
if (!list_empty(&h->id_map))
struct list id_map;