Module Name:    src
Committed By:   ad
Date:           Sat Nov 23 17:32:10 UTC 2019

Modified Files:
        src/sys/dev: lockstat.c

Log Message:
- Increase the default number of buffers, and scale it by ncpu.
- Stop tracing when the device is closed.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/dev/lockstat.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/lockstat.c
diff -u src/sys/dev/lockstat.c:1.25 src/sys/dev/lockstat.c:1.26
--- src/sys/dev/lockstat.c:1.25	Thu Jun  1 02:45:09 2017
+++ src/sys/dev/lockstat.c	Sat Nov 23 17:32:10 2019
@@ -1,7 +1,7 @@
-/*	$NetBSD: lockstat.c,v 1.25 2017/06/01 02:45:09 chs Exp $	*/
+/*	$NetBSD: lockstat.c,v 1.26 2019/11/23 17:32:10 ad Exp $	*/
 
 /*-
- * Copyright (c) 2006, 2007 The NetBSD Foundation, Inc.
+ * Copyright (c) 2006, 2007, 2019 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
@@ -37,10 +37,11 @@
  * Only one thread can hold the device at a time, providing a global lock.
  *
  * XXX Timings for contention on sleep locks are currently incorrect.
+ * XXX Convert this to use timecounters!
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.25 2017/06/01 02:45:09 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lockstat.c,v 1.26 2019/11/23 17:32:10 ad Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -71,7 +72,7 @@ __KERNEL_RCSID(0, "$NetBSD: lockstat.c,v
 #endif
 
 #define	LOCKSTAT_MINBUFS	1000
-#define	LOCKSTAT_DEFBUFS	10000
+#define	LOCKSTAT_DEFBUFS	20000
 #define	LOCKSTAT_MAXBUFS	1000000
 
 #define	LOCKSTAT_HASH_SIZE	128
@@ -453,6 +454,10 @@ lockstat_close(dev_t dev, int flag, int 
 {
 
 	lockstat_lwp = NULL;
+	if (lockstat_dev_enabled) {
+		lockstat_stop(NULL);
+		lockstat_free();
+	}
 	__cpu_simple_unlock(&lockstat_lock);
 	return 0;
 }
@@ -490,9 +495,10 @@ lockstat_ioctl(dev_t dev, u_long cmd, vo
 		/*
 		 * Sanitize the arguments passed in and set up filtering.
 		 */
-		if (le->le_nbufs == 0)
-			le->le_nbufs = LOCKSTAT_DEFBUFS;
-		else if (le->le_nbufs > LOCKSTAT_MAXBUFS ||
+		if (le->le_nbufs == 0) {
+			le->le_nbufs = MIN(LOCKSTAT_DEFBUFS * ncpu,
+			    LOCKSTAT_MAXBUFS);
+		} else if (le->le_nbufs > LOCKSTAT_MAXBUFS ||
 		    le->le_nbufs < LOCKSTAT_MINBUFS) {
 			error = EINVAL;
 			break;

Reply via email to