diff options
author | cheloha <cheloha@cvs.openbsd.org> | 2020-01-24 15:58:34 +0000 |
---|---|---|
committer | cheloha <cheloha@cvs.openbsd.org> | 2020-01-24 15:58:34 +0000 |
commit | 7fecfc011e42d21ce3f65b4f5855d9fc88160b16 (patch) | |
tree | fcb35f28deb9ae28eec69de3a9b48ac1ff5606d4 /sys/kern | |
parent | 02bf819f950d91d048cbee120208a20e257c6474 (diff) |
*sleep_nsec(9): log process name and pid when nsecs == 0
We included DIAGNOSTIC in *sleep_nsec(9) when they were first committed
to help us sniff out divison-to-zero bugs when converting *sleep(9)
callers to the new interfaces.
Recently we exposed the new interface to userland callers. This has
yielded some warnings.
This diff adds a process name and pid to the warnings to help determine
the source of the zero-length sleeps.
ok mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/kern_synch.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/sys/kern/kern_synch.c b/sys/kern/kern_synch.c index 3ca58be881e..f23fdfffcda 100644 --- a/sys/kern/kern_synch.c +++ b/sys/kern/kern_synch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_synch.c,v 1.160 2020/01/21 16:16:23 mpi Exp $ */ +/* $OpenBSD: kern_synch.c,v 1.161 2020/01/24 15:58:33 cheloha Exp $ */ /* $NetBSD: kern_synch.c,v 1.37 1996/04/22 01:38:37 christos Exp $ */ /* @@ -164,8 +164,10 @@ tsleep_nsec(const volatile void *ident, int priority, const char *wmesg, return tsleep(ident, priority, wmesg, 0); #ifdef DIAGNOSTIC if (nsecs == 0) { - log(LOG_WARNING, "%s: %s: trying to sleep zero nanoseconds\n", - __func__, wmesg); + log(LOG_WARNING, + "%s: %s[%d]: %s: trying to sleep zero nanoseconds\n", + __func__, curproc->p_p->ps_comm, curproc->p_p->ps_pid, + wmesg); } #endif /* @@ -288,8 +290,10 @@ msleep_nsec(const volatile void *ident, struct mutex *mtx, int priority, return msleep(ident, mtx, priority, wmesg, 0); #ifdef DIAGNOSTIC if (nsecs == 0) { - log(LOG_WARNING, "%s: %s: trying to sleep zero nanoseconds\n", - __func__, wmesg); + log(LOG_WARNING, + "%s: %s[%d]: %s: trying to sleep zero nanoseconds\n", + __func__, curproc->p_p->ps_comm, curproc->p_p->ps_pid, + wmesg); } #endif nsecs = MIN(nsecs, UINT64_MAX - tick_nsec); @@ -338,8 +342,10 @@ rwsleep_nsec(const volatile void *ident, struct rwlock *rwl, int priority, return rwsleep(ident, rwl, priority, wmesg, 0); #ifdef DIAGNOSTIC if (nsecs == 0) { - log(LOG_WARNING, "%s: %s: trying to sleep zero nanoseconds\n", - __func__, wmesg); + log(LOG_WARNING, + "%s: %s[%d]: %s: trying to sleep zero nanoseconds\n", + __func__, curproc->p_p->ps_comm, curproc->p_p->ps_pid, + wmesg); } #endif nsecs = MIN(nsecs, UINT64_MAX - tick_nsec); |