bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v1 PATCH 0/7] bpf: Make RT friendly.
@ 2019-12-08  0:03 David Miller
  2019-12-11  1:28 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-12-08  0:03 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, tglx


The goal of this patch set is to make the BPF code friendly in RT
configurations.

The first step is eliminating preemption disable/enable and replacing
it with local lock usage when full RT is enabled.

Likewise we also need to elide usage of up_read_non_owner() in the
stackmap code when full RT is turned on.

Signed-off-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC v1 PATCH 0/7] bpf: Make RT friendly.
  2019-12-08  0:03 [RFC v1 PATCH 0/7] bpf: Make RT friendly David Miller
@ 2019-12-11  1:28 ` David Miller
  2019-12-19 11:32   ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2019-12-11  1:28 UTC (permalink / raw)
  To: bpf, netdev; +Cc: ast, daniel, tglx

From: David Miller <davem@davemloft.net>
Date: Sat, 07 Dec 2019 16:03:57 -0800 (PST)

> 
> The goal of this patch set is to make the BPF code friendly in RT
> configurations.
> 
> The first step is eliminating preemption disable/enable and replacing
> it with local lock usage when full RT is enabled.
> 
> Likewise we also need to elide usage of up_read_non_owner() in the
> stackmap code when full RT is turned on.
> 
> Signed-off-by: David S. Miller <davem@davemloft.net>

Thomas can you please take a look at this patch series?

It eliminates all of the RT problems we were made aware of, and these
patches have been through the bpf test suite as well as gotten 0-day
testing.

The only major thing we needs ACK'd is the locallock stubs.

Thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC v1 PATCH 0/7] bpf: Make RT friendly.
  2019-12-11  1:28 ` David Miller
@ 2019-12-19 11:32   ` Thomas Gleixner
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Gleixner @ 2019-12-19 11:32 UTC (permalink / raw)
  To: David Miller; +Cc: bpf, netdev, ast, daniel

David,

On Tue, 10 Dec 2019, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Sat, 07 Dec 2019 16:03:57 -0800 (PST)
> 
> > 
> > The goal of this patch set is to make the BPF code friendly in RT
> > configurations.
> > 
> > The first step is eliminating preemption disable/enable and replacing
> > it with local lock usage when full RT is enabled.
> > 
> > Likewise we also need to elide usage of up_read_non_owner() in the
> > stackmap code when full RT is turned on.
> > 
> > Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> Thomas can you please take a look at this patch series?
> 
> It eliminates all of the RT problems we were made aware of, and these
> patches have been through the bpf test suite as well as gotten 0-day
> testing.
> 
> The only major thing we needs ACK'd is the locallock stubs.

Sorry for the late reply. I had to take myself out for a while and I just
saw this by chance while looking for something else. I was not planning
to look at any kernel stuff before Jan 7th.

Thanks for looking into that!

This is going into the direction I had in mind, but from a quick look, I
think this is missing a few details.

The invocation and locking needs to be context aware. local_locks are
'sleeping' locks on RT, so you can't take them from truly atomic contexts.

The reason why RT works at all is that the kernel is pretty strict about
execution context and most things have context aware entry points. Aa far
as I understand BPF has a single entry point (please correct me if I'm
wrong).

I assume that you know in which context a BPF program will run at verifier
time, as you need to prevent certain calls from e.g. perf context, right?

For RT we really need context sensitive entry points

   - atomic entry. Called from (even on RT) atomic contexts like tracing,
     perf, kprobes ....

     These entry points do not need preempt_disable() at all, because those
     contexts have preemption already disabled.

     None of these BPF programs should invoke memory allocation functions
     or stuff like that.

   - BH disabled context entry.

     On non RT preempt disable is not required because preemption is
     already disabled.

     On RT BH context is non-reentrant, but can be preempted. The question is
     whether the BH non-reentrance guarantee is enough or not.

     If you need to protect that against other BPF stuff then we'd need a
     local lock there.

   - Regular thread context. This needs preempt disable on non RT and a
     local lock on RT.

If we treat BH disabled and thread context the same, then two entry points
are enough.

So if you could provide context sensitive entry points, then adding RT
support into it should be just a pretty trivial patch.

Thanks,

	Thomas

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-19 11:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-08  0:03 [RFC v1 PATCH 0/7] bpf: Make RT friendly David Miller
2019-12-11  1:28 ` David Miller
2019-12-19 11:32   ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).