On Mon, Nov 18, 2024 at 10:52:45AM -0800, Vadim Fedorenko wrote: > +int bpf_cpu_cycles(void) > +{ > + struct bpf_pidns_info pidns; > + __u64 start; > + > + start = bpf_get_cpu_cycles(); > + bpf_get_ns_current_pid_tgid(0, 0, &pidns, sizeof(struct bpf_pidns_info)); > + cycles = bpf_get_cpu_cycles() - start; > + ns = bpf_cpu_cycles_to_ns(cycles); > + return 0; > +} Oh, the intent is to use that cycles_to_ns() on deltas. That wasn't at all clear. Anyway, the above has more problems than just bad naming. TSC is constant and not affected by DVFS, so depending on the DVFS state of things your function will return wildly different readings. Why do you think you need this?