All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexei Starovoitov <alexei.starovoitov@gmail.com>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: Andrii Nakryiko <andrii.nakryiko@gmail.com>,
	Quentin Monnet <quentin@isovalent.com>, bpf <bpf@vger.kernel.org>,
	Networking <netdev@vger.kernel.org>,
	Martin KaFai Lau <kafai@fb.com>
Subject: Re: [PATCH bpf-next] bpf, bpftool: Allow probing for CONFIG_HZ from kernel config
Date: Fri, 15 May 2020 08:23:14 -0700	[thread overview]
Message-ID: <CAADnVQLDfOHg1DT+JrUgiM6-Z2Ocrj8qf90_ViLVZXS5W3D8_w@mail.gmail.com> (raw)
In-Reply-To: <20200515121235.GA7407@pc-9.home>

On Fri, May 15, 2020 at 5:12 AM Daniel Borkmann <daniel@iogearbox.net> wrote:
> >
> > libbpf supports kconfig values, so don't have to even probe for that,
> > it will just appear as a constant global variable:
> >
> > extern unsigned long CONFIG_HZ __kconfig;
> >
> > But I assume you want this for iproute2 case, which doesn't support
> > this, right? We really should try to make iproute2 just use libbpf as
>
> It's one but not the only reason. Our golang daemon picks up the json config
> from `bpftool feature -j` and based on that we decide which features our BPF
> datapath will have where the daemons needs to also adapt accordingly. So for
> users running older kernels we need fallback behavior in our daemon, for
> example, in case of missing LPM delete or get_next_key from syscall side the
> LPM map management and/or program regeneration will differ in the agent. In
> case of jiffies, it's also not as trivial from control plane side, e.g.
> existing deployments cannot simply switch from ktime to jiffies during upgrade
> while traffic is live in the datapath given this has upgrade and downgrade
> implications on timeouts. However, we can switch to using it for new deployments
> via helm. In that case, the agent today probes for availability, so it needs
> to know i) whether the underlying kernel supports jiffies64 helper, ii) it needs
> to know the kernel hz value in order to convert timeouts for our CT's GC. This
> is done based on bpftool feature -j from the agent's probe manager. Next, we
> also cannot assume general availability of an existing .config from distro side,
> so in that case we run the probe to determine kernel hz and emit the CONFIG_HZ
> define instead, and if all breaks down we fall back to using ktime in our data
> path. From the macro side, the timeouts all resolve nicely during compilation
> time since everything is passed as a constant here. We have a small helper for
> bpf_jiffies_to_sec() and bpf_sec_to_jiffies() that resolves it whereas `extern
> unsigned long CONFIG_HZ __kconfig` hapens at load time plus relies on the fact
> that config must be available, although the latter could probably be fixed via
> user-callback.

fair enough.
Applied to bpf-next. Thanks

      reply	other threads:[~2020-05-15 15:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-13  7:58 [PATCH bpf-next] bpf, bpftool: Allow probing for CONFIG_HZ from kernel config Daniel Borkmann
2020-05-13 10:42 ` Quentin Monnet
2020-05-13 11:26   ` Daniel Borkmann
2020-05-14 23:19 ` Andrii Nakryiko
2020-05-15 12:12   ` Daniel Borkmann
2020-05-15 15:23     ` Alexei Starovoitov [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=CAADnVQLDfOHg1DT+JrUgiM6-Z2Ocrj8qf90_ViLVZXS5W3D8_w@mail.gmail.com \
    --to=alexei.starovoitov@gmail.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=quentin@isovalent.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.