Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Add a comment.



details:   https://anonhg.NetBSD.org/src/rev/f63220141fad
branches:  trunk
changeset: 1005535:f63220141fad
user:      ad <ad%NetBSD.org@localhost>
date:      Wed Dec 11 20:50:32 2019 +0000

description:
Add a comment.

diffstat:

 sys/kern/vfs_bio.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (35 lines):

diff -r 3999c6ecde35 -r f63220141fad sys/kern/vfs_bio.c
--- a/sys/kern/vfs_bio.c        Wed Dec 11 20:46:06 2019 +0000
+++ b/sys/kern/vfs_bio.c        Wed Dec 11 20:50:32 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_bio.c,v 1.282 2019/12/08 20:35:23 ad Exp $ */
+/*     $NetBSD: vfs_bio.c,v 1.283 2019/12/11 20:50:32 ad Exp $ */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.282 2019/12/08 20:35:23 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.283 2019/12/11 20:50:32 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -1145,6 +1145,16 @@
        /* Unlock the buffer. */
        CLR(bp->b_cflags, BC_AGE|BC_BUSY|BC_NOCACHE);
        CLR(bp->b_flags, B_ASYNC);
+
+       /*
+        * Wake only the highest priority waiter on the lock, in order to
+        * prevent a thundering herd: many LWPs simultaneously awakening and
+        * competing for the buffer's lock.  Testing in 2019 revealed this
+        * to reduce contention on bufcache_lock tenfold during a kernel
+        * compile.  Elsewhere, when the buffer is changing identity, being
+        * disposed of, or moving from one list to another, we wake all lock
+        * requestors.
+        */
        cv_signal(&bp->b_busy);
 
        if (bp->b_bufsize <= 0)



Home | Main Index | Thread Index | Old Index