BPF List
 help / color / mirror / Atom feed
From: Barret Rhoden <brho@google.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf <bpf@vger.kernel.org>, Dohyun Kim <dohyunkim@google.com>,
	Neel Natu <neelnatu@google.com>
Subject: Re: BPF timers in hard irq context?
Date: Thu, 23 May 2024 12:42:48 -0400	[thread overview]
Message-ID: <28aaad42-3859-43ea-8a45-dbe83bcfd5d0@google.com> (raw)
In-Reply-To: <CAADnVQJw=mEX7ZEKffGMUm9my1Di9wFHwayhz+4vno_fypmnsQ@mail.gmail.com>

On 5/22/24 16:03, Alexei Starovoitov wrote:
> On Tue, May 21, 2024 at 2:59 PM Barret Rhoden <brho@google.com> wrote:
>>
>> hi -
>>
>> we've noticed some variability in bpf timer expiration that goes away if
>> we change the timers to run in hardirq context.
> 
> What kind of variability are we talking about?

hmm - it's actually worse than just variability.  the issue is that 
we're using the timer to implement scheduling policy.  yet the timer 
sometimes gets handled by ksoftirqd.  and ksoftirqd relies on the 
scheduling policy to run.  we end up with a circular dependence.

e.g. say we want to let a very high priority thread run for 50us. 
ideally we'd just set a timer for 50us and force a context switch when 
it goes off.

but if timers might require ksoftirqd to run, we'll have to treat that 
ksoftirqd specially (always run ksoftirqd if it is runnable), and then 
we won't be able to let the high prio thread run ahead of other, less 
important softirqs.

>> i imagine the use of softirqs was to keep the potentially long-running
>> timer callback out of hardirq, but is there anything particularly
>> dangerous about making them run in hardirq?
> 
> exactly what you said. We don't have a good mechanism to
> keep bpf prog runtime tiny enough for hardirq.

i think stuff like the scheduler tick, and any bpf progs that run there 
are also run in hardirq.  let alone tracing progs.  so maybe if we've 
already opened the gates to hardirq progs, then maybe letting timers run 
there too would be ok?  perhaps with CAP_BPF.

barret



  reply	other threads:[~2024-05-23 16:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-21 21:59 BPF timers in hard irq context? Barret Rhoden
2024-05-22 20:03 ` Alexei Starovoitov
2024-05-23 16:42   ` Barret Rhoden [this message]
2024-05-24 20:48     ` Alexei Starovoitov

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=28aaad42-3859-43ea-8a45-dbe83bcfd5d0@google.com \
    --to=brho@google.com \
    --cc=alexei.starovoitov@gmail.com \
    --cc=bpf@vger.kernel.org \
    --cc=dohyunkim@google.com \
    --cc=neelnatu@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox