All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Fastabend <john.fastabend@gmail.com>
To: Tero Kristo <tero.kristo@linux.intel.com>,
	 shuah@kernel.org,  tglx@linutronix.de,  x86@kernel.org,
	 bp@alien8.de,  dave.hansen@linux.intel.com,  mingo@redhat.com
Cc: ast@kernel.org,  linux-kselftest@vger.kernel.org,
	 linux-kernel@vger.kernel.org,  andrii@kernel.org,
	 daniel@iogearbox.net,  bpf@vger.kernel.org
Subject: RE: [PATCH 0/2] x86/BPF: Add new BPF helper call bpf_rdtsc
Date: Mon, 03 Jul 2023 14:55:57 -0700	[thread overview]
Message-ID: <64a343ed28ccc_6520520836@john.notmuch> (raw)
In-Reply-To: <20230703105745.1314475-1-tero.kristo@linux.intel.com>

Tero Kristo wrote:
> Hello,
> 
> This patch series adds a new x86 arch specific BPF helper, bpf_rdtsc()
> which can be used for reading the hardware time stamp counter (TSC.)
> Currently the same counter is directly accessible from userspace
> (using RDTSC instruction), and kernel space using various rdtsc_*()
> APIs, however eBPF lacks the support.
> 
> The main usage for the TSC counter is for various profiling and timing
> purposes, getting accurate cycle counter values. The counter can be
> currently read from BPF programs by using the existing perf subsystem
> services (bpf_perf_event_read()), however its usage is cumbersome at
> best. Additionally, the perf subsystem provides relative value only
> for the counter, but absolute values are desired by some use cases
> like Wult [1]. The absolute value of TSC can be read with BPF programs
> currently via some kprobe / bpf_core_read() magic (see [2], [3], [4] for
> example), but this relies on accessing kernel internals and is not
> stable API, and is pretty cumbersome. Thus, this patch proposes a new
> arch x86 specific BPF helper to avoid the above issues.
> 
> -Tero
> 
> [1] https://github.com/intel/wult
> [2] https://github.com/intel/wult/blob/c92237c95b898498faf41e6644983102d1fe5156/helpers/wult-tdt-helper/tdt-bpf.c#L102
> [3] https://github.com/intel/wult/blob/c92237c95b898498faf41e6644983102d1fe5156/helpers/wult-tdt-helper/tdt-bpf.c#L133
> [4] https://github.com/intel/wult/blob/c92237c95b898498faf41e6644983102d1fe5156/helpers/wult-tdt-helper/tdt-bpf.c#L488
> 
> 
> 

Makes a lot of sense to me.

Acked-by: John Fastabend <john.fastabend@gmail.com>

      parent reply	other threads:[~2023-07-03 21:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-03 10:57 [PATCH 0/2] x86/BPF: Add new BPF helper call bpf_rdtsc Tero Kristo
2023-07-03 10:57 ` [PATCH 1/2] x86/tsc: " Tero Kristo
2023-07-04  4:49   ` Yonghong Song
2023-07-06 12:00     ` Tero Kristo
2023-07-06  3:02   ` Alexei Starovoitov
2023-07-06  5:16     ` John Fastabend
2023-07-06 11:59       ` Tero Kristo
2023-07-06 19:51         ` Alexei Starovoitov
2023-07-07  5:41           ` John Fastabend
2023-07-07  8:27             ` Tero Kristo
2023-07-07 14:42               ` Alexei Starovoitov
2023-08-09 11:31                 ` Tero Kristo
2023-07-03 10:57 ` [PATCH 2/2] selftests/bpf: Add test for bpf_rdtsc Tero Kristo
2023-07-03 22:00   ` John Fastabend
2023-07-04  8:55     ` Tero Kristo
2023-07-06  4:57       ` John Fastabend
2023-07-03 21:55 ` John Fastabend [this message]

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=64a343ed28ccc_6520520836@john.notmuch \
    --to=john.fastabend@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bp@alien8.de \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=dave.hansen@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=shuah@kernel.org \
    --cc=tero.kristo@linux.intel.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /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.