Re: [PATCH bpf-next v7 4/4] selftests/bpf: add usage example for cpu cycles kfuncs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux