Lines Matching +full:no +full:- +full:map
1 // SPDX-License-Identifier: GPL-2.0
36 * 3. map: 1 always, pointer points to additional struct with number
81 * Map of C-string key/value pairs with fixed maximum capacity. Each map has
83 * way appropriate. Map is "write-only", there is no way to get data out of
84 * map. Map is intended to be used to provide metadata for profilers and is
85 * not to be used for internal in-app communication. All methods are
86 * thread-safe.
96 /* number of used entries in map */
112 #define TLS_NOT_SET -1
124 * - -1 (TLS_NOT_SET) - no metavariable;
125 * - 0 (TLS_LOCAL_EXEC) - Local Executable mode;
126 * - 1 (TLS_IMM_EXEC) - Immediate Executable mode;
127 * - 2 (TLS_GENERAL_DYN) - General Dynamic mode;
134 * TLS_LOCAL_EXEC: offset from thread pointer (fs:0 for x86-64,
155 * cnt <0 - map value isn't set;
156 * 0 - map has id set, but no key/value entries
179 /* if map_descrs[i].cnt == -1, metavar is not present/set */
182 * payload has compactly packed values of str and map variables in the
261 * For x86-64, this is mapped onto two entries in GOT.
278 * - -1 (TLS_NOT_SET), if no metavar is present; in calc_location()
279 * - 0 (TLS_LOCAL_EXEC), if metavar uses Local Executable mode of TLS in calc_location()
280 * (offset from fs:0 for x86-64 or tpidr_el0 for aarch64); in calc_location()
281 * - 1 (TLS_IMM_EXEC), if metavar uses Immediate Executable mode of TLS; in calc_location()
282 * - 2 (TLS_GENERAL_DYN), if metavar uses General Dynamic mode of TLS; in calc_location()
285 * to get NULL for "no metavar" location, or correct pointer for local in calc_location()
288 if (loc->tls_mode <= TLS_LOCAL_EXEC) { in calc_location()
291 void *addr = tls_base + loc->offset; in calc_location()
292 /* multiply by (tls_mode + 1) to get NULL, if we have no in calc_location()
294 return (void *)((loc->tls_mode + 1) * (int64_t)addr); in calc_location()
300 * - loc->offset is pointing to a GOT entry containing fixed offset in calc_location()
304 * - loc->offset is pointing to a beginning of double GOT entries; in calc_location()
305 * - (for aarch64 only) second entry points to tls_index_t struct; in calc_location()
306 * - (for x86-64 only) two GOT entries are already tls_index_t; in calc_location()
307 * - tls_index_t->module is used to find start of TLS section in in calc_location()
309 * - tls_index_t->offset provides offset within that TLS section, in calc_location()
317 (void *)loc->offset); in calc_location()
320 /* dtv = ((struct tcbhead *)tls_base)->dtv[tls_index.module] */ in calc_location()
322 &((struct tcbhead *)tls_base)->dtv); in calc_location()
328 /* if pointer has (void *)-1 value, then TLS wasn't initialized yet */ in calc_location()
329 return tls_ptr && tls_ptr != (void *)-1 in calc_location()
344 void *location = calc_location(&cfg->int_locs[idx], tls_base); in read_int_var()
349 data->int_vals[idx] = value->val; in read_int_var()
350 if (value->header.len) in read_int_var()
351 data->int_vals_set_mask |= (1 << idx); in read_int_var()
363 data->str_lens[idx] = 0; in read_str_var()
364 location = calc_location(&cfg->str_locs[idx], tls_base); in read_str_var()
369 len = bpf_probe_read_user_str(payload, STROBE_MAX_STR_LEN, value->ptr); in read_str_var()
380 data->str_lens[idx] = len; in read_str_var()
390 struct strobe_map_descr* descr = &data->map_descrs[idx]; in read_map_var()
391 struct strobe_map_raw map; in read_map_var() local
396 descr->tag_len = 0; /* presume no tag is set */ in read_map_var()
397 descr->cnt = -1; /* presume no value is set */ in read_map_var()
399 location = calc_location(&cfg->map_locs[idx], tls_base); in read_map_var()
404 if (bpf_probe_read_user(&map, sizeof(struct strobe_map_raw), value->ptr)) in read_map_var()
407 descr->id = map.id; in read_map_var()
408 descr->cnt = map.cnt; in read_map_var()
409 if (cfg->req_meta_idx == idx) { in read_map_var()
410 data->req_id = map.id; in read_map_var()
411 data->req_meta_valid = 1; in read_map_var()
414 len = bpf_probe_read_user_str(payload, STROBE_MAX_STR_LEN, map.tag); in read_map_var()
416 descr->tag_len = len; in read_map_var()
426 if (i >= map.cnt) in read_map_var()
429 descr->key_lens[i] = 0; in read_map_var()
431 map.entries[i].key); in read_map_var()
433 descr->key_lens[i] = len; in read_map_var()
436 descr->val_lens[i] = 0; in read_map_var()
438 map.entries[i].val); in read_map_var()
440 descr->val_lens[i] = len; in read_map_var()
449 * read_strobe_meta returns NULL, if no metadata was read; otherwise returns
469 data->int_vals_set_mask = 0; in read_strobe_meta()
470 data->req_meta_valid = 0; in read_strobe_meta()
471 payload = data->payload; in read_strobe_meta()
474 * tls_base = (void *)task->thread.fsbase; in read_strobe_meta()
522 sample->pid = pid; in on_event()
523 bpf_get_current_comm(&sample->comm, TASK_COMM_LEN); in on_event()
525 sample->ktime = ktime_ns; in on_event()
528 sample_end = read_strobe_meta(task, &sample->metadata); in on_event()
529 sample->has_meta = sample_end != NULL; in on_event()
530 sample_end = sample_end ? : &sample->metadata; in on_event()
533 sample->kernel_stack_id = bpf_get_stackid(ctx, &stacks_1, 0); in on_event()
534 sample->user_stack_id = bpf_get_stackid(ctx, &stacks_1, BPF_F_USER_STACK); in on_event()
536 sample->kernel_stack_id = bpf_get_stackid(ctx, &stacks_0, 0); in on_event()
537 sample->user_stack_id = bpf_get_stackid(ctx, &stacks_0, BPF_F_USER_STACK); in on_event()
540 uint64_t sample_size = sample_end - (void *)sample; in on_event()