Source-Changes-HG archive

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

[src/trunk]: src/sys/kern - Put back a microoptimisation that was accidentall...



details:   https://anonhg.NetBSD.org/src/rev/a33135af2961
branches:  trunk
changeset: 1004912:a33135af2961
user:      ad <ad%NetBSD.org@localhost>
date:      Wed Nov 20 21:49:00 2019 +0000

description:
- Put back a microoptimisation that was accidentally removed.
- Comments.

diffstat:

 sys/kern/kern_condvar.c |  32 +++++++++++++++++++++++---------
 1 files changed, 23 insertions(+), 9 deletions(-)

diffs (85 lines):

diff -r 8dd0a456ae24 -r a33135af2961 sys/kern/kern_condvar.c
--- a/sys/kern/kern_condvar.c   Wed Nov 20 19:37:51 2019 +0000
+++ b/sys/kern/kern_condvar.c   Wed Nov 20 21:49:00 2019 +0000
@@ -1,7 +1,7 @@
-/*     $NetBSD: kern_condvar.c,v 1.41 2018/01/30 07:52:22 ozaki-r Exp $        */
+/*     $NetBSD: kern_condvar.c,v 1.42 2019/11/20 21:49:00 ad Exp $     */
 
 /*-
- * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.41 2018/01/30 07:52:22 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.42 2019/11/20 21:49:00 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -210,10 +210,10 @@
  *     Remove an LWP from the condition variable and sleep queue.  This
  *     is called when the LWP has not been awoken normally but instead
  *     interrupted: for example, when a signal is received.  Must be
- *     called with the LWP locked, and must return it unlocked.
+ *     called with the LWP locked.  Will unlock if "unlock" is true.
  */
 static void
-cv_unsleep(lwp_t *l, bool cleanup)
+cv_unsleep(lwp_t *l, bool unlock)
 {
        kcondvar_t *cv __diagused;
 
@@ -224,7 +224,7 @@
        KASSERT(cv_is_valid(cv));
        KASSERT(cv_has_waiters(cv));
 
-       sleepq_unsleep(l, cleanup);
+       sleepq_unsleep(l, unlock);
 }
 
 /*
@@ -490,7 +490,14 @@
                cv_wakeup_one(cv);
 }
 
-static inline void
+/*
+ * cv_wakeup_one:
+ *
+ *     Slow path for cv_signal().  Deliberately marked __noinline to
+ *     prevent the compiler pulling it in to cv_signal(), which adds
+ *     extra prologue and epilogue code.
+ */
+static __noinline void
 cv_wakeup_one(kcondvar_t *cv)
 {
        sleepq_t *sq;
@@ -502,7 +509,7 @@
        mp = sleepq_hashlock(cv);
        sq = CV_SLEEPQ(cv);
        l = TAILQ_FIRST(sq);
-       if (l == NULL) {
+       if (__predict_false(l == NULL)) {
                mutex_spin_exit(mp);
                return;
        }
@@ -533,7 +540,14 @@
                cv_wakeup_all(cv);
 }
 
-static inline void
+/*
+ * cv_wakeup_all:
+ *
+ *     Slow path for cv_broadcast().  Deliberately marked __noinline to
+ *     prevent the compiler pulling it in to cv_broadcast(), which adds
+ *     extra prologue and epilogue code.
+ */
+static __noinline void
 cv_wakeup_all(kcondvar_t *cv)
 {
        sleepq_t *sq;



Home | Main Index | Thread Index | Old Index