Lines Matching refs:man
259 struct usdt_manager *man;
269 man = calloc(1, sizeof(*man));
270 if (!man)
273 man->specs_map = specs_map;
274 man->ip_to_spec_id_map = ip_to_spec_id_map;
280 man->has_bpf_cookie = kernel_supports(obj, FEAT_BPF_COOKIE);
286 man->has_sema_refcnt = faccessat(AT_FDCWD, ref_ctr_sysfs_path, F_OK, AT_EACCESS) == 0;
292 man->has_uprobe_multi = kernel_supports(obj, FEAT_UPROBE_MULTI_LINK);
293 return man;
296 void usdt_manager_free(struct usdt_manager *man)
298 if (IS_ERR_OR_NULL(man))
301 free(man->free_spec_ids);
302 free(man);
578 static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid,
687 if (ehdr.e_type == ET_DYN && !man->has_bpf_cookie) {
735 if (!man->has_sema_refcnt) {
824 struct usdt_manager *man = usdt_link->usdt_man;
839 if (!man->has_bpf_cookie) {
841 (void)bpf_map_delete_elem(bpf_map__fd(man->ip_to_spec_id_map),
849 if (!man->free_spec_ids) {
851 man->free_spec_ids = usdt_link->spec_ids;
852 man->free_spec_cnt = usdt_link->spec_cnt;
856 size_t new_cnt = man->free_spec_cnt + usdt_link->spec_cnt;
859 new_free_ids = libbpf_reallocarray(man->free_spec_ids, new_cnt,
871 memcpy(new_free_ids + man->free_spec_cnt, usdt_link->spec_ids,
873 man->free_spec_ids = new_free_ids;
874 man->free_spec_cnt = new_cnt;
900 static int allocate_spec_id(struct usdt_manager *man, struct hashmap *specs_hash,
924 if (man->free_spec_cnt) {
925 *spec_id = man->free_spec_ids[man->free_spec_cnt - 1];
932 man->free_spec_cnt--;
935 if (man->next_free_spec_id >= bpf_map__max_entries(man->specs_map))
938 *spec_id = man->next_free_spec_id;
945 man->next_free_spec_id++;
955 struct bpf_link *usdt_manager_attach_usdt(struct usdt_manager *man, const struct bpf_program *prog,
970 spec_map_fd = bpf_map__fd(man->specs_map);
971 ip_map_fd = bpf_map__fd(man->ip_to_spec_id_map);
990 err = collect_usdt_targets(man, elf_fd.elf, path, pid, usdt_provider, usdt_name,
1009 link->usdt_man = man;
1013 if (man->has_uprobe_multi) {
1044 err = allocate_spec_id(man, specs_hash, link, target, &spec_id, &is_new);
1054 if (!man->has_bpf_cookie &&
1068 if (man->has_uprobe_multi) {
1074 opts.bpf_cookie = man->has_bpf_cookie ? spec_id : 0;
1090 if (man->has_uprobe_multi) {