-/* $OpenBSD: kern_timeout.c,v 1.86 2022/11/08 19:09:53 cheloha Exp $ */
+/* $OpenBSD: kern_timeout.c,v 1.87 2022/11/09 17:12:50 cheloha Exp $ */
/*
* Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org>
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
timeout_set_kclock(struct timeout *to, void (*fn)(void *), void *arg,
int kclock, int flags)
{
- _timeout_set(to, fn, arg, kclock, flags | TIMEOUT_KCLOCK);
+ _timeout_set(to, fn, arg, kclock, flags);
}
int
int ret = 1;
KASSERT(ISSET(new->to_flags, TIMEOUT_INITIALIZED));
- KASSERT(!ISSET(new->to_flags, TIMEOUT_KCLOCK));
KASSERT(new->to_kclock == KCLOCK_NONE);
KASSERT(to_ticks >= 0);
mtx_enter(&timeout_mutex);
- KASSERT(ISSET(to->to_flags, TIMEOUT_INITIALIZED | TIMEOUT_KCLOCK));
+ KASSERT(ISSET(to->to_flags, TIMEOUT_INITIALIZED));
KASSERT(to->to_kclock != KCLOCK_NONE);
old_abstime = to->to_abstime;
uint32_t
timeout_bucket(const struct timeout *to)
{
- struct kclock *kc = &timeout_kclock[to->to_kclock];
struct timespec diff, shifted_abstime;
+ struct kclock *kc;
uint32_t level;
- KASSERT(ISSET(to->to_flags, TIMEOUT_KCLOCK));
- KASSERT(timespeccmp(&kc->kc_lastscan, &to->to_abstime, <));
+ KASSERT(to->to_kclock == KCLOCK_UPTIME);
+ kc = &timeout_kclock[to->to_kclock];
+ KASSERT(timespeccmp(&kc->kc_lastscan, &to->to_abstime, <));
timespecsub(&to->to_abstime, &kc->kc_lastscan, &diff);
for (level = 0; level < nitems(timeout_level_width) - 1; level++) {
if (diff.tv_sec < timeout_level_width[level])
CIRCQ_REMOVE(&to->to_list);
if (to == first_new)
new = 1;
- if (ISSET(to->to_flags, TIMEOUT_KCLOCK))
+ if (to->to_kclock != KCLOCK_NONE)
softclock_process_kclock_timeout(to, new);
else
softclock_process_tick_timeout(to, new);
else if (bucket == &timeout_proc)
where = "thread";
else {
- if (ISSET(to->to_flags, TIMEOUT_KCLOCK))
+ if (to->to_kclock != KCLOCK_NONE)
wheel = timeout_wheel_kc;
else
wheel = timeout_wheel;
(bucket - wheel) / WHEELSIZE);
where = buf;
}
- if (ISSET(to->to_flags, TIMEOUT_KCLOCK)) {
+ if (to->to_kclock != KCLOCK_NONE) {
kc = &timeout_kclock[to->to_kclock];
timespecsub(&to->to_abstime, &kc->kc_lastscan, &remaining);
db_printf("%20s %8s %7s 0x%0*lx %s\n",
-/* $OpenBSD: timeout.h,v 1.44 2022/11/08 19:09:53 cheloha Exp $ */
+/* $OpenBSD: timeout.h,v 1.45 2022/11/09 17:12:50 cheloha Exp $ */
/*
* Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org>
* All rights reserved.
#define TIMEOUT_ONQUEUE 0x02 /* on any timeout queue */
#define TIMEOUT_INITIALIZED 0x04 /* initialized */
#define TIMEOUT_TRIGGERED 0x08 /* running or ran */
-#define TIMEOUT_KCLOCK 0x10 /* clock-based timeout */
struct timeoutstat {
uint64_t tos_added; /* timeout_add*(9) calls */
}
#define TIMEOUT_INITIALIZER_KCLOCK(_fn, _arg, _kclock, _flags) \
- __TIMEOUT_INITIALIZER((_fn), (_arg), (_kclock), (_flags) | TIMEOUT_KCLOCK)
+ __TIMEOUT_INITIALIZER((_fn), (_arg), (_kclock), (_flags))
#define TIMEOUT_INITIALIZER_FLAGS(_fn, _arg, _flags) \
__TIMEOUT_INITIALIZER((_fn), (_arg), KCLOCK_NONE, (_flags))