The branch stable/13 has been updated by kib:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3cb7188a310c36359cf0493a2abf58df5d8bfec6

commit 3cb7188a310c36359cf0493a2abf58df5d8bfec6
Author:     Konstantin Belousov <k...@freebsd.org>
AuthorDate: 2021-03-05 23:31:20 +0000
Commit:     Konstantin Belousov <k...@freebsd.org>
CommitDate: 2021-04-23 11:14:09 +0000

    Add helper for kqueue timers callout scheduling
    
    (cherry picked from commit 533e5057ed2503013643bf8450588e4aa58c2b7e)
---
 sys/kern/kern_event.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/sys/kern/kern_event.c b/sys/kern/kern_event.c
index 5185723b8d10..5e9f1fc35dfe 100644
--- a/sys/kern/kern_event.c
+++ b/sys/kern/kern_event.c
@@ -676,10 +676,19 @@ timer2sbintime(int64_t data, int flags)
 
 struct kq_timer_cb_data {
        struct callout c;
+       struct knote *kn;
+       int cpuid;
        sbintime_t next;        /* next timer event fires at */
        sbintime_t to;          /* precalculated timer period, 0 for abs */
 };
 
+static void
+kqtimer_sched_callout(struct kq_timer_cb_data *kc)
+{
+       callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kc->kn,
+           kc->cpuid, C_ABSOLUTE);
+}
+
 static void
 filt_timerexpire(void *knx)
 {
@@ -696,8 +705,7 @@ filt_timerexpire(void *knx)
        if (kc->to == 0)
                return;
        kc->next += kc->to;
-       callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kn,
-           PCPU_GET(cpuid), C_ABSOLUTE);
+       kqtimer_sched_callout(kc);
 }
 
 /*
@@ -753,6 +761,8 @@ filt_timerattach(struct knote *kn)
                kn->kn_flags |= EV_CLEAR;       /* automatically set */
        kn->kn_status &= ~KN_DETACHED;          /* knlist_add clears it */
        kn->kn_ptr.p_v = kc = malloc(sizeof(*kc), M_KQUEUE, M_WAITOK);
+       kc->kn = kn;
+       kc->cpuid = PCPU_GET(cpuid);
        callout_init(&kc->c, 1);
        filt_timerstart(kn, to);
 
@@ -772,8 +782,7 @@ filt_timerstart(struct knote *kn, sbintime_t to)
                kc->next = to + sbinuptime();
                kc->to = to;
        }
-       callout_reset_sbt_on(&kc->c, kc->next, 0, filt_timerexpire, kn,
-           PCPU_GET(cpuid), C_ABSOLUTE);
+       kqtimer_sched_callout(kc);
 }
 
 static void
_______________________________________________
dev-commits-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all
To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"

Reply via email to