Lines Matching refs:stackid
513 struct stackid { struct
523 static int stackid_init(struct stackid *stackid, struct bpf_map *map, in stackid_init() argument
535 stackid->nr = min_t(u32, trace_nr - skip, max_depth - skip); in stackid_init()
536 stackid->len = stackid->nr * sizeof(u64); in stackid_init()
537 stackid->ips = trace->ip + skip; in stackid_init()
538 stackid->hash = jhash2((const u32 *)stackid->ips, stackid->len / sizeof(u32), 0); in stackid_init()
539 stackid->id = stackid->hash & (smap->n_buckets - 1); in stackid_init()
540 stackid->bucket = READ_ONCE(smap->buckets[stackid->id]); in stackid_init()
541 stackid->hash_matches = stackid->bucket && stackid->bucket->hash == stackid->hash; in stackid_init()
545 static int stackid_fastpath(struct stackid *stackid, struct bpf_map *map, in stackid_fastpath() argument
551 err = stackid_init(stackid, map, trace, trace_nr, flags); in stackid_fastpath()
556 if (stackid->hash_matches && flags & BPF_F_FAST_STACK_CMP) in stackid_fastpath()
557 return stackid->id; in stackid_fastpath()
561 if (stackid->hash_matches && stackid->bucket->nr == stackid->nr && in stackid_fastpath()
562 memcmp(stackid->bucket->data, stackid->ips, stackid->len) == 0) in stackid_fastpath()
563 return stackid->id; in stackid_fastpath()
564 if (stackid->bucket && !(flags & BPF_F_REUSE_STACKID)) in stackid_fastpath()
570 stackid_new_bucket(struct stackid *stackid, struct bpf_map *map) in stackid_new_bucket() argument
583 for (i = 0; i < stackid->nr; i++) in stackid_new_bucket()
584 id_offs[i].ip = stackid->ips[i]; in stackid_new_bucket()
586 memcpy(bucket->data, stackid->ips, stackid->len); in stackid_new_bucket()
589 bucket->hash = stackid->hash; in stackid_new_bucket()
590 bucket->nr = stackid->nr; in stackid_new_bucket()
594 static long stackid_install(struct stackid *stackid, struct bpf_map *map, in stackid_install() argument
606 stack_map_get_build_id_offset(id_offs, stackid->nr, user, false /* !may_fault */); in stackid_install()
607 trace_len = stackid->nr * sizeof(struct bpf_stack_build_id); in stackid_install()
608 if (stackid->hash_matches && stackid->bucket->nr == stackid->nr && in stackid_install()
609 memcmp(stackid->bucket->data, new_bucket->data, trace_len) == 0) { in stackid_install()
611 return stackid->id; in stackid_install()
613 if (stackid->bucket && !(flags & BPF_F_REUSE_STACKID)) { in stackid_install()
619 old_bucket = xchg(&smap->buckets[stackid->id], new_bucket); in stackid_install()
622 return stackid->id; in stackid_install()
632 struct stackid stackid; in BPF_CALL_3() local
650 err = stackid_fastpath(&stackid, map, trace, trace->nr, flags); in BPF_CALL_3()
654 new_bucket = stackid_new_bucket(&stackid, map); in BPF_CALL_3()
659 return stackid_install(&stackid, map, new_bucket, flags); in BPF_CALL_3()
689 struct stackid stackid; in BPF_CALL_3() local
726 ret = stackid_fastpath(&stackid, map, trace, trace_nr, flags); in BPF_CALL_3()
730 new_bucket = stackid_new_bucket(&stackid, map); in BPF_CALL_3()
732 return stackid_install(&stackid, map, new_bucket, flags); in BPF_CALL_3()