All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Thomas Gleixner <tglx@linutronix.de>,
	Alexei Starovoitov <alexei.starovoitov@gmail.com>,
	Kurt Kanzenbach <kurt@linutronix.de>
Cc: brouer@redhat.com, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Joanne Koong <joannelkoong@gmail.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Dave Marchevsky <davemarchevsky@fb.com>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Geliang Tang <geliang.tang@suse.com>,
	Jakub Sitnicki <jakub@cloudflare.com>,
	Network Development <netdev@vger.kernel.org>,
	bpf <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next] bpf: Add BPF-helper for accessing CLOCK_TAI
Date: Tue, 7 Jun 2022 21:35:05 +0200	[thread overview]
Message-ID: <c166aa47-e404-e6ee-0ec5-0ead1923f412@redhat.com> (raw)
In-Reply-To: <875ylc6djv.ffs@tglx>


On 07/06/2022 11.14, Thomas Gleixner wrote:
> Alexei,
> 
> On Mon, Jun 06 2022 at 08:57, Alexei Starovoitov wrote:
>> On Mon, Jun 6, 2022 at 3:38 AM Kurt Kanzenbach <kurt@linutronix.de> wrote:
>>>
>>> From: Jesper Dangaard Brouer <brouer@redhat.com>
>>>
>>> Commit 3dc6ffae2da2 ("timekeeping: Introduce fast accessor to clock tai")
>>> introduced a fast and NMI-safe accessor for CLOCK_TAI. Especially in time
>>> sensitive networks (TSN), where all nodes are synchronized by Precision Time
>>> Protocol (PTP), it's helpful to have the possibility to generate timestamps
>>> based on CLOCK_TAI instead of CLOCK_MONOTONIC. With a BPF helper for TAI in
>>> place, it becomes very convenient to correlate activity across different
>>> machines in the network.
>>
>> That's a fresh feature. It feels risky to bake it into uapi already.
> 
> What? That's just support for a different CLOCK. What's so risky about
> it?

I didn't think it was "risky" as this is already exported as:
  EXPORT_SYMBOL_GPL(ktime_get_tai_fast_ns);

Correct me if I'm wrong, but this simple gives BPF access to CLOCK_TAI
(see man clock_gettime(2)), right?
And CLOCK_TAI is not really a new/fresh type of CLOCK.

Especially for networking we need this CLOCK_TAI time as HW LaunchTime
need this (e.g. see qdisc's sch_etf.c and sch_taprio.c).

> 
>> imo it would be better to annotate tk_core variable in vmlinux BTF.
>> Then progs will be able to read all possible timekeeper offsets.
> 
> We are exposing APIs. APIs can be supported, but exposing implementation
> details creates ABIs of the worst sort because that prevents the kernel
> from changing the implementation. We've seen the fallout with the recent
> tracepoint changes already.

Hmm... annotate tk_core variable in vmlinux BTF and letting BPF progs
access this seems like an unsafe approach and we tempt BPF-developers to
think other parts are okay to access.

Accessing timekeeper->offs_tai might be okay as it is already "marked" 
with data_race(tk->offs_tai), but I'm not sure about other members, as 
I'm not expert in this area.

I assume that the include filename <linux/timekeeper_internal.h>
indicate that the maintainers don't want to open up access to struct
timekeeper...

--Jesper


  reply	other threads:[~2022-06-08  0:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-06 10:37 [PATCH bpf-next] bpf: Add BPF-helper for accessing CLOCK_TAI Kurt Kanzenbach
2022-06-06 15:57 ` Alexei Starovoitov
2022-06-07  9:14   ` Thomas Gleixner
2022-06-07 19:35     ` Jesper Dangaard Brouer [this message]
2022-06-08  2:01       ` Alexei Starovoitov
2022-06-08  6:13         ` Kurt Kanzenbach
2022-08-02  7:06         ` Kurt Kanzenbach
2022-08-02 15:03           ` Alexei Starovoitov
2022-08-03  6:29             ` Kurt Kanzenbach
2022-08-03  9:28               ` Maciej Fijalkowski
2022-08-03 17:29                 ` Andrii Nakryiko
2022-08-03 17:28               ` Andrii Nakryiko
2022-08-04  6:40                 ` Kurt Kanzenbach
2022-08-09  0:28                   ` Andrii Nakryiko

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=c166aa47-e404-e6ee-0ec5-0ead1923f412@redhat.com \
    --to=jbrouer@redhat.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davemarchevsky@fb.com \
    --cc=geliang.tang@suse.com \
    --cc=jakub@cloudflare.com \
    --cc=joannelkoong@gmail.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@kernel.org \
    --cc=kurt@linutronix.de \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=yhs@fb.com \
    /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.