From: Vadim Fedorenko <vadim.fedorenko@linux.dev>
To: Peter Zijlstra <peterz@infradead.org>,
Andrii Nakryiko <andrii@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>,
Yonghong Song <yonghong.song@linux.dev>,
Mykola Lysenko <mykolal@fb.com>,
x86@kernel.org, bpf@vger.kernel.org,
Martin KaFai Lau <martin.lau@linux.dev>
Subject: Re: [PATCH bpf-next v7 1/4] bpf: add bpf_get_cpu_cycles kfunc
Date: Tue, 19 Nov 2024 10:03:01 -0800 [thread overview]
Message-ID: <6d525549-b623-4292-b700-ee94eb313eb1@linux.dev> (raw)
In-Reply-To: <20241119161753.GA28920@noisy.programming.kicks-ass.net>
On 19/11/2024 08:17, Peter Zijlstra wrote:
> On Tue, Nov 19, 2024 at 06:29:09AM -0800, Vadim Fedorenko wrote:
>> On 19/11/2024 03:18, Peter Zijlstra wrote:
>>> On Mon, Nov 18, 2024 at 10:52:42AM -0800, Vadim Fedorenko wrote:
>>>> @@ -2094,6 +2094,13 @@ static int do_jit(struct bpf_prog *bpf_prog, int *addrs, u8 *image,
>>>> if (insn->src_reg == BPF_PSEUDO_KFUNC_CALL) {
>>>> int err;
>>>> + if (imm32 == BPF_CALL_IMM(bpf_get_cpu_cycles)) {
>>>> + if (cpu_feature_enabled(X86_FEATURE_LFENCE_RDTSC))
>>>> + EMIT3(0x0F, 0xAE, 0xE8);
>>>> + EMIT2(0x0F, 0x31);
>>>> + break;
>>>> + }
>>>
>>> TSC != cycles. Naming is bad.
>>
>> Any suggestions?
>>
>> JIT for other architectures will come after this one is merged and some
>> of them will be using cycles, so not too far away form the truth..
>
> bpf_get_time_stamp() ?
> bpf_get_counter() ?
Well, we have already been somewhere nearby these names [1].
[1]
https://lore.kernel.org/bpf/CAEf4BzaBNNCYaf9a4oHsB2AzYyc6JCWXpHx6jk22Btv=UAgX4A@mail.gmail.com/
bpf_get_time_stamp() doesn't really explain that the actual timestamp
will be provided by CPU hardware.
bpf_get_counter() is again too general, doesn't provide any information
about what type of counter will be returned. The more specific name,
bpf_get_cycles_counter(), was also discussed in v3 (accidentally, it
didn't reach mailing list). The quote of feedback from Andrii is:
Bikeshedding time, but let's be consistently slightly verbose, but
readable. Give nwe have bpf_get_cpu_cycles_counter (which maybe we
should shorten to "bpf_get_cpu_cycles()"), we should call this
something like "bpf_cpu_cycles_to_ns()".
It might make a bit more sense to name it bpf_get_cpu_counter(), but it
still looks too general.
Honestly, I'm not a fan of renaming functions once again, I would let
Andrii to vote for naming.
next prev parent reply other threads:[~2024-11-19 18:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 18:52 [PATCH bpf-next v7 0/4] bpf: add cpu cycles kfuncss Vadim Fedorenko
2024-11-18 18:52 ` [PATCH bpf-next v7 1/4] bpf: add bpf_get_cpu_cycles kfunc Vadim Fedorenko
2024-11-19 11:18 ` Peter Zijlstra
2024-11-19 14:29 ` Vadim Fedorenko
2024-11-19 16:17 ` Peter Zijlstra
2024-11-19 18:03 ` Vadim Fedorenko [this message]
2024-11-19 19:16 ` Andrii Nakryiko
2024-11-19 19:27 ` Vadim Fedorenko
2024-11-18 18:52 ` [PATCH bpf-next v7 2/4] bpf: add bpf_cpu_cycles_to_ns helper Vadim Fedorenko
2024-11-19 11:28 ` Peter Zijlstra
2024-11-19 14:38 ` Vadim Fedorenko
2024-11-20 8:49 ` Peter Zijlstra
2024-11-20 13:39 ` Vadim Fedorenko
2024-11-18 18:52 ` [PATCH bpf-next v7 3/4] selftests/bpf: add selftest to check rdtsc jit Vadim Fedorenko
2024-11-18 18:52 ` [PATCH bpf-next v7 4/4] selftests/bpf: add usage example for cpu cycles kfuncs Vadim Fedorenko
2024-11-19 11:47 ` Peter Zijlstra
2024-11-19 14:45 ` Vadim Fedorenko
2024-11-20 8:51 ` Peter Zijlstra
2024-11-20 17:19 ` Vadim Fedorenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6d525549-b623-4292-b700-ee94eb313eb1@linux.dev \
--to=vadim.fedorenko@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.