return 0;
}
+static void initialize_perturb(sd_event *e) {
+ sd_id128_t bootid = {};
+
+ /* When we sleep for longer, we try to realign the wakeup to
+ the same time wihtin each minute/second/250ms, so that
+ events all across the system can be coalesced into a single
+ CPU wakeup. However, let's take some system-specific
+ randomness for this value, so that in a network of systems
+ with synced clocks timer events are distributed a
+ bit. Here, we calculate a perturbation usec offset from the
+ boot ID. */
+
+ if (_likely_(e->perturb != (usec_t) -1))
+ return;
+
+ if (sd_id128_get_boot(&bootid) >= 0)
+ e->perturb = (bootid.qwords[0] ^ bootid.qwords[1]) % USEC_PER_MINUTE;
+}
+
static int event_setup_timer_fd(
sd_event *e,
struct clock_data *d,
clockid_t clock) {
- sd_id128_t bootid = {};
struct epoll_event ev = {};
int r, fd;
}
d->fd = fd;
-
- /* When we sleep for longer, we try to realign the wakeup to
- the same time wihtin each minute/second/250ms, so that
- events all across the system can be coalesced into a single
- CPU wakeup. However, let's take some system-specific
- randomness for this value, so that in a network of systems
- with synced clocks timer events are distributed a
- bit. Here, we calculate a perturbation usec offset from the
- boot ID. */
-
- if (e->perturb == (usec_t) -1)
- if (sd_id128_get_boot(&bootid) >= 0)
- e->perturb = (bootid.qwords[0] ^ bootid.qwords[1]) % USEC_PER_MINUTE;
-
return 0;
}
if (b <= a + 1)
return a;
+ initialize_perturb(e);
+
/*
Find a good time to wake up again between times a and b. We
have two goals here: