CVS commit: src/sys/arch/powerpc/include/ibm4xx

2021-04-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr  2 03:20:54 UTC 2021

Modified Files:
src/sys/arch/powerpc/include/ibm4xx: dcr4xx.h

Log Message:
Add bit-field definitions for DCR_SDRAM0_B[0-3]CR registers.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h

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

Modified files:

Index: src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h
diff -u src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h:1.3 src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h:1.4
--- src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h:1.3	Thu Nov 21 13:33:15 2013
+++ src/sys/arch/powerpc/include/ibm4xx/dcr4xx.h	Fri Apr  2 03:20:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dcr4xx.h,v 1.3 2013/11/21 13:33:15 kiyohara Exp $	*/
+/*	$NetBSD: dcr4xx.h,v 1.4 2021/04/02 03:20:53 rin Exp $	*/
 
 /*
  * Copyright 2002 Wasabi Systems, Inc.
@@ -303,6 +303,8 @@
 #define DCR_SDRAM0_B1CR		0x44
 #define DCR_SDRAM0_B2CR		0x48
 #define DCR_SDRAM0_B3CR		0x4c
+#define   SDRAM0_BnCR_EN	  0x0001
+#define   SDRAM0_BnCR_SZ(n)	  (1 << n) >> 17) & 7) + 22))
 #define DCR_SDRAM0_TR		0x80
 #define DCR_SDRAM0_ECCCFG	0x94
 #define DCR_SDRAM0_ECCESR	0x98



CVS commit: src/sys/nfs

2021-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr  2 03:07:54 UTC 2021

Modified Files:
src/sys/nfs: nfs_vfsops.c

Log Message:
Set f_namemax during mount time like all the other filesystems so that
it does gets the right data in copy_statvfs_info(). Otherwise f_namemax
can end up being 0. To reproduce: unmount the remote filesystem, remount
it, and kill -HUP mountd to refresh exports.


To generate a diff of this commit:
cvs rdiff -u -r1.241 -r1.242 src/sys/nfs/nfs_vfsops.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/nfs/nfs_vfsops.c
diff -u src/sys/nfs/nfs_vfsops.c:1.241 src/sys/nfs/nfs_vfsops.c:1.242
--- src/sys/nfs/nfs_vfsops.c:1.241	Mon Apr 13 15:23:20 2020
+++ src/sys/nfs/nfs_vfsops.c	Thu Apr  1 23:07:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_vfsops.c,v 1.241 2020/04/13 19:23:20 ad Exp $	*/
+/*	$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.241 2020/04/13 19:23:20 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_vfsops.c,v 1.242 2021/04/02 03:07:54 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_nfs.h"
@@ -223,7 +223,6 @@ nfs_statvfs(struct mount *mp, struct sta
 		sbp->f_ffree = tquad;
 		sbp->f_favail = tquad;
 		sbp->f_fresvd = 0;
-		sbp->f_namemax = NFS_MAXNAMLEN;
 	} else {
 		sbp->f_bsize = NFS_FABLKSIZE;
 		sbp->f_frsize = fxdr_unsigned(int32_t, sfp->sf_bsize);
@@ -235,7 +234,6 @@ nfs_statvfs(struct mount *mp, struct sta
 		sbp->f_ffree = 0;
 		sbp->f_favail = 0;
 		sbp->f_fresvd = 0;
-		sbp->f_namemax = NFS_MAXNAMLEN;
 	}
 	copy_statvfs_info(sbp, mp);
 	nfsm_reqdone;
@@ -706,19 +704,20 @@ mountnfs(struct nfs_args *argp, struct m
 		nmp = VFSTONFS(mp);
 		/* update paths, file handles, etc, here	XXX */
 		m_freem(nam);
-		return (0);
-	} else {
-		nmp = kmem_zalloc(sizeof(*nmp), KM_SLEEP);
-		mp->mnt_data = nmp;
-		TAILQ_INIT(>nm_uidlruhead);
-		TAILQ_INIT(>nm_bufq);
-		rw_init(>nm_writeverflock);
-		mutex_init(>nm_lock, MUTEX_DEFAULT, IPL_NONE);
-		cv_init(>nm_rcvcv, "nfsrcv");
-		cv_init(>nm_sndcv, "nfssnd");
-		cv_init(>nm_aiocv, "nfsaio");
-		cv_init(>nm_disconcv, "nfsdis");
+		return 0;
 	}
+	nmp = kmem_zalloc(sizeof(*nmp), KM_SLEEP);
+	TAILQ_INIT(>nm_uidlruhead);
+	TAILQ_INIT(>nm_bufq);
+	rw_init(>nm_writeverflock);
+	mutex_init(>nm_lock, MUTEX_DEFAULT, IPL_NONE);
+	cv_init(>nm_rcvcv, "nfsrcv");
+	cv_init(>nm_sndcv, "nfssnd");
+	cv_init(>nm_aiocv, "nfsaio");
+	cv_init(>nm_disconcv, "nfsdis");
+
+	mp->mnt_data = nmp;
+	mp->mnt_stat.f_namemax = NFS_MAXNAMLEN;
 	vfs_getnewfsid(mp);
 	nmp->nm_mountp = mp;
 



CVS commit: src/sys/dev/pci

2021-04-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr  2 01:08:03 UTC 2021

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
regen


To generate a diff of this commit:
cvs rdiff -u -r1.1410 -r1.1411 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1409 -r1.1410 src/sys/dev/pci/pcidevs_data.h

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/pci/pcidevs.h
diff -u src/sys/dev/pci/pcidevs.h:1.1410 src/sys/dev/pci/pcidevs.h:1.1411
--- src/sys/dev/pci/pcidevs.h:1.1410	Sat Jan 30 21:24:46 2021
+++ src/sys/dev/pci/pcidevs.h	Fri Apr  2 01:08:02 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs.h,v 1.1410 2021/01/30 21:24:46 jmcneill Exp $	*/
+/*	$NetBSD: pcidevs.h,v 1.1411 2021/04/02 01:08:02 rin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1424 2021/01/30 21:24:30 jmcneill Exp
+ *	NetBSD: pcidevs,v 1.1425 2021/04/02 01:07:16 rin Exp
  */
 
 /*
@@ -7260,7 +7260,7 @@
 #define	PCI_PRODUCT_PROLAN_NE2KETHER	0x1980		/* Ethernet */
 
 /* Promise products */
-#define	PCI_PRODUCT_PROMISE_PDC20265	0x0d30		/* PDC20265 Ultra/66 IDE Controller */
+#define	PCI_PRODUCT_PROMISE_PDC20265	0x0d30		/* PDC20265 Ultra/100 IDE Controller */
 #define	PCI_PRODUCT_PROMISE_PDC20263	0x0d38		/* PDC20263 Ultra/66 IDE Controller */
 #define	PCI_PRODUCT_PROMISE_PDC20275	0x1275		/* PDC20275 Ultra/133 IDE Controller */
 #define	PCI_PRODUCT_PROMISE_PDC20318	0x3318		/* PDC20318 Serial ATA Controller */

Index: src/sys/dev/pci/pcidevs_data.h
diff -u src/sys/dev/pci/pcidevs_data.h:1.1409 src/sys/dev/pci/pcidevs_data.h:1.1410
--- src/sys/dev/pci/pcidevs_data.h:1.1409	Sat Jan 30 21:24:46 2021
+++ src/sys/dev/pci/pcidevs_data.h	Fri Apr  2 01:08:02 2021
@@ -1,10 +1,10 @@
-/*	$NetBSD: pcidevs_data.h,v 1.1409 2021/01/30 21:24:46 jmcneill Exp $	*/
+/*	$NetBSD: pcidevs_data.h,v 1.1410 2021/04/02 01:08:02 rin Exp $	*/
 
 /*
  * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT EDIT.
  *
  * generated from:
- *	NetBSD: pcidevs,v 1.1424 2021/01/30 21:24:30 jmcneill Exp
+ *	NetBSD: pcidevs,v 1.1425 2021/04/02 01:07:16 rin Exp
  */
 
 /*
@@ -12906,75 +12906,75 @@ static const uint16_t pci_products[] = {
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20265, 
 	31910, 31919, 6593, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20263, 
-	31928, 31919, 6593, 6422, 0,
+	31929, 31938, 6593, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20275, 
-	31937, 31946, 6593, 6422, 0,
+	31947, 31956, 6593, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20318, 
-	31956, 12059, 6413, 6422, 0,
+	31966, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20319, 
-	31965, 12059, 6413, 6422, 0,
+	31975, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20371, 
-	31974, 12059, 6413, 6422, 0,
+	31984, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20379, 
-	31983, 12059, 6413, 6422, 0,
+	31993, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20378, 
-	31992, 12059, 6413, 6422, 0,
+	32002, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20375, 
-	32001, 12059, 6413, 6422, 0,
+	32011, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20376, 
-	32010, 12059, 6413, 6422, 0,
+	32020, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20377, 
-	32019, 12059, 6413, 6422, 0,
+	32029, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40719, 
-	32028, 12059, 6413, 6422, 0,
+	32038, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40519, 
-	32037, 12059, 6413, 6422, 0,
+	32047, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20771, 
-	32046, 12059, 6413, 6422, 0,
+	32056, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20571, 
-	32055, 12059, 6413, 6422, 0,
+	32065, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20579, 
-	32064, 12059, 6413, 6422, 0,
+	32074, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40779, 
-	32073, 12059, 6413, 6422, 0,
+	32083, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40718, 
-	32082, 12059, 6413, 6422, 0,
+	32092, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC40518, 
-	32091, 12059, 6413, 6422, 0,
+	32101, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20775, 
-	32100, 12059, 6413, 6422, 0,
+	32110, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20575, 
-	32109, 12059, 6413, 6422, 0,
+	32119, 12059, 6413, 6422, 0,
 	PCI_VENDOR_PROMISE, PCI_PRODUCT_PROMISE_PDC20267, 
-	32118, 32127, 6593, 

CVS commit: src/sys/dev/pci

2021-04-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr  2 01:07:16 UTC 2021

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
PDC20265 is Ultra/100, not 66.


To generate a diff of this commit:
cvs rdiff -u -r1.1424 -r1.1425 src/sys/dev/pci/pcidevs

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/pci/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1424 src/sys/dev/pci/pcidevs:1.1425
--- src/sys/dev/pci/pcidevs:1.1424	Sat Jan 30 21:24:30 2021
+++ src/sys/dev/pci/pcidevs	Fri Apr  2 01:07:16 2021
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1424 2021/01/30 21:24:30 jmcneill Exp $
+$NetBSD: pcidevs,v 1.1425 2021/04/02 01:07:16 rin Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -7253,7 +7253,7 @@ product POWERHOUSE POWERPRO	0x6073	Power
 product PROLAN NE2KETHER 0x1980 Ethernet
 
 /* Promise products */
-product PROMISE PDC20265	0x0d30	PDC20265 Ultra/66 IDE Controller
+product PROMISE PDC20265	0x0d30	PDC20265 Ultra/100 IDE Controller
 product PROMISE PDC20263	0x0d38	PDC20263 Ultra/66 IDE Controller
 product PROMISE PDC20275	0x1275	PDC20275 Ultra/133 IDE Controller
 product PROMISE PDC20318	0x3318	PDC20318 Serial ATA Controller



CVS commit: src/sys/arch/powerpc/oea

2021-04-01 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr  1 22:02:20 UTC 2021

Modified Files:
src/sys/arch/powerpc/oea: ofwoea_machdep.c

Log Message:
avoid mapping 0xf000 - my beige G3 DSIs on it
with this my the machine boots again
tested on a variety of G4 and G5 models with no problems


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/powerpc/oea/ofwoea_machdep.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/arch/powerpc/oea/ofwoea_machdep.c
diff -u src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.59 src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.60
--- src/sys/arch/powerpc/oea/ofwoea_machdep.c:1.59	Fri Mar  5 18:10:06 2021
+++ src/sys/arch/powerpc/oea/ofwoea_machdep.c	Thu Apr  1 22:02:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: ofwoea_machdep.c,v 1.59 2021/03/05 18:10:06 thorpej Exp $ */
+/* $NetBSD: ofwoea_machdep.c,v 1.60 2021/04/01 22:02:20 macallan Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.59 2021/03/05 18:10:06 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofwoea_machdep.c,v 1.60 2021/04/01 22:02:20 macallan Exp $");
 
 #include "ksyms.h"
 #include "wsdisplay.h"
@@ -378,6 +378,14 @@ restore_ofmap(void)
 		if (va < 0xf000)	/* XXX */
 			continue;
 
+		/*
+		 * XXX
+		 * my beige G3 throws a DSI trap if we try to map the last page
+		 * of the firmware ROM
+		 */
+		if (pa == 0xffc0 && size == 0x40)
+			size = 0x3ff000;
+
 		while (size > 0) {
 			pmap_enter(_pmap, va, pa, VM_PROT_ALL,
 			VM_PROT_ALL|PMAP_WIRED);



CVS commit: src/sys/fs/puffs

2021-04-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr  1 19:00:33 UTC 2021

Modified Files:
src/sys/fs/puffs: puffs_vfsops.c

Log Message:
Put a copy of our existing data first in the non-error case (noticed by RVP).


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/fs/puffs/puffs_vfsops.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/fs/puffs/puffs_vfsops.c
diff -u src/sys/fs/puffs/puffs_vfsops.c:1.125 src/sys/fs/puffs/puffs_vfsops.c:1.126
--- src/sys/fs/puffs/puffs_vfsops.c:1.125	Thu Feb 27 17:12:53 2020
+++ src/sys/fs/puffs/puffs_vfsops.c	Thu Apr  1 15:00:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: puffs_vfsops.c,v 1.125 2020/02/27 22:12:53 ad Exp $	*/
+/*	$NetBSD: puffs_vfsops.c,v 1.126 2021/04/01 19:00:33 christos Exp $	*/
 
 /*
  * Copyright (c) 2005, 2006  Antti Kantee.  All Rights Reserved.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.125 2020/02/27 22:12:53 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.126 2021/04/01 19:00:33 christos Exp $");
 
 #include 
 #include 
@@ -501,6 +501,9 @@ puffs_vfsop_statvfs(struct mount *mp, st
 	 *
 	 * XXX: cache the copy in non-error case
 	 */
+	if (!error) {
+		puffs_statvfs_to_statvfs(_msg->pvfsr_sb, sbp);
+	}
 	copy_statvfs_info(sbp, mp);
 	if (!error) {
 		statvfs_to_puffs_statvfs(sbp, _msg->pvfsr_sb);



CVS commit: src/usr.bin/xlint/lint1

2021-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Apr  1 15:06:50 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: tree.c

Log Message:
lint: remove wrong assumption from comment

The size in bits of a struct or union is not measured at all at this
point since portable_size_in_bits only takes the broad type
classification (tspec_t), not the precise type information (type_t).

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.254 -r1.255 src/usr.bin/xlint/lint1/tree.c

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

Modified files:

Index: src/usr.bin/xlint/lint1/tree.c
diff -u src/usr.bin/xlint/lint1/tree.c:1.254 src/usr.bin/xlint/lint1/tree.c:1.255
--- src/usr.bin/xlint/lint1/tree.c:1.254	Tue Mar 30 15:18:19 2021
+++ src/usr.bin/xlint/lint1/tree.c	Thu Apr  1 15:06:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $	*/
+/*	$NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -37,7 +37,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: tree.c,v 1.254 2021/03/30 15:18:19 rillig Exp $");
+__RCSID("$NetBSD: tree.c,v 1.255 2021/04/01 15:06:49 rillig Exp $");
 #endif
 
 #include 
@@ -2233,10 +2233,6 @@ should_warn_about_pointer_cast(const typ
 	if (nst == CHAR || nst == UCHAR)
 		return false;	/* for the sake of traditional C code */
 
-	/*
-	 * XXX: Why should it be ok to cast between arbitrary structs that
-	 * just happen to be of the same size?
-	 */
 	return portable_size_in_bits(nst) != portable_size_in_bits(ost);
 }
 



CVS commit: src/usr.bin/xlint/lint1

2021-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Apr  1 14:59:21 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: ops.def

Log Message:
lint: replace empty macro arguments with non-empty arguments

Empty arguments are a new feature of C99.  Since lint is one of the
build tools, it is supposed to only use C90 features.  C99 6.10.3 "Macro
replacement" explicitly allows empty macro arguments while C90 3.8.3
"Macro replacement" last sentence defines an empty macro argument as
undefined behavior.

This change makes the '1's stick out less from the table.  I tried to
use '.' instead of '-' as well, but that made it too hard to see the
commas.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint1/ops.def

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

Modified files:

Index: src/usr.bin/xlint/lint1/ops.def
diff -u src/usr.bin/xlint/lint1/ops.def:1.19 src/usr.bin/xlint/lint1/ops.def:1.20
--- src/usr.bin/xlint/lint1/ops.def:1.19	Sat Mar 20 20:39:35 2021
+++ src/usr.bin/xlint/lint1/ops.def	Thu Apr  1 14:59:21 2021
@@ -1,86 +1,86 @@
-/*	$NetBSD: ops.def,v 1.19 2021/03/20 20:39:35 rillig Exp $ */
+/*	$NetBSD: ops.def,v 1.20 2021/04/01 14:59:21 rillig Exp $ */
 
 begin_ops()
 
 /* See mod_t in op.h for the definition of the table columns. */
 
 /*	name	repr		b l b B i c a s f v t b s l r p c e e =	*/
-op(	NOOP,	"no-op",	 , , , , , , , , , , , , , , , , , , , )
-op(	ARROW,	"->",		1, ,1, , , , , , ,1, , , , , , , , , , )
-op(	POINT,	".",		1, ,1, , , , , , , , , , , , , , , , , )
-op(	NOT,	"!",		 ,1,1,1, , , ,1,1, ,1, , , , , , , ,1, )
-op(	COMPL,	"~",		 , , , , ,1, , ,1,1, , , , , , , , ,1,1)
-op(	INC,	"++",		 , , , , , , , , , , , , , , , , , , , )
-op(	DEC,	"--",		 , , , , , , , , , , , , , , , , , , , )
-op(	INCBEF,	"++x",		 , , , , , , ,1, , , , ,1, , , , , ,1, )
-op(	DECBEF,	"--x",		 , , , , , , ,1, , , , ,1, , , , , ,1, )
-op(	INCAFT,	"x++",		 , , , , , , ,1, , , , ,1, , , , , ,1, )
-op(	DECAFT,	"x--",		 , , , , , , ,1, , , , ,1, , , , , ,1, )
-op(	UPLUS,	"+",		 , , , , , ,1, ,1,1, , , , , , , , ,1,1)
-op(	UMINUS,	"-",		 , , , , , ,1, ,1,1, , , ,1, , , , ,1,1)
-op(	INDIR,	"*",		 , , , , , , , , ,1, , , , , , , , , , )
-op(	ADDR,	"&",		 , ,1, , , , , , , , , , , , , , , , , )
+op(	NOOP,	"no-op",	-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
+op(	ARROW,	"->",		1,-,1,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)
+op(	POINT,	".",		1,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
+op(	NOT,	"!",		-,1,1,1,-,-,-,1,1,-,1,-,-,-,-,-,-,-,1,-)
+op(	COMPL,	"~",		-,-,-,-,-,1,-,-,1,1,-,-,-,-,-,-,-,-,1,1)
+op(	INC,	"++",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
+op(	DEC,	"--",		-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
+op(	INCBEF,	"++x",		-,-,-,-,-,-,-,1,-,-,-,-,1,-,-,-,-,-,1,-)
+op(	DECBEF,	"--x",		-,-,-,-,-,-,-,1,-,-,-,-,1,-,-,-,-,-,1,-)
+op(	INCAFT,	"x++",		-,-,-,-,-,-,-,1,-,-,-,-,1,-,-,-,-,-,1,-)
+op(	DECAFT,	"x--",		-,-,-,-,-,-,-,1,-,-,-,-,1,-,-,-,-,-,1,-)
+op(	UPLUS,	"+",		-,-,-,-,-,-,1,-,1,1,-,-,-,-,-,-,-,-,1,1)
+op(	UMINUS,	"-",		-,-,-,-,-,-,1,-,1,1,-,-,-,1,-,-,-,-,1,1)
+op(	INDIR,	"*",		-,-,-,-,-,-,-,-,-,1,-,-,-,-,-,-,-,-,-,-)
+op(	ADDR,	"&",		-,-,1,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-,-)
 /* the operator 'arr[ind]' is translated to '*(arr + ind)' during parsing. */
 
 /*	name	repr		b l b B i c a s f v t b s l r p c e e = */
-op(	MULT,	"*",		1, , , , , ,1, ,1,1, ,1, , ,1, , , ,1,1)
-op(	DIV,	"/",		1, , , , , ,1, ,1,1, ,1, ,1,1, , , ,1,1)
-op(	MOD,	"%",		1, , , ,1, , , ,1,1, ,1, ,1,1, , , ,1,1)
-op(	PLUS,	"+",		1, , , , , , ,1,1,1, ,1, , , , , , ,1, )
-op(	MINUS,	"-",		1, , , , , , ,1,1,1, ,1, , , , , , ,1, )
-op(	SHL,	"<<",		1, , , ,1, , , ,1,1, , , , , ,1, , ,1,1)
-op(	SHR,	">>",		1, , , ,1, , , ,1,1, , , ,1, ,1, , ,1,1)
-
-/*	name	repr		b l b B i c a s f v t b s l r p c e e = */
-op(	LT,	"<",		1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
-op(	LE,	"<=",		1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
-op(	GT,	">",		1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
-op(	GE,	">=",		1,1, , , , , ,1,1,1, ,1, ,1,1, ,1,1, ,1)
-op(	EQ,	"==",		1,1,1, , , , ,1,1,1, ,1, , , , ,1,1, ,1)
-op(	NE,	"!=",		1,1,1, , , , ,1,1,1, ,1, , , , ,1,1, ,1)
-
-/*	name	repr		b l b B i c a s f v t b s l r p c e e = */
-op(	BITAND,	"&",		1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
-op(	BITXOR,	"^",		1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
-op(	BITOR,	"|",		1, ,1, ,1, , , ,1,1, ,1, , , ,1, , ,1, )
-op(	LOGAND,	"&&",		1,1,1,1, , , ,1,1, ,1, , , , , , , ,1, )
-op(	LOGOR,	"||",		1,1,1,1, , , ,1,1, ,1, , , , ,1, , ,1, )
-op(	QUEST,	"?",		1, , , , , , , ,1, ,1, , , , , , , , , )
-op(	COLON,	":",		1, ,1, , , , , , ,1, ,1, , , , , ,1, , )
-
-/*	name	repr		b l b B i c a s f v t b s l r p c e e = */
-op(	ASSIGN,	"=",		1, ,1, , , , , , , , , ,1, , , , ,1, , )
-op(	MULASS,	"*=",		1, , , , , ,1, , , , , ,1, , , , , ,1, )
-op(	DIVASS,	"/=",		1, , , , , ,1, , , , , ,1, ,1, , , ,1, )
-op(	MODASS,	"%=",		1, , , ,1, , , , , , , ,1, ,1, , , ,1, )
-op(	ADDASS,	"+=",		1, , , 

CVS commit: src

2021-04-01 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Thu Apr  1 14:20:30 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: d_c99_init.c d_c99_init.exp
src/usr.bin/xlint/lint1: init.c

Log Message:
lint: do not error out of a struct is initialized without braces

This allows to process lib/libc/gen/sysctl.c 1.38 from 2021-03-30, as
well as its precedessor 1.37, which had a workaround just for lint.

While unusual, C99 allows these.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/tests/usr.bin/xlint/lint1/d_c99_init.c
cvs rdiff -u -r1.23 -r1.24 src/tests/usr.bin/xlint/lint1/d_c99_init.exp
cvs rdiff -u -r1.184 -r1.185 src/usr.bin/xlint/lint1/init.c

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/d_c99_init.c
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.29 src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.30
--- src/tests/usr.bin/xlint/lint1/d_c99_init.c:1.29	Tue Mar 30 19:45:04 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.c	Thu Apr  1 14:20:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: d_c99_init.c,v 1.29 2021/03/30 19:45:04 rillig Exp $	*/
+/*	$NetBSD: d_c99_init.c,v 1.30 2021/04/01 14:20:30 rillig Exp $	*/
 # 3 "d_c99_init.c"
 
 /*
@@ -275,8 +275,8 @@ int c99_6_7_8_p27_example4[4][3] = {
 struct {
 	int a[3], b;
 } c99_6_7_8_p28_example5[] = {
-	{ 1 },
-	2,			/* XXX *//* expect: cannot initialize */
+	{ 1 },		/* just parsed, not checked in detail */
+	2,		/* just parsed, not checked in detail */
 };
 
 short c99_6_7_8_p29_example6a[4][3][2] = {

Index: src/tests/usr.bin/xlint/lint1/d_c99_init.exp
diff -u src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.23 src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.24
--- src/tests/usr.bin/xlint/lint1/d_c99_init.exp:1.23	Tue Mar 30 19:45:04 2021
+++ src/tests/usr.bin/xlint/lint1/d_c99_init.exp	Thu Apr  1 14:20:30 2021
@@ -9,7 +9,6 @@ d_c99_init.c(221): error: array subscrip
 d_c99_init.c(230): error: too many struct/union initializers [172]
 d_c99_init.c(236): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
 d_c99_init.c(240): warning: illegal combination of integer (char) and pointer (pointer to char) [183]
-d_c99_init.c(279): error: cannot initialize 'struct ' from 'int' [185]
 d_c99_init.c(321): error: duplicate case in switch: 0 [199]
 d_c99_init.c(330): error: type 'struct point' does not have member 'r' [101]
 d_c99_init.c(337): error: type 'struct point' does not have member 'r' [101]

Index: src/usr.bin/xlint/lint1/init.c
diff -u src/usr.bin/xlint/lint1/init.c:1.184 src/usr.bin/xlint/lint1/init.c:1.185
--- src/usr.bin/xlint/lint1/init.c:1.184	Tue Mar 30 20:23:30 2021
+++ src/usr.bin/xlint/lint1/init.c	Thu Apr  1 14:20:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: init.c,v 1.184 2021/03/30 20:23:30 rillig Exp $	*/
+/*	$NetBSD: init.c,v 1.185 2021/04/01 14:20:30 rillig Exp $	*/
 
 /*
  * Copyright (c) 1994, 1995 Jochen Pohl
@@ -38,7 +38,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: init.c,v 1.184 2021/03/30 20:23:30 rillig Exp $");
+__RCSID("$NetBSD: init.c,v 1.185 2021/04/01 14:20:30 rillig Exp $");
 #endif
 
 #include 
@@ -126,7 +126,7 @@ struct brace_level {
 	size_t		bl_array_next_subscript;
 	bool		bl_array_of_unknown_size: 1;
 	bool		bl_scalar_done: 1;	/* for scalars */
-	bool		bl_omitted_braces: 1;	/* skip further checks */
+	bool		bl_confused: 1;		/* skip further checks */
 	struct designation bl_designation;	/* .member[123].member */
 	struct brace_level *bl_enclosing;
 };
@@ -608,8 +608,7 @@ static const type_t *
 brace_level_sub_type_array(const struct brace_level *bl)
 {
 
-	if (!bl->bl_type->t_incomplete_array &&
-	!bl->bl_omitted_braces &&
+	if (!bl->bl_confused && !bl->bl_type->t_incomplete_array &&
 	bl->bl_array_next_subscript >= (size_t)bl->bl_type->t_dim) {
 		/* too many array initializers, expected %d */
 		error(173, bl->bl_type->t_dim);
@@ -939,7 +938,7 @@ initialization_expr(struct initializatio
 		return;
 
 	bl = in->in_brace_level;
-	if (bl != NULL && bl->bl_omitted_braces)
+	if (bl != NULL && bl->bl_confused)
 		return;
 
 	debug_enter();
@@ -967,12 +966,13 @@ initialization_expr(struct initializatio
 	 * Hack to accept initializations with omitted braces, see
 	 * c99_6_7_8_p28_example5 in test d_c99_init.c.  Since both GCC and
 	 * Clang already warn about this at level -Wall, there is no point
-	 * in letting lint check this again.
+	 * in repeating the same check in lint.  If needed, support for these
+	 * edge cases could be added, but that would increase the complexity.
 	 */
 	if (is_scalar(tn->tn_type->t_tspec) &&
-	tp->t_tspec == ARRAY &&
+	(tp->t_tspec == ARRAY || is_struct_or_union(tp->t_tspec)) &&
 	bl != NULL) {
-		bl->bl_omitted_braces = true;
+		bl->bl_confused = true;
 		goto done;
 	}
 



CVS commit: src/distrib/sets/lists/base

2021-04-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Thu Apr  1 10:35:24 UTC 2021

Modified Files:
src/distrib/sets/lists/base: mi shl.mi

Log Message:
Move the named filter- plugin to the shared list


To generate a diff of this commit:
cvs rdiff -u -r1.1275 -r1.1276 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.913 -r1.914 src/distrib/sets/lists/base/shl.mi

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

Modified files:

Index: src/distrib/sets/lists/base/mi
diff -u src/distrib/sets/lists/base/mi:1.1275 src/distrib/sets/lists/base/mi:1.1276
--- src/distrib/sets/lists/base/mi:1.1275	Wed Mar 31 04:38:30 2021
+++ src/distrib/sets/lists/base/mi	Thu Apr  1 10:35:24 2021
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.1275 2021/03/31 04:38:30 christos Exp $
+# $NetBSD: mi,v 1.1276 2021/04/01 10:35:24 martin Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -1602,7 +1602,6 @@
 ./usr/libexec/makekeybase-crypto-bin
 ./usr/libexec/makewhatis			base-man-bin		!makemandb
 ./usr/libexec/namedbase-bind-bin
-./usr/libexec/named/filter-.so		base-bind-bin
 ./usr/libexec/named-xfer			base-obsolete		obsolete
 ./usr/libexec/ntalkdbase-netutil-bin
 ./usr/libexec/pfspamdbase-obsolete		obsolete

Index: src/distrib/sets/lists/base/shl.mi
diff -u src/distrib/sets/lists/base/shl.mi:1.913 src/distrib/sets/lists/base/shl.mi:1.914
--- src/distrib/sets/lists/base/shl.mi:1.913	Mon Mar 15 20:17:04 2021
+++ src/distrib/sets/lists/base/shl.mi	Thu Apr  1 10:35:24 2021
@@ -1,4 +1,4 @@
-# $NetBSD: shl.mi,v 1.913 2021/03/15 20:17:04 christos Exp $
+# $NetBSD: shl.mi,v 1.914 2021/04/01 10:35:24 martin Exp $
 #
 # Note:	Don't delete entries from here - mark them as "obsolete" instead,
 #	unless otherwise stated below.
@@ -1002,3 +1002,4 @@
 ./usr/lib/security/pam_u2f.so.4			base-sys-shlib		compatfile,pam
 ./usr/lib/security/pam_unix.so.4		base-sys-shlib		compatfile,pam
 ./usr/libexec/ld.elf_sobase-sys-shlib		dynamicroot
+./usr/libexec/named/filter-.so		base-bind-bin		dynamicroot



CVS commit: src/sys/uvm

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:26:26 UTC 2021

Modified Files:
src/sys/uvm: uvm_bio.c

Log Message:
Add a sysctl hashstat collector for ubchash.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/uvm/uvm_bio.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/uvm/uvm_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.125 src/sys/uvm/uvm_bio.c:1.126
--- src/sys/uvm/uvm_bio.c:1.125	Sat Mar 13 15:29:55 2021
+++ src/sys/uvm/uvm_bio.c	Thu Apr  1 06:26:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.126 2021/04/01 06:26:26 simonb Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.126 2021/04/01 06:26:26 simonb Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 		/* for ilog2() */
 
@@ -61,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 
 static int	ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
 			  int, int, vm_prot_t, int);
 static struct ubc_map *ubc_find_mapping(struct uvm_object *, voff_t);
+static int	ubchash_stats(struct hashstat_sysctl *hs, bool fill);
 #ifdef UBC_USE_PMAP_DIRECT
 static int __noinline ubc_uiomove_direct(struct uvm_object *, struct uio *, vsize_t,
 			  int, int);
@@ -215,6 +217,8 @@ ubc_init(void)
 UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)) != 0) {
 		panic("ubc_init: failed to map ubc_object");
 	}
+
+	hashstat_register("ubchash", ubchash_stats);
 }
 
 void
@@ -1104,3 +1108,35 @@ ubc_purge(struct uvm_object *uobj)
 	}
 	rw_exit(ubc_object.uobj.vmobjlock);
 }
+
+static int
+ubchash_stats(struct hashstat_sysctl *hs, bool fill)
+{
+	struct ubc_map *umap;
+	uint64_t chain;
+
+	strlcpy(hs->hash_name, "ubchash", sizeof(hs->hash_name));
+	strlcpy(hs->hash_desc, "ubc object hash", sizeof(hs->hash_desc));
+	if (!fill)
+		return 0;
+
+	hs->hash_size = ubc_object.hashmask + 1;
+
+	for (size_t i = 0; i < hs->hash_size; i++) {
+		chain = 0;
+		rw_enter(ubc_object.uobj.vmobjlock, RW_READER);
+		LIST_FOREACH(umap, _object.hash[i], hash) {
+			chain++;
+		}
+		rw_exit(ubc_object.uobj.vmobjlock);
+		if (chain > 0) {
+			hs->hash_used++;
+			hs->hash_items += chain;
+			if (chain > hs->hash_maxchain)
+hs->hash_maxchain = chain;
+		}
+		preempt_point();
+	}
+
+	return 0;
+}



CVS commit: src/sys/kern

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:26:14 UTC 2021

Modified Files:
src/sys/kern: vfs_vnode.c

Log Message:
Add a sysctl hashstat collector for vcache.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 src/sys/kern/vfs_vnode.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/kern/vfs_vnode.c
diff -u src/sys/kern/vfs_vnode.c:1.126 src/sys/kern/vfs_vnode.c:1.127
--- src/sys/kern/vfs_vnode.c:1.126	Tue Aug  4 03:00:10 2020
+++ src/sys/kern/vfs_vnode.c	Thu Apr  1 06:26:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_vnode.c,v 1.126 2020/08/04 03:00:10 riastradh Exp $	*/
+/*	$NetBSD: vfs_vnode.c,v 1.127 2021/04/01 06:26:14 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1997-2011, 2019, 2020 The NetBSD Foundation, Inc.
@@ -148,7 +148,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.126 2020/08/04 03:00:10 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_vnode.c,v 1.127 2021/04/01 06:26:14 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_pax.h"
@@ -1194,6 +1194,38 @@ vcache_hash(const struct vcache_key *key
 	return hash;
 }
 
+static int
+vcache_stats(struct hashstat_sysctl *hs, bool fill)
+{
+	vnode_impl_t *vip;
+	uint64_t chain;
+
+	strlcpy(hs->hash_name, "vcache", sizeof(hs->hash_name));
+	strlcpy(hs->hash_desc, "vnode cache hash", sizeof(hs->hash_desc));
+	if (!fill)
+		return 0;
+
+	hs->hash_size = vcache_hashmask + 1;
+
+	for (size_t i = 0; i < hs->hash_size; i++) {
+		chain = 0;
+		mutex_enter(_lock);
+		SLIST_FOREACH(vip, _hashtab[i], vi_hash) {
+			chain++;
+		}
+		mutex_exit(_lock);
+		if (chain > 0) {
+			hs->hash_used++;
+			hs->hash_items += chain;
+			if (chain > hs->hash_maxchain)
+hs->hash_maxchain = chain;
+		}
+		preempt_point();
+	}
+
+	return 0;
+}
+
 static void
 vcache_init(void)
 {
@@ -1206,6 +1238,7 @@ vcache_init(void)
 	vcache_hashsize = desiredvnodes;
 	vcache_hashtab = hashinit(desiredvnodes, HASH_SLIST, true,
 	_hashmask);
+	hashstat_register("vcache", vcache_stats);
 }
 
 static void



CVS commit: src/sys/kern

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:26:00 UTC 2021

Modified Files:
src/sys/kern: vfs_bio.c

Log Message:
Add a sysctl hashstat collector for bufhash.


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/sys/kern/vfs_bio.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/kern/vfs_bio.c
diff -u src/sys/kern/vfs_bio.c:1.297 src/sys/kern/vfs_bio.c:1.298
--- src/sys/kern/vfs_bio.c:1.297	Fri Jul 31 04:07:30 2020
+++ src/sys/kern/vfs_bio.c	Thu Apr  1 06:25:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $	*/
+/*	$NetBSD: vfs_bio.c,v 1.298 2021/04/01 06:25:59 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -123,7 +123,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.297 2020/07/31 04:07:30 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_bio.c,v 1.298 2021/04/01 06:25:59 simonb Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_bufcache.h"
@@ -252,6 +252,8 @@ biohist_init(void)
 LIST_HEAD(bufhashhdr, buf) *bufhashtbl, invalhash;
 u_long	bufhash;
 
+static int bufhash_stats(struct hashstat_sysctl *, bool);
+
 static kcondvar_t needbuffer_cv;
 
 /*
@@ -536,6 +538,7 @@ bufinit(void)
 
 	sysctl_kern_buf_setup();
 	sysctl_vm_buf_setup();
+	hashstat_register("bufhash", bufhash_stats);
 }
 
 void
@@ -1953,6 +1956,40 @@ sysctl_vm_buf_setup(void)
 		   CTL_VM, CTL_CREATE, CTL_EOL);
 }
 
+static int
+bufhash_stats(struct hashstat_sysctl *hs, bool fill)
+{
+	buf_t *bp;
+	uint64_t chain;
+
+	strlcpy(hs->hash_name, "bufhash", sizeof(hs->hash_name));
+	strlcpy(hs->hash_desc, "buffer hash", sizeof(hs->hash_desc));
+	if (!fill)
+		return 0;
+
+	hs->hash_size = bufhash + 1;
+
+	for (size_t i = 0; i < hs->hash_size; i++) {
+		chain = 0;
+
+		mutex_enter(_lock);
+		LIST_FOREACH(bp, [i], b_hash) {
+			chain++;
+		}
+		mutex_exit(_lock);
+
+		if (chain > 0) {
+			hs->hash_used++;
+			hs->hash_items += chain;
+			if (chain > hs->hash_maxchain)
+hs->hash_maxchain = chain;
+		}
+		preempt_point();
+	}
+
+	return 0;
+}
+
 #ifdef DEBUG
 /*
  * Print out statistics on the current allocation of the buffer pool.



CVS commit: src/sys/kern

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:25:46 UTC 2021

Modified Files:
src/sys/kern: kern_uidinfo.c

Log Message:
Add a sysctl hashstat collector for uihash.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/kern_uidinfo.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/kern/kern_uidinfo.c
diff -u src/sys/kern/kern_uidinfo.c:1.11 src/sys/kern/kern_uidinfo.c:1.12
--- src/sys/kern/kern_uidinfo.c:1.11	Fri Mar  1 03:03:19 2019
+++ src/sys/kern/kern_uidinfo.c	Thu Apr  1 06:25:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_uidinfo.c,v 1.11 2019/03/01 03:03:19 christos Exp $	*/
+/*	$NetBSD: kern_uidinfo.c,v 1.12 2021/04/01 06:25:45 simonb Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_uidinfo.c,v 1.11 2019/03/01 03:03:19 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_uidinfo.c,v 1.12 2021/04/01 06:25:45 simonb Exp $");
 
 #include 
 #include 
@@ -132,6 +132,37 @@ sysctl_kern_uidinfo_setup(void)
 		   CTL_CREATE, CTL_EOL);
 }
 
+static int
+uid_stats(struct hashstat_sysctl *hs, bool fill)
+{
+	struct uidinfo *uip;
+	uint64_t chain;
+
+	strlcpy(hs->hash_name, "uihash", sizeof(hs->hash_name));
+	strlcpy(hs->hash_desc, "user info (uid->used proc) hash",
+	sizeof(hs->hash_desc));
+	if (!fill)
+		return 0;
+
+	hs->hash_size = uihash + 1;
+
+	for (size_t i = 0; i < hs->hash_size; i++) {
+		chain = 0;
+		SLIST_FOREACH(uip, [i], ui_hash) {
+			membar_datadep_consumer();
+			chain++;
+		}
+		if (chain > 0) {
+			hs->hash_used++;
+			hs->hash_items += chain;
+			if (chain > hs->hash_maxchain)
+hs->hash_maxchain = chain;
+		}
+	}
+
+	return 0;
+}
+
 void
 uid_init(void)
 {
@@ -151,6 +182,7 @@ uid_init(void)
 	 */
 	(void)uid_find(0);
 	sysctl_kern_uidinfo_setup();
+	hashstat_register("uihash", uid_stats);
 }
 
 struct uidinfo *



CVS commit: src/usr.bin/vmstat

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:23:15 UTC 2021

Modified Files:
src/usr.bin/vmstat: vmstat.c

Log Message:
Use kernel sysctl hashstat collection instead of kmem grovelling
directly.  Also GC a few old hash nlist entries that no longer exist.


To generate a diff of this commit:
cvs rdiff -u -r1.244 -r1.245 src/usr.bin/vmstat/vmstat.c

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

Modified files:

Index: src/usr.bin/vmstat/vmstat.c
diff -u src/usr.bin/vmstat/vmstat.c:1.244 src/usr.bin/vmstat/vmstat.c:1.245
--- src/usr.bin/vmstat/vmstat.c:1.244	Thu Apr  1 05:33:50 2021
+++ src/usr.bin/vmstat/vmstat.c	Thu Apr  1 06:23:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $ */
+/* $NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $ */
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2007, 2019, 2020
@@ -71,7 +71,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)vmstat.c	8.2 (Berkeley) 3/1/95";
 #else
-__RCSID("$NetBSD: vmstat.c,v 1.244 2021/04/01 05:33:50 simonb Exp $");
+__RCSID("$NetBSD: vmstat.c,v 1.245 2021/04/01 06:23:14 simonb Exp $");
 #endif
 #endif /* not lint */
 
@@ -113,6 +113,7 @@ __RCSID("$NetBSD: vmstat.c,v 1.244 2021/
 #include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
@@ -207,31 +208,23 @@ struct nlist intrnl[] =
  */
 struct nlist hashnl[] =
 {
-#define	X_NFSNODE	0
-	{ .n_name = "_nfsnodehash" },
-#define	X_NFSNODETBL	1
-	{ .n_name = "_nfsnodehashtbl" },
-#define	X_IHASH		2
-	{ .n_name = "_ihash" },
-#define	X_IHASHTBL	3
-	{ .n_name = "_ihashtbl" },
-#define	X_BUFHASH	4
+#define	X_BUFHASH	0
 	{ .n_name = "_bufhash" },
-#define	X_BUFHASHTBL	5
+#define	X_BUFHASHTBL	1
 	{ .n_name = "_bufhashtbl" },
-#define	X_UIHASH	6
+#define	X_UIHASH	2
 	{ .n_name = "_uihash" },
-#define	X_UIHASHTBL	7
+#define	X_UIHASHTBL	3
 	{ .n_name = "_uihashtbl" },
-#define	X_IFADDRHASH	8
+#define	X_IFADDRHASH	4
 	{ .n_name = "_in_ifaddrhash" },
-#define	X_IFADDRHASHTBL	9
+#define	X_IFADDRHASHTBL	5
 	{ .n_name = "_in_ifaddrhashtbl" },
-#define	X_VCACHEHASH	10
+#define	X_VCACHEHASH	6
 	{ .n_name = "_vcache_hashmask" },
-#define	X_VCACHETBL	11
+#define	X_VCACHETBL	7
 	{ .n_name = "_vcache_hashtab" },
-#define X_HASHNL_SIZE	12	/* must be last */
+#define X_HASHNL_SIZE	8	/* must be last */
 	{ .n_name = NULL },
 };
 
@@ -300,6 +293,7 @@ void	deref_kptr(const void *, void *, si
 void	drvstats(int *);
 void	doevcnt(int verbose, int type);
 void	dohashstat(int, int, const char *);
+void	dohashstat_sysctl(int, int, const char *);
 void	dointr(int verbose);
 void	dopool(int, int);
 void	dopoolcache(int);
@@ -1925,6 +1919,9 @@ dohashstat(int verbose, int todo, const 
 	u_long	hashsize, i;
 	int	used, items, chain, maxchain;
 
+	if (memf == NULL)
+		return dohashstat_sysctl(verbose, todo, hashname);
+
 	hashbuf = NULL;
 	hashbufsize = 0;
 
@@ -2057,6 +2054,75 @@ dohashstat(int verbose, int todo, const 
 	}
 }
 
+void
+dohashstat_sysctl(int verbose, int todo, const char *hashname)
+{
+	struct hashstat_sysctl hash, *data, *hs;
+	int mib[3];
+	int error;
+	size_t i, len, miblen;
+
+
+	miblen = __arraycount(mib);
+	error = sysctlnametomib("kern.hashstat", mib, );
+	if (error)
+		err(EXIT_FAILURE, "nametomib kern.hashstat failed");
+	assert(miblen < 3);
+
+	if (todo & HASHLIST) {
+		mib[miblen] = CTL_DESCRIBE;
+		miblen++;
+	};
+
+	if (hashname) {
+		mib[miblen] = CTL_QUERY;
+		miblen++;
+		memset(, 0, sizeof(hash));
+		strlcpy(hash.hash_name, hashname, sizeof(hash.hash_name));
+		len = sizeof(hash);
+		error = sysctl(mib, miblen, , , , len);
+		if (error == ENOENT) {
+			err(1, "hash '%s' not found", hashname);
+			return;
+		} else if (error) {
+			err(1, "sysctl kern.hashstat query failed");
+			return;
+		}
+
+		data = 
+		len = 1;
+	} else {
+		data = asysctl(mib, miblen, );
+		if (data == NULL)
+			err(1, "failed to read kern.hashstat");
+		len /= sizeof(*data);
+	}
+
+	if (todo & HASHLIST) {
+		printf("Supported hashes:\n");
+		for (i = 0, hs = data; i < len; i++, hs++) {
+			printf("\t%-16s%s\n", hs->hash_name, hs->hash_desc);
+		}
+	} else {
+		printf("%-16s %8s %8s %8s %8s %8s %8s\n"
+		"%-16s %8s %8s %8s %8s %8s %8s\n",
+		"", "total", "used", "util", "num", "average", "maximum",
+		"hash table", "buckets", "buckets", "%", "items", "chain",
+		"chain");
+		for (i = 0, hs = data; i < len; i++, hs++) {
+			printf("%-16s %8"PRId64" %8"PRId64" %8.2f %8"PRId64
+			" %8.2f %8"PRId64"\n",
+			hs->hash_name, hs->hash_size, hs->hash_used,
+			hs->hash_used * 100.0 / hs->hash_size, hs->hash_items,
+			hs->hash_used ? (double)hs->hash_items / hs->hash_used : 0.0,
+			hs->hash_maxchain);
+		}
+	}
+
+	if (!hashname && (data != NULL))
+		free(data);
+}
+
 /*
  * kreadc like kread but returns 1 if successful, 0 otherwise
  */
@@ -2254,7 +2320,7 @@ hist_traverse_sysctl(int todo, const cha
  			warnx("kernel history 

CVS commit: src/sys

2021-04-01 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Apr  1 06:22:10 UTC 2021

Modified Files:
src/sys/kern: subr_hash.c
src/sys/sys: sysctl.h

Log Message:
Add support for kernel hash statistics generation for vmstat -h/-H.  As
well as not needing any kmem grovelling, also much faster as it doesn't
need a kmem read for hash bucket and for each item in the hash bucket
chains.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/kern/subr_hash.c
cvs rdiff -u -r1.231 -r1.232 src/sys/sys/sysctl.h

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

Modified files:

Index: src/sys/kern/subr_hash.c
diff -u src/sys/kern/subr_hash.c:1.7 src/sys/kern/subr_hash.c:1.8
--- src/sys/kern/subr_hash.c:1.7	Wed Jul  6 05:20:48 2016
+++ src/sys/kern/subr_hash.c	Thu Apr  1 06:22:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_hash.c,v 1.7 2016/07/06 05:20:48 ozaki-r Exp $	*/
+/*	$NetBSD: subr_hash.c,v 1.8 2021/04/01 06:22:09 simonb Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -37,13 +37,17 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_hash.c,v 1.7 2016/07/06 05:20:48 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_hash.c,v 1.8 2021/04/01 06:22:09 simonb Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
+
+static int hashstat_sysctl(SYSCTLFN_PROTO);
 
 static size_t
 hash_list_size(enum hashtype htype)
@@ -138,3 +142,119 @@ hashdone(void *hashtbl, enum hashtype ht
 	const size_t esize = hash_list_size(htype);
 	kmem_free(hashtbl, esize * (hashmask + 1));
 }
+
+/*
+ * Support for hash statistics (vmstat -H / vmstat -h hashname).
+ */
+
+struct hashstat {
+	const char *hs_name;
+	hashstat_func_t hs_func;
+	TAILQ_ENTRY(hashstat) hs_next;
+};
+TAILQ_HEAD(, hashstat) hashstat_list =
+TAILQ_HEAD_INITIALIZER(hashstat_list);
+static krwlock_t hashstat_lock;
+
+void
+hashstat_register(const char *name, hashstat_func_t func)
+{
+	struct hashstat *hs;
+
+	hs = kmem_alloc(sizeof(*hs), KM_SLEEP);
+
+	hs->hs_name = name;
+	hs->hs_func = func;
+
+	rw_enter(_lock, RW_WRITER);
+	TAILQ_INSERT_TAIL(_list, hs, hs_next);
+	rw_exit(_lock);
+}
+
+/*
+ * sysctl support for returning kernel hash statistics.
+ *
+ * We (ab)use CTL_DESCRIBE and CTL_QUERY:
+ * When passed an OID of CTL_DESCRIBE, return a list and description
+ * of the available hashes.
+ * When passed an OID of CTL_QUERY, use the hash name passed in the
+ * "new" hash input as the name of a single hash to return stats on.
+ */
+static int
+hashstat_sysctl(SYSCTLFN_ARGS)
+{
+	struct hashstat_sysctl hs;
+	struct hashstat *hash;
+	char queryname[SYSCTL_NAMELEN];
+	size_t written;
+	bool fill, query;
+	int error;
+
+	if (oldp == NULL) {
+		*oldlenp = 0;
+		TAILQ_FOREACH(hash, _list, hs_next)
+			*oldlenp += sizeof(hs);
+		return 0;
+	}
+
+	error = 0;
+	written = 0;
+
+	if (namelen > 0 && name[0] == CTL_DESCRIBE)
+		fill = false;
+	else
+		fill = true;
+
+	if (namelen > 0 && name[0] == CTL_QUERY) {
+		const struct hashstat_sysctl *h = newp;
+
+		if (h == NULL) {
+			/* Can't QUERY one hash without supplying the hash name. */
+			return EINVAL;
+		}
+		query = true;
+		h = newp;
+		strlcpy(queryname, h->hash_name, sizeof(queryname));
+	} else {
+		query = false;
+	}
+
+	sysctl_unlock();
+	rw_enter(_lock, RW_READER);
+	TAILQ_FOREACH(hash, _list, hs_next) {
+		if (query &&
+		(strncmp(hash->hs_name, queryname, sizeof(hash->hs_name)) != 0)) {
+			continue;
+		}
+
+		memset(, 0, sizeof(hs));
+		error = hash->hs_func(, fill);
+		if (error)
+			break;
+
+		error = sysctl_copyout(l, , oldp, sizeof(hs));
+		if (error)
+			break;
+		written += sizeof(hs);
+		oldp = (char *)oldp + sizeof(hs);
+	}
+	rw_exit(_lock);
+	sysctl_relock();
+
+	*oldlenp = written;
+	return error;
+}
+
+
+SYSCTL_SETUP(sysctl_hash_setup, "sysctl hash stats setup")
+{
+
+	rw_init(_lock);	/* as good a place as any for this */
+
+	sysctl_createv(NULL, 0, NULL, NULL,
+		   CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+		   CTLTYPE_STRUCT,
+		   "hashstat", SYSCTL_DESCR("kernel hash statistics"),
+		   hashstat_sysctl, 0, NULL, 0,
+		   CTL_KERN, CTL_CREATE, CTL_EOL);
+}

Index: src/sys/sys/sysctl.h
diff -u src/sys/sys/sysctl.h:1.231 src/sys/sys/sysctl.h:1.232
--- src/sys/sys/sysctl.h:1.231	Sat Oct 17 09:06:15 2020
+++ src/sys/sys/sysctl.h	Thu Apr  1 06:22:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.h,v 1.231 2020/10/17 09:06:15 mlelstv Exp $	*/
+/*	$NetBSD: sysctl.h,v 1.232 2021/04/01 06:22:10 simonb Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -727,6 +727,28 @@ struct evcnt_sysctl {
 #define	KERN_EVCNT_COUNT_ANY		0
 #define	KERN_EVCNT_COUNT_NONZERO	1
 
+
+/*
+ * kern.hashstat returns an array of these structures, which are designed
+ * to be immune to 32/64 bit emulation issues.
+ *
+ * Hash users can register a filler function to fill the hashstat_sysctl
+ * which can then be exposed via vmstat(1).
+ *
+ * See comments for hashstat_sysctl() in