Source-Changes-HG archive

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

[src/trunk]: src/sys/kern calcru: ignore running softints, unless softint_tim...



details:   https://anonhg.NetBSD.org/src/rev/60bf0fd90459
branches:  trunk
changeset: 461272:60bf0fd90459
user:      ad <ad%NetBSD.org@localhost>
date:      Thu Nov 21 17:50:49 2019 +0000

description:
calcru: ignore running softints, unless softint_timing is on.
Fixes crazy times reported for proc0.

diffstat:

 sys/kern/kern_resource.c |   8 +++++---
 sys/kern/kern_softint.c  |  12 +++++++-----
 2 files changed, 12 insertions(+), 8 deletions(-)

diffs (77 lines):

diff -r 943422c0e146 -r 60bf0fd90459 sys/kern/kern_resource.c
--- a/sys/kern/kern_resource.c  Thu Nov 21 17:47:53 2019 +0000
+++ b/sys/kern/kern_resource.c  Thu Nov 21 17:50:49 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_resource.c,v 1.182 2019/04/05 00:33:21 mlelstv Exp $      */
+/*     $NetBSD: kern_resource.c,v 1.183 2019/11/21 17:50:49 ad Exp $   */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.182 2019/04/05 00:33:21 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.183 2019/11/21 17:50:49 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -506,7 +506,8 @@
        LIST_FOREACH(l, &p->p_lwps, l_sibling) {
                lwp_lock(l);
                bintime_add(&tm, &l->l_rtime);
-               if ((l->l_pflag & LP_RUNNING) != 0) {
+               if ((l->l_pflag & LP_RUNNING) != 0 &&
+                   (l->l_pflag & (LP_INTR | LP_TIMEINTR)) != LP_INTR) {
                        struct bintime diff;
                        /*
                         * Adjust for the current time slice.  This is
@@ -516,6 +517,7 @@
                         * error.
                         */
                        binuptime(&diff);
+                       membar_consumer(); /* for softint_dispatch() */
                        bintime_sub(&diff, &l->l_stime);
                        bintime_add(&tm, &diff);
                }
diff -r 943422c0e146 -r 60bf0fd90459 sys/kern/kern_softint.c
--- a/sys/kern/kern_softint.c   Thu Nov 21 17:47:53 2019 +0000
+++ b/sys/kern/kern_softint.c   Thu Nov 21 17:50:49 2019 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $    */
+/*     $NetBSD: kern_softint.c,v 1.49 2019/11/21 17:50:49 ad Exp $     */
 
 /*-
- * Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2007, 2008, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.48 2019/10/06 15:11:17 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.49 2019/11/21 17:50:49 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -866,14 +866,16 @@
        timing = (softint_timing ? LP_TIMEINTR : 0);
        l->l_switchto = pinned;
        l->l_stat = LSONPROC;
-       l->l_pflag |= (LP_RUNNING | timing);
 
        /*
         * Dispatch the interrupt.  If softints are being timed, charge
         * for it.
         */
-       if (timing)
+       if (timing) {
                binuptime(&l->l_stime);
+               membar_producer();      /* for calcru */
+       }
+       l->l_pflag |= (LP_RUNNING | timing);
        softint_execute(si, l, s);
        if (timing) {
                binuptime(&now);



Home | Main Index | Thread Index | Old Index