Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern KERNEL_LOCK(9): Avoid spinning out until 10sec have...



details:   https://anonhg.NetBSD.org/src/rev/1f20342fa020
branches:  trunk
changeset: 370036:1f20342fa020
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Tue Sep 13 09:28:05 2022 +0000

description:
KERNEL_LOCK(9): Avoid spinning out until 10sec have passed.

This means we'll never spin out if the hardclock timer is stuck.  But
the hardclock timer never runs with the kernel lock held itself, so
it's not immediately clear that's important.

diffstat:

 sys/kern/kern_lock.c |  8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diffs (36 lines):

diff -r 1d0bdd03764f -r 1f20342fa020 sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c      Tue Sep 13 09:14:26 2022 +0000
+++ b/sys/kern/kern_lock.c      Tue Sep 13 09:28:05 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_lock.c,v 1.179 2022/09/13 09:14:26 riastradh Exp $        */
+/*     $NetBSD: kern_lock.c,v 1.180 2022/09/13 09:28:05 riastradh Exp $        */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.179 2022/09/13 09:14:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.180 2022/09/13 09:28:05 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lockdebug.h"
@@ -195,6 +195,7 @@
 #ifdef LOCKDEBUG
        static struct cpu_info *kernel_lock_holder;
        u_int spins = 0;
+       u_int starttime = getticks();
 #endif
        int s;
        struct lwp *l = curlwp;
@@ -254,7 +255,8 @@
                while (__SIMPLELOCK_LOCKED_P(kernel_lock)) {
 #ifdef LOCKDEBUG
                        extern int start_init_exec;
-                       if (SPINLOCK_SPINOUT(spins) && start_init_exec) {
+                       if (SPINLOCK_SPINOUT(spins) && start_init_exec &&
+                           (getticks() - starttime) > 10*hz) {
                                ipi_msg_t msg = {
                                        .func = kernel_lock_trace_ipi,
                                };



Home | Main Index | Thread Index | Old Index