Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/lib/bpf/libbpf.c
static int attach_uprobe(const struct bpf_program *prog, long cookie, struct bpf_link **link) { DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, opts); char *probe_type = NULL, *binary_path = NULL, *func_name = NULL; int n, ret = -EINVAL; long offset = 0; *link = NULL; n = sscanf(prog->sec_na...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
struct bpf_link *bpf_program__attach_uprobe(const struct bpf_program *prog, bool retprobe, pid_t pid, const char *binary_path, size_t func_offset) { DECLARE_LIBBPF_OPTS(bpf_uprobe_opts,...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
struct bpf_link *bpf_program__attach_usdt(const struct bpf_program *prog, pid_t pid, const char *binary_path, const char *usdt_provider, const char *usdt_name, ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
static int attach_usdt(const struct bpf_program *prog, long cookie, struct bpf_link **link) { char *path = NULL, *provider = NULL, *name = NULL; const char *sec_name; int n, err; sec_name = bpf_program__section_name(prog); if (strcmp(sec_name, "usdt") == 0) { *link = NULL; ret...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
static int determine_tracepoint_id(const char *tp_category, const char *tp_name) { char file[PATH_MAX]; int ret; ret = snprintf(file, sizeof(file), "%s/events/%s/%s/id", tracefs_path(), tp_category, tp_name); if (ret < 0) return -errno; if (ret >= size...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
struct bpf_link * bpf_program__attach_raw_tracepoint(const struct bpf_program *prog, const char *tp_name) { char errmsg[STRERR_BUFSIZE]; struct bpf_link *link; int prog_fd, pfd; prog_fd = bpf_program__fd(prog); if (prog_fd < 0) { pr_warn("prog '%s': can't attach before...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
struct bpf_link *bpf_program__attach_trace(const struct bpf_program *prog) { return bpf_program__attach_btf_id(prog, NULL); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
static int attach_lsm(const struct bpf_program *prog, long cookie, struct bpf_link **link) { *link = bpf_program__attach_lsm(prog); return libbpf_get_error(*link); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
static struct bpf_link *bpf_program__attach_fd(const struct bpf_program *prog, int target_fd, int btf_id, const char *target_name) { DECLARE_LIBBPF_OPTS(bpf_link_create_opts, opts, .target_btf_id = btf_id); enum bpf_attac...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
struct bpf_link * bpf_program__attach_iter(const struct bpf_program *prog, const struct bpf_iter_attach_opts *opts) { DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_create_opts); char errmsg[STRERR_BUFSIZE]; struct bpf_link *link; int prog_fd, link_fd; __u32 target_fd = 0; if (!OP...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
static enum bpf_perf_event_ret perf_event_read_simple(void *mmap_mem, size_t mmap_size, size_t page_size, void **copy_mem, size_t *copy_size, bpf_perf_event_print_t fn, void *private_data) { struct perf_event_mmap_page *header = mmap_mem; __u64 data_head = ring_buffer_...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
int perf_buffer__epoll_fd(const struct perf_buffer *pb) { return pb->epoll_fd; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
int perf_buffer__poll(struct perf_buffer *pb, int timeout_ms) { int i, cnt, err; cnt = epoll_wait(pb->epoll_fd, pb->events, pb->cpu_cnt, timeout_ms); if (cnt < 0) return -errno; for (i = 0; i < cnt; i++) { struct perf_cpu_buf *cpu_buf = pb->events[i].data.ptr; err = perf_buffer__process_records(...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
int parse_cpu_mask_str(const char *s, bool **mask, int *mask_sz) { int err = 0, n, len, start, end = -1; bool *tmp; *mask = NULL; *mask_sz = 0; while (*s) { if (*s == ',' || *s == '\n') { s++; continue; } n = sscanf(s, "%d%n-%d%n", &start, &len, &end, &len); if (n <= 0 || n > 2) ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf.c
void bpf_object__destroy_subskeleton(struct bpf_object_subskeleton *s) { if (!s) return; free(s->maps); free(s->progs); free(s->vars); free(s); }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf_internal.h
static inline __u32 btf_type_info(int kind, int vlen, int kflag) { return (kflag << 31) | (kind << 24) | vlen; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/libbpf_internal.h
static inline bool libbpf_is_mem_zeroed(const char *p, ssize_t len) { while (len > 0) { if (*p) return false; p++; len--; } return true; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf_internal.h
static inline bool is_ldimm64_insn(struct bpf_insn *insn) { return insn->code == (BPF_LD | BPF_IMM | BPF_DW); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/libbpf_internal.h
static inline bool is_pow_of_2(size_t x) { return x && (x & (x - 1)) == 0; } #define PROG_LOAD_ATTEMPTS 5
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static struct dst_sec *add_dst_sec(struct bpf_linker *linker, const char *sec_name) { struct dst_sec *secs = linker->secs, *sec; size_t new_cnt = linker->sec_cnt ? linker->sec_cnt + 1 : 2; secs = libbpf_reallocarray(secs, new_cnt, sizeof(*secs)); if (!secs) return NULL; ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
int bpf_linker__add_file(struct bpf_linker *linker, const char *filename, const struct bpf_linker_file_opts *opts) { struct src_obj obj = {}; int err = 0; if (!OPTS_VALID(opts, bpf_linker_file_opts)) return libbpf_err(-EINVAL); if (!linker->elf) return libbpf_err(-EINVAL); ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static bool is_dwarf_sec_name(const char *name) { return strncmp(name, ".debug_", sizeof(".debug_") - 1) == 0; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static int linker_sanity_check_btf_ext(struct src_obj *obj) { int err = 0; if (!obj->btf_ext) return 0; if (!obj->btf) return -EINVAL; err = err ?: btf_ext_visit_type_ids(obj->btf_ext, check_btf_type_id, obj->btf); err = err ?: btf_ext_visit_str_offs(obj->btf_ext, check_btf_str_off, obj...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj) { int i, err; for (i = 1; i < obj->sec_cnt; i++) { struct src_sec *src_sec; struct dst_sec *dst_sec; src_sec = &obj->secs[i]; if (!is_data_sec(src_sec)) continue; dst_sec ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static int linker_append_elf_syms(struct bpf_linker *linker, struct src_obj *obj) { struct src_sec *symtab = &obj->secs[obj->symtab_sec_idx]; Elf64_Sym *sym = symtab->data->d_buf; int i, n = symtab->shdr->sh_size / symtab->shdr->sh_entsize, err; int str_sec_idx = symtab->shdr->...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static Elf64_Sym *get_sym_by_idx(struct bpf_linker *linker, size_t sym_idx) { struct dst_sec *symtab = &linker->secs[linker->symtab_sec_idx]; Elf64_Sym *syms = symtab->raw_data; return &syms[sym_idx]; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static struct glob_sym *find_glob_sym(struct bpf_linker *linker, const char *sym_name) { struct glob_sym *glob_sym; const char *name; int i; for (i = 0; i < linker->glob_sym_cnt; i++) { glob_sym = &linker->glob_syms[i]; name = strset__data(linker->strtab_strs) + g...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static struct glob_sym *add_glob_sym(struct bpf_linker *linker) { struct glob_sym *syms, *sym; syms = libbpf_reallocarray(linker->glob_syms, linker->glob_sym_cnt + 1, sizeof(*linker->glob_syms)); if (!syms) return NULL; sym = &syms[linker->glob_sym_cnt]; memset(sym, 0, size...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static void sym_update_type(Elf64_Sym *sym, int sym_type) { sym->st_info = ELF64_ST_INFO(ELF64_ST_BIND(sym->st_info), sym_type); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
static int remap_type_id(__u32 *type_id, void *ctx) { int *id_map = ctx; int new_id = id_map[*type_id]; if (new_id == 0 && *type_id != 0) { pr_warn("failed to find new ID mapping for original BTF type ID %u\n", *type_id); return -EINVAL; } *type_id = id_map[*type_id]; return 0; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/linker.c
int bpf_linker__finalize(struct bpf_linker *linker) { struct dst_sec *sec; size_t strs_sz; const void *strs; int err, i; if (!linker->elf) return libbpf_err(-EINVAL); err = finalize_btf(linker); if (err) return libbpf_err(err); strs_sz = strset__data_size(linker->strtab_strs); strs = strset...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/netlink.c
int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts) { struct libbpf_nla_req req = { .nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)), .nh.nlmsg_type = RTM_GETLINK, .nh.nlmsg_flags = NLM_F_DUMP | NLM_F_REQUEST, .ifinfo.ifi_family = AF_PACKET, }; struct xdp_i...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/netlink.c
int bpf_tc_hook_destroy(struct bpf_tc_hook *hook) { if (!hook || !OPTS_VALID(hook, bpf_tc_hook) || OPTS_GET(hook, ifindex, 0) <= 0) return libbpf_err(-EINVAL); switch (OPTS_GET(hook, attach_point, 0)) { case BPF_TC_INGRESS: case BPF_TC_EGRESS: return libbpf_err(__bpf_tc_detach(hook, NULL, true))...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/netlink.c
static int __get_tc_info(void *cookie, struct tcmsg *tc, struct nlattr **tb, bool unicast) { struct nlattr *tbb[TCA_BPF_MAX + 1]; struct bpf_cb_ctx *info = cookie; if (!info || !info->opts) return -EINVAL; if (unicast && info->processed) return -EINVAL; if (!tb[TCA_OPTIONS])...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/netlink.c
static int tc_add_fd_and_name(struct libbpf_nla_req *req, int fd) { struct bpf_prog_info info; __u32 info_len = sizeof(info); char name[256]; int len, ret; memset(&info, 0, info_len); ret = bpf_obj_get_info_by_fd(fd, &info, &info_len); if (ret < 0) return ret; ret = nlattr_add(req, TCA_BPF_FD, &f...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
static struct nlattr *nla_next(const struct nlattr *nla, int *remaining) { int totlen = NLA_ALIGN(nla->nla_len); *remaining -= totlen; return (struct nlattr *)((void *)nla + totlen); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
static int nla_ok(const struct nlattr *nla, int remaining) { return remaining >= (int)sizeof(*nla) && nla->nla_len >= sizeof(*nla) && nla->nla_len <= remaining; }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
static int nla_type(const struct nlattr *nla) { return nla->nla_type & NLA_TYPE_MASK; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
static int validate_nla(struct nlattr *nla, int maxtype, struct libbpf_nla_policy *policy) { struct libbpf_nla_policy *pt; unsigned int minlen = 0; int type = nla_type(nla); if (type < 0 || type > maxtype) return 0; pt = &policy[type]; if (pt->type > LIBBPF_NLA_TYPE_MAX) ...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
static inline int nlmsg_len(const struct nlmsghdr *nlh) { return nlh->nlmsg_len - NLMSG_HDRLEN; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.c
int libbpf_nla_parse_nested(struct nlattr *tb[], int maxtype, struct nlattr *nla, struct libbpf_nla_policy *policy) { return libbpf_nla_parse(tb, maxtype, libbpf_nla_data(nla), libbpf_nla_len(nla), policy); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/nlattr.h
static inline uint32_t libbpf_nla_getattr_u32(const struct nlattr *nla) { return *(uint32_t *)libbpf_nla_data(nla); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/relo_core.c
static bool is_flex_arr(const struct btf *btf, const struct bpf_core_accessor *acc, const struct btf_array *arr) { const struct btf_type *t; if (!acc->name || arr->nelems > 0) return false; /* has to be the last member of enclosing struct */ t = btf_type_by_...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/relo_core.c
static void bpf_core_poison_insn(const char *prog_name, int relo_idx, int insn_idx, struct bpf_insn *insn) { pr_debug("prog '%s': relo #%d: substituting insn #%d w/ invalid insn\n", prog_name, relo_idx, insn_idx); insn->code = BPF_JMP | BPF_CALL; insn->dst_reg = 0; in...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/relo_core.c
static bool bpf_core_names_match(const struct btf *local_btf, size_t local_name_off, const struct btf *targ_btf, size_t targ_name_off) { const char *local_n, *targ_n; size_t local_len, targ_len; local_n = btf__nam...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/relo_core.c
static int bpf_core_enums_match(const struct btf *local_btf, const struct btf_type *local_t, const struct btf *targ_btf, const struct btf_type *targ_t) { __u16 local_vlen = btf_vlen(local_t); __u16 targ_vlen = btf_vlen(t...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/ringbuf.c
int ring_buffer__poll(struct ring_buffer *rb, int timeout_ms) { int i, cnt; int64_t err, res = 0; cnt = epoll_wait(rb->epoll_fd, rb->events, rb->ring_cnt, timeout_ms); if (cnt < 0) return libbpf_err(-errno); for (i = 0; i < cnt; i++) { __u32 ring_id = rb->events[i].data.fd; struct ring *ring = &...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/ringbuf.c
static __u64 ns_elapsed_timespec(const struct timespec *start, const struct timespec *end) { __u64 start_ns, end_ns, ns_per_s = 1000000000; start_ns = (__u64)start->tv_sec * ns_per_s + start->tv_nsec; end_ns = (__u64)end->tv_sec * ns_per_s + end->tv_nsec; return end_ns - star...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline int skel_sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, unsigned int size) { #ifdef __KERNEL__ return kern_sys_bpf(cmd, attr, size); #else return syscall(__NR_bpf, cmd, attr, size); #endif }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline void skel_free(const void *p) { kfree(p); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline void skel_free_map_data(void *p, __u64 addr, size_t sz) { if (addr != ~0ULL) kvfree(p); }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline void *skel_finalize_map_data(__u64 *init_val, size_t mmap_sz, int flags, int fd) { struct bpf_map *map; void *addr = NULL; kvfree((void *)(long)*init_val); *init_val = ~0ULL; map = bpf_map_get(fd); if (IS_ERR(map)) return NULL; if (map->map_ty...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline void skel_free(void *p) { free(p); }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline int skel_raw_tracepoint_open(const char *name, int prog_fd) { const size_t attr_sz = offsetofend(union bpf_attr, raw_tracepoint.prog_fd); union bpf_attr attr; memset(&attr, 0, attr_sz); attr.raw_tracepoint.name = (long)name; attr.raw_tracepoint.prog_fd = prog_fd; return skel_sys_bpf(BPF_RAW...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/skel_internal.h
static inline int skel_link_create(int prog_fd, int target_fd, enum bpf_attach_type attach_type) { const size_t attr_sz = offsetofend(union bpf_attr, link_create.iter_info_len); union bpf_attr attr; memset(&attr, 0, attr_sz); attr.link_create.prog_fd = prog_fd; attr.link_c...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/strset.c
static bool strset_equal_fn(long key1, long key2, void *ctx) { const struct strset *s = ctx; const char *str1 = s->strs_data + key1; const char *str2 = s->strs_data + key2; return strcmp(str1, str2) == 0; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/strset.c
void strset__free(struct strset *set) { if (IS_ERR_OR_NULL(set)) return; hashmap__free(set->strs_hash); free(set->strs_data); free(set); }
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
struct usdt_manager *usdt_manager_new(struct bpf_object *obj) { static const char *ref_ctr_sysfs_path = "/sys/bus/event_source/devices/uprobe/format/ref_ctr_offset"; struct usdt_manager *man; struct bpf_map *specs_map, *ip_to_spec_id_map; specs_map = bpf_object__find_map_by_name(obj, "__bpf_usdt_specs");...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
static int find_elf_sec_by_name(Elf *elf, const char *sec_name, GElf_Shdr *shdr, Elf_Scn **scn) { Elf_Scn *sec = NULL; size_t shstrndx; if (elf_getshdrstrndx(elf, &shstrndx)) return -EINVAL; if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL)) return -EINVAL; while ((s...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
static struct elf_seg *find_elf_seg(struct elf_seg *segs, size_t seg_cnt, long virtaddr) { struct elf_seg *seg; int i; for (i = 0, seg = segs; i < seg_cnt; i++, seg++) { if (seg->start <= virtaddr && virtaddr < seg->end) return seg; } return NULL; }
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
static struct elf_seg *find_vma_seg(struct elf_seg *segs, size_t seg_cnt, long offset) { struct elf_seg *seg; int i; for (i = 0, seg = segs; i < seg_cnt; i++, seg++) { if (seg->offset <= offset && offset < seg->offset + (seg->end - seg->start)) return seg; } retu...
[ 1, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
static int parse_usdt_arg(const char *arg_str, int arg_num, struct usdt_arg_spec *arg) { char reg_name[16]; int arg_sz, len, reg_off; long off; if (sscanf(arg_str, " %d @ %ld ( %15[a-z0-9] ) %n", &arg_sz, &off, reg_name, &len) == 3) { arg->arg_type = USDT_ARG_REG_DER...
[ 0, 0 ]
Linux Kernel
tools/lib/bpf/usdt.c
static int parse_usdt_arg(const char *arg_str, int arg_num, struct usdt_arg_spec *arg) { pr_warn("usdt: libbpf doesn't support USDTs on current architecture\n"); return -ENOTSUP; }
[ 0, 0 ]
Linux Kernel
tools/lib/find_bit.c
unsigned long _find_first_zero_bit(const unsigned long *addr, unsigned long size) { return FIND_FIRST_BIT(~addr[idx], , size); } #endif #ifndef find_next_bit
[ 0, 0 ]
Linux Kernel
tools/lib/hweight.c
unsigned int __sw_hweight32(unsigned int w) { #ifdef CONFIG_ARCH_HAS_FAST_MULTIPLIER w -= (w >> 1) & 0x55555555; w = (w & 0x33333333) + ((w >> 2) & 0x33333333); w = (w + (w >> 4)) & 0x0f0f0f0f; return (w * 0x01010101) >> 24; #else unsigned int res = w - ((w >> 1) & 0x55555555); res = (res & 0x33333333) + ((...
[ 1, 0 ]
Linux Kernel
tools/lib/hweight.c
unsigned int __sw_hweight16(unsigned int w) { unsigned int res = w - ((w >> 1) & 0x5555); res = (res & 0x3333) + ((res >> 2) & 0x3333); res = (res + (res >> 4)) & 0x0F0F; return (res + (res >> 8)) & 0x00FF; }
[ 1, 0 ]
Linux Kernel
tools/lib/perf/core.c
void libperf_init(libperf_print_fn_t fn) { page_size = sysconf(_SC_PAGE_SIZE); __libperf_pr = fn; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/cpumap.c
static struct perf_cpu_map *perf_cpu_map__alloc(int nr_cpus) { struct perf_cpu_map *cpus = malloc(sizeof(*cpus) + sizeof(struct perf_cpu) * nr_cpus); if (cpus != NULL) { cpus->nr = nr_cpus; refcount_set(&cpus->refcnt, 1); } return cpus; }
[ 1, 0 ]
Linux Kernel
tools/lib/perf/cpumap.c
struct perf_cpu_map *perf_cpu_map__dummy_new(void) { struct perf_cpu_map *cpus = perf_cpu_map__alloc(1); if (cpus) cpus->map[0].cpu = -1; return cpus; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/cpumap.c
struct perf_cpu_map *perf_cpu_map__default_new(void) { return cpu_map__default_new(); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/cpumap.c
static struct perf_cpu_map *cpu_map__read_all_cpu_map(void) { struct perf_cpu_map *cpus = NULL; FILE *onlnf; onlnf = fopen("/sys/devices/system/cpu/online", "r"); if (!onlnf) return cpu_map__default_new(); cpus = perf_cpu_map__read(onlnf); fclose(onlnf); return cpus; }
[ 1, 0 ]
Linux Kernel
tools/lib/perf/Documentation/examples/sampling.c
static int libperf_print(enum libperf_print_level level, const char *fmt, va_list ap) { return vfprintf(stderr, fmt, ap); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
int perf_evlist__open(struct perf_evlist *evlist) { struct perf_evsel *evsel; int err; perf_evlist__for_each_entry(evlist, evsel) { err = perf_evsel__open(evsel, evsel->cpus, evsel->threads); if (err < 0) goto out_err; } return 0; out_err: perf_evlist__close(evlist); return err; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
int perf_evlist__id_add_fd(struct perf_evlist *evlist, struct perf_evsel *evsel, int cpu, int thread, int fd) { u64 read_data[4] = { 0, }; int id_idx = 1; u64 id; int ret; ret = ioctl(fd, PERF_EVENT_IOC_ID, &id); if (!ret) goto add; if (errno != ENOTTY) return ...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
int perf_evlist__alloc_pollfd(struct perf_evlist *evlist) { int nr_cpus = perf_cpu_map__nr(evlist->all_cpus); int nr_threads = perf_thread_map__nr(evlist->threads); int nfds = 0; struct perf_evsel *evsel; perf_evlist__for_each_entry(evlist, evsel) { if (evsel->system_wide) nfds += nr_cpus; els...
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
static void perf_evlist__munmap_filtered(struct fdarray *fda, int fd, void *arg __maybe_unused) { struct perf_mmap *map = fda->priv[fd].ptr; if (map) perf_mmap__put(map); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
static struct perf_mmap *perf_evlist__alloc_mmap(struct perf_evlist *evlist, bool overwrite) { int i; struct perf_mmap *map; map = zalloc(evlist->nr_mmaps * sizeof(struct perf_mmap)); if (!map) return NULL; for (i = 0; i < evlist->nr_mmaps; i++) { str...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
void perf_evlist__munmap(struct perf_evlist *evlist) { int i; if (evlist->mmap) { for (i = 0; i < evlist->nr_mmaps; i++) perf_mmap__munmap(&evlist->mmap[i]); } if (evlist->mmap_ovw) { for (i = 0; i < evlist->nr_mmaps; i++) perf_mmap__munmap(&evlist->mmap_ovw[i]); } zfree(&evlist->mma...
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
void __perf_evlist__set_leader(struct list_head *list, struct perf_evsel *leader) { struct perf_evsel *first, *last, *evsel; first = list_first_entry(list, struct perf_evsel, node); last = list_last_entry(list, struct perf_evsel, node); leader->nr_members = last->idx - first->i...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evlist.c
void perf_evlist__set_leader(struct perf_evlist *evlist) { if (evlist->nr_entries) { struct perf_evsel *first = list_entry(evlist->entries.next, struct perf_evsel, node); evlist->nr_groups = evlist->nr_entries > 1 ? 1 : 0; __perf_evlist__set_leader(&evlist->entries, first); } }
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
void perf_evsel__delete(struct perf_evsel *evsel) { free(evsel); } #define FD(_evsel, _cpu_map_idx, _thread) \ ((int *)xyarray__entry(_evsel->fd, _cpu_map_idx, _thread)) #define MMAP(_evsel, _cpu_map_idx, _thread) \ (_evsel->mmap ? ((struct p...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
void perf_evsel__free_fd(struct perf_evsel *evsel) { xyarray__delete(evsel->fd); evsel->fd = NULL; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
void *perf_evsel__mmap_base(struct perf_evsel *evsel, int cpu_map_idx, int thread) { int *fd = FD(evsel, cpu_map_idx, thread); if (fd == NULL || *fd < 0 || MMAP(evsel, cpu_map_idx, thread) == NULL) return NULL; return MMAP(evsel, cpu_map_idx, thread)->base; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
int perf_evsel__read_size(struct perf_evsel *evsel) { u64 read_format = evsel->attr.read_format; int entry = sizeof(u64); int size = 0; int nr = 1; if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) size += sizeof(u64); if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) size += sizeof(u64); if (r...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
int perf_evsel__disable(struct perf_evsel *evsel) { int i; int err = 0; for (i = 0; i < xyarray__max_x(evsel->fd) && !err; i++) err = perf_evsel__run_ioctl(evsel, PERF_EVENT_IOC_DISABLE, NULL, i); return err; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/evsel.c
void perf_evsel__free_id(struct perf_evsel *evsel) { xyarray__delete(evsel->sample_id); evsel->sample_id = NULL; zfree(&evsel->id); evsel->ids = 0; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/include/internal/tests.h
static inline int get_verbose(char **argv, int argc) { int c; int verbose = 0; while ((c = getopt(argc, argv, "v")) != -1) { switch (c) { case 'v': verbose = 1; break; default: break; } } optind = 1; return verbose; } #define __T_START ...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
void perf_mmap__put(struct perf_mmap *map) { BUG_ON(map->base && refcount_read(&map->refcnt) == 0); if (refcount_dec_and_test(&map->refcnt)) perf_mmap__munmap(map); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
int perf_mmap__read_init(struct perf_mmap *map) { if (!refcount_read(&map->refcnt)) return -ENOENT; return __perf_mmap__read_init(map); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
static union perf_event *perf_mmap__read(struct perf_mmap *map, u64 *startp, u64 end) { unsigned char *data = map->base + page_size; union perf_event *event = NULL; int diff = end - *startp; if (diff >= (int)sizeof(event->header)) { size_t size; event = (union ...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
static u64 read_timestamp(void) { unsigned int low, high; asm volatile("rdtsc" : "=a"(low), "=d"(high)); return low | ((u64)high) << 32; } #elif defined(__aarch64__) #define read_sysreg(r) \ ({ ...
[ 0, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
static u64 read_timestamp(void) { return read_sysreg(cntvct_el0); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/mmap.c
int perf_mmap__read_self(struct perf_mmap *map, struct perf_counts_values *count) { struct perf_event_mmap_page *pc = map->base; u32 seq, idx, time_mult = 0, time_shift = 0; u64 cnt, cyc = 0, time_offset = 0, time_cycles = 0, time_mask = ~0ULL; if (!pc || !pc->cap_user_rdpmc) retur...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/tests/test-evlist.c
static int libperf_print(enum libperf_print_level level, const char *fmt, va_list ap) { return vfprintf(stderr, fmt, ap); }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/tests/test-evlist.c
static int test_stat_cpu(void) { struct perf_cpu_map *cpus; struct perf_evlist *evlist; struct perf_evsel *evsel, *leader; struct perf_event_attr attr1 = { .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_CPU_CLOCK, }; struct perf_event_attr attr2 = { .type = PERF_TYPE_SOFTWARE, ...
[ 0, 0 ]
Linux Kernel
tools/lib/perf/tests/test-evsel.c
static int test_stat_read_format_single(struct perf_event_attr *attr, struct perf_thread_map *threads) { struct perf_evsel *evsel; struct perf_counts_values counts; volatile int count = 0x100000; int err; evsel = perf_evsel__new(attr); __T("failed to create evsel", e...
[ 1, 0 ]
Linux Kernel
tools/lib/perf/threadmap.c
void perf_thread_map__set_pid(struct perf_thread_map *map, int idx, pid_t pid) { map->map[idx].pid = pid; }
[ 0, 0 ]
Linux Kernel
tools/lib/perf/xyarray.c
struct xyarray *xyarray__new(int xlen, int ylen, size_t entry_size) { size_t row_size = ylen * entry_size; struct xyarray *xy = zalloc(sizeof(*xy) + xlen * row_size); if (xy != NULL) { xy->entry_size = entry_size; xy->row_size = row_size; xy->entries = xlen * ylen; xy->max_x = xlen; xy->max_...
[ 0, 0 ]
Linux Kernel
tools/lib/rbtree.c
static inline void rb_set_black(struct rb_node *rb) { rb->__rb_parent_color |= RB_BLACK; }
[ 0, 0 ]
Linux Kernel
tools/lib/rbtree.c
static inline void __rb_rotate_set_parents(struct rb_node *old, struct rb_node *new, struct rb_root *root, int color) { struct rb_node *parent = rb_parent(old); new->__rb_parent_color = old->__rb_parent_color; rb_set_parent_colo...
[ 0, 0 ]