Thread (35 messages) 35 messages, 9 authors, 2021-06-02

Re: [RFC PATCH bpf-next] bpf: Introduce bpf_timer

flat view

From: Toke Høiland-Jørgensen <hidden>
Date: 2021-05-24 18:39:53
Also in: bpf

Alexei Starovoitov [off-list ref] writes:
On Sun, May 23, 2021 at 8:58 AM Alexei Starovoitov
[off-list ref] wrote:
quoted
On Sun, May 23, 2021 at 4:48 AM Toke Høiland-Jørgensen [off-list ref] wrote:
quoted
Still wrapping my head around this, but one thing immediately sprang to
mind:
quoted
+ * long bpf_timer_mod(struct bpf_timer *timer, u64 msecs)
+ *   Description
+ *           Set the timer expiration N msecs from the current time.
+ *   Return
+ *           zero
Could we make this use nanoseconds (and wire it up to hrtimers) instead?
I would like to eventually be able to use this for pacing out network
packets, and msec precision is way too coarse for that...
msecs are used to avoid exposing jiffies to bpf prog, since msec_to_jiffies
isn't trivial to do in the bpf prog unlike the kernel.
hrtimer would be great to support as well.
It could be implemented via flags (which are currently zero only)
but probably not as a full replacement for jiffies based timers.
Like array vs hash. bpf_timer can support both.
After reading the hrtimer code I might take the above statement back...
hrtimer looks strictly better than timerwheel and jiffies.
It scales well and there are no concerns with overload,
since sys_nanonsleep and tcp are heavy users.
So I'm thinking to drop jiffies approach and do hrtimer only.
wdyt?
Oops, sorry, crossed streams, didn't see this before sending my other
reply. Yeah, hrtimers only SGTM :)

-Toke
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help