CVS commit: src/doc

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 06:30:15 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
doc: Add note about tprof improbements.


To generate a diff of this commit:
cvs rdiff -u -r1.2934 -r1.2935 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2934 src/doc/CHANGES:1.2935
--- src/doc/CHANGES:1.2934	Thu Dec  8 06:19:26 2022
+++ src/doc/CHANGES	Thu Dec  8 06:30:15 2022
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2934 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2935 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -749,3 +749,8 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		to be used on x86. [mrg 20221125]
 	ifconfig(8): Allow configuration of interfaces as
 		explicitly unnumbered. [knakahara 20221125]
+	tprof: Revamped tprof(4), and multiple event counters can be
+		referenced with tprof(8). Add some improvements to prof(8).
+		[ryo 20221201]
+	tprof: Add AMD family 19h (zen3 and zen4) support to tprof(4) and
+		tprof(8). [msaitoh 20221208]



CVS commit: src/doc

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 06:30:15 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
doc: Add note about tprof improbements.


To generate a diff of this commit:
cvs rdiff -u -r1.2934 -r1.2935 src/doc/CHANGES

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



CVS commit: src/doc

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 06:19:26 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.2933 -r1.2934 src/doc/CHANGES

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



CVS commit: src/doc

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Dec  8 06:19:26 UTC 2022

Modified Files:
src/doc: CHANGES

Log Message:
Fix typo.


To generate a diff of this commit:
cvs rdiff -u -r1.2933 -r1.2934 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2933 src/doc/CHANGES:1.2934
--- src/doc/CHANGES:1.2933	Mon Nov 28 10:23:56 2022
+++ src/doc/CHANGES	Thu Dec  8 06:19:26 2022
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2933 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2934 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -748,4 +748,4 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 		machine-independent code, allowing dmidecode -d /dev/smbios
 		to be used on x86. [mrg 20221125]
 	ifconfig(8): Allow configuration of interfaces as
-		explicitly unnumbred. [knakahara 20221125]
+		explicitly unnumbered. [knakahara 20221125]



CVS commit: src

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 05:29:27 UTC 2022

Modified Files:
src/sys/dev/tprof: tprof_x86_amd.c
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
Add AMD family 19h (zen3 and zen4) support to tprof.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/tprof/tprof_x86_amd.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/tprof/arch/tprof_x86.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/tprof/tprof_x86_amd.c
diff -u src/sys/dev/tprof/tprof_x86_amd.c:1.6 src/sys/dev/tprof/tprof_x86_amd.c:1.7
--- src/sys/dev/tprof/tprof_x86_amd.c:1.6	Thu Dec  1 00:32:52 2022
+++ src/sys/dev/tprof/tprof_x86_amd.c	Thu Dec  8 05:29:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_x86_amd.c,v 1.6 2022/12/01 00:32:52 ryo Exp $	*/
+/*	$NetBSD: tprof_x86_amd.c,v 1.7 2022/12/08 05:29:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tprof_x86_amd.c,v 1.6 2022/12/01 00:32:52 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tprof_x86_amd.c,v 1.7 2022/12/08 05:29:27 msaitoh Exp $");
 
 #include 
 #include 
@@ -245,6 +245,7 @@ tprof_amd_ident(void)
 	case 0x10:
 	case 0x15:
 	case 0x17:
+	case 0x19:
 		return TPROF_IDENT_AMD_GENERIC;
 	}
 

Index: src/usr.sbin/tprof/arch/tprof_x86.c
diff -u src/usr.sbin/tprof/arch/tprof_x86.c:1.14 src/usr.sbin/tprof/arch/tprof_x86.c:1.15
--- src/usr.sbin/tprof/arch/tprof_x86.c:1.14	Thu Dec  8 02:12:18 2022
+++ src/usr.sbin/tprof/arch/tprof_x86.c	Thu Dec  8 05:29:27 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_x86.c,v 1.14 2022/12/08 02:12:18 msaitoh Exp $	*/
+/*	$NetBSD: tprof_x86.c,v 1.15 2022/12/08 05:29:27 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -831,6 +831,186 @@ static struct event_table amd_f17h = {
 	.next = NULL
 };
 
+/*
+ * AMD Family 19h
+ * From PPR:
+ *	- f19h model 01h B1 (zen3)
+ *	- f19h model 11h B1 (zen4)
+ *	- f19h model 21h B1 (zen3)
+ *	- f19h model 51h A1 (zen3)
+ */
+static struct name_to_event amd_f19h_names[] = {
+	/* Model 1x only */
+	{ "FpRetx87FpOps",			0x02, __BITS(2,0), true },
+
+	/* Only model 1x has bit 4 */
+	{ "FpRetSseAvxOps",			0x03, __BITS(4,0), true },
+
+	{ "FpRetiredSerOps",			0x05, __BITS(3,0), true },
+
+	/* Model 1x only */
+	{ "FpOpsRetiredByWidth",		0x08, __BITS(5,0), true },
+	{ "FpOpsRetiredByType",			0x0a, __BITS(7,0), true },
+	{ "SseAvxOpsRetired",			0x0b, __BITS(7,0), true },
+	{ "FpPackOpsRetired",			0x0c, __BITS(7,0), true },
+	{ "PackedIntOpType",			0x0d, __BITS(7,0), true },
+
+	{ "FpDispFaults",			0x0e, __BITS(3,0), true },
+	{ "LsBadStatus2",			0x24, __BIT(1),	true },
+	{ "LsLocks",0x25, __BIT(0), true },
+	{ "LsRetClClush",			0x26, 0x00, true },
+	{ "LsRetCpuid",0x27, 0x00, true },
+	{ "LsDispatch",0x29, __BITS(2,0), true },
+	{ "LsSmiRx",0x2b, 0x00, true },
+	{ "LsIntTaken",0x2c, 0x00, true },
+	{ "LsSTLF",0x35, 0x00, true },
+	{ "LsStCommitCancel2",			0x37, __BIT(0), true },
+	{ "LsMabAlloc-ls",			0x41, 0x3f, true },
+	{ "LsMabAlloc-hp",			0x41, 0x40, true },
+	{ "LsMabAlloc-all",			0x41, 0x7f, true },
+	{ "LsDmndFillsFromSys",			0x43, 0x5f, true },
+
+	/* Only model 1x has bit 7 */
+	{ "LsAnyFillsFromSys",			0x44, 0xdf, true },
+
+	{ "LsL1DTlbMiss",			0x45, __BITS(7,0), true },
+	{ "LsMisalLoads-MA64",			0x47, __BIT(0), true },
+	{ "LsMisalLoads-MA4K",			0x47, __BIT(1), true },
+	{ "LsMisalLoads-all",			0x47, __BITS(1,0), true },
+	{ "LsPrefInstrDisp",			0x4b, __BITS(2,0), true },
+	{ "LsInefSwPref",			0x52, __BITS(1,0), true },
+
+	/* Only model 1x has bit 7 */
+	{ "LsSwPfDcFills",			0x59, 0xdf, true },
+	{ "LsHwPfDcFills",			0x5a, 0xdf, true },
+
+	{ "LsAllocMabCount",			0x5f, 0x00, true },
+	{ "LsNotHaltedCyc",			0x76, 0x00, true },
+
+	/* Model 0x, 1x and 2x only */
+	{ "LsTlbFlush",0x78, 0xff, true },
+
+	/* Model 1x only */
+	{ "LsNotHaltedP0Cyc",			0x120, __BIT(0), true },
+
+	{ "IcCacheFillL2",			0x82, 0x00, true },
+	{ "IcCacheFillSys",			0x83, 0x00, true },
+	{ "BpL1TlbMissL2TlbHit",		0x84, 0x00, true },
+	{ "BpL1TlbMissL2TlbMiss-IF4K",		0x85, __BIT(0), true },
+	{ "BpL1TlbMissL2TlbMiss-IF2M",		0x85, __BIT(1), true },
+	{ "BpL1TlbMissL2TlbMiss-IF1G",		0x85, __BIT(2), true },
+	{ "BpL1TlbMissL2TlbMiss-Coalesced4K",	0x85, __BIT(3), true },
+	{ "BpL1TlbMissL2TlbMiss-all",		0x85, __BITS(3,0), true },
+
+	{ "BpL2BTBCorrect",			0x8b, 0x00, true },
+	{ "BpDynIndPred",			0x8e, 0x00, true },
+	{ "BpDeReDirect",			0x91, 0x00, true },
+	{ "BpL1TlbFetchHit-IF4K",		0x94, __BIT(0), true },
+	{ "BpL1TlbFetchHit-IF2M",		0x94, __BIT(1), true },
+	{ "BpL1TlbFetchHit-IF1G",		0x94, __BIT(2), true },
+	{ "BpL1TlbFetchHit-all",		0x94, __BITS(2,0), true },
+
+	/* Model 1x only */
+	{ "ResyncsOrNcRedirects",		0x96, 0x00, true },
+
+	{ "IcTagHitMiss-hit",			0x18e, 0x07, true },
+	{ "IcTagHitMiss-miss",			0x18e, 0x18, true },
+	{ 

CVS commit: src

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 05:29:27 UTC 2022

Modified Files:
src/sys/dev/tprof: tprof_x86_amd.c
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
Add AMD family 19h (zen3 and zen4) support to tprof.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/tprof/tprof_x86_amd.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/tprof/arch/tprof_x86.c

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



CVS commit: src/usr.sbin/tprof/arch

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 02:12:18 UTC 2022

Modified Files:
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
Use lowercase consistently for hexadecimal numbers. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/tprof/arch/tprof_x86.c

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



CVS commit: src/usr.sbin/tprof/arch

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Thu Dec  8 02:12:18 UTC 2022

Modified Files:
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
Use lowercase consistently for hexadecimal numbers. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/tprof/arch/tprof_x86.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.sbin/tprof/arch/tprof_x86.c
diff -u src/usr.sbin/tprof/arch/tprof_x86.c:1.13 src/usr.sbin/tprof/arch/tprof_x86.c:1.14
--- src/usr.sbin/tprof/arch/tprof_x86.c:1.13	Wed Dec  7 08:11:49 2022
+++ src/usr.sbin/tprof/arch/tprof_x86.c	Thu Dec  8 02:12:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_x86.c,v 1.13 2022/12/07 08:11:49 msaitoh Exp $	*/
+/*	$NetBSD: tprof_x86.c,v 1.14 2022/12/08 02:12:18 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -78,14 +78,14 @@ static void x86_cpuid(unsigned int *eax,
  */
 static struct name_to_event intel_arch1_names[] = {
 	/* Event Name - Event Select - UMask */
-	{ "unhalted-core-cycles",	0x3C, 0x00, true },
-	{ "instruction-retired",	0xC0, 0x00, true },
-	{ "unhalted-reference-cycles",	0x3C, 0x01, true },
-	{ "llc-reference",		0x2E, 0x4F, true },
-	{ "llc-misses",			0x2E, 0x41, true },
-	{ "branch-instruction-retired",	0xC4, 0x00, true },
-	{ "branch-misses-retired",	0xC5, 0x00, true },
-	{ "topdown-slots",		0xA4, 0x01, true },
+	{ "unhalted-core-cycles",	0x3c, 0x00, true },
+	{ "instruction-retired",	0xc0, 0x00, true },
+	{ "unhalted-reference-cycles",	0x3c, 0x01, true },
+	{ "llc-reference",		0x2e, 0x4f, true },
+	{ "llc-misses",			0x2e, 0x41, true },
+	{ "branch-instruction-retired",	0xc4, 0x00, true },
+	{ "branch-misses-retired",	0xc5, 0x00, true },
+	{ "topdown-slots",		0xa4, 0x01, true },
 };
 
 static struct event_table intel_arch1 = {
@@ -103,7 +103,7 @@ init_intel_arch1(void)
 	struct event_table *table;
 	size_t i;
 
-	eax = 0x0A;
+	eax = 0x0a;
 	ebx = 0;
 	ecx = 0;
 	edx = 0;
@@ -150,53 +150,53 @@ static struct name_to_event intel_silver
 	{ "PAGE_WALKS.D_SIDE_CYCLES",		0x05, 0x01, true },
 	{ "PAGE_WALKS.I_SIDE_CYCLES",		0x05, 0x02, true },
 	{ "PAGE_WALKS.WALKS",			0x05, 0x03, true },
-	{ "LONGEST_LAT_CACHE.MISS",		0x2E, 0x41, true },
-	{ "LONGEST_LAT_CACHE.REFERENCE",	0x2E, 0x4F, true },
+	{ "LONGEST_LAT_CACHE.MISS",		0x2e, 0x41, true },
+	{ "LONGEST_LAT_CACHE.REFERENCE",	0x2e, 0x4f, true },
 	{ "L2_REJECT_XQ.ALL",			0x30, 0x00, true },
 	{ "CORE_REJECT_L2Q.ALL",		0x31, 0x00, true },
-	{ "CPU_CLK_UNHALTED.CORE_P",		0x3C, 0x00, true },
-	{ "CPU_CLK_UNHALTED.REF_P",		0x3C, 0x01, true },
+	{ "CPU_CLK_UNHALTED.CORE_P",		0x3c, 0x00, true },
+	{ "CPU_CLK_UNHALTED.REF_P",		0x3c, 0x01, true },
 	{ "ICACHE.HIT",0x80, 0x01, true },
 	{ "ICACHE.MISSES",			0x80, 0x02, true },
 	{ "ICACHE.ACCESSES",			0x80, 0x03, true },
-	{ "OFFCORE_RESPONSE_0",			0xB7, 0x01, true },
-	{ "OFFCORE_RESPONSE_1",			0xB7, 0x02, true },
-	{ "INST_RETIRED.ANY_P",			0xC0, 0x00, true },
-	{ "UOPS_RETIRED.MS",			0xC2, 0x01, true },
-	{ "UOPS_RETIRED.ALL",			0xC2, 0x10, true },
-	{ "MACHINE_CLEARS.SMC",			0xC3, 0x01, true },
-	{ "MACHINE_CLEARS.MEMORY_ORDERING",	0xC3, 0x02, true },
-	{ "MACHINE_CLEARS.FP_ASSIST",		0xC3, 0x04, true },
-	{ "MACHINE_CLEARS.ALL",			0xC3, 0x08, true },
-	{ "BR_INST_RETIRED.ALL_BRANCHES",	0xC4, 0x00, true },
-	{ "BR_INST_RETIRED.JCC",		0xC4, 0x7E, true },
-	{ "BR_INST_RETIRED.FAR_BRANCH",		0xC4, 0xBF, true },
-	{ "BR_INST_RETIRED.NON_RETURN_IND",	0xC4, 0xEB, true },
-	{ "BR_INST_RETIRED.RETURN",		0xC4, 0xF7, true },
-	{ "BR_INST_RETIRED.CALL",		0xC4, 0xF9, true },
-	{ "BR_INST_RETIRED.IND_CALL",		0xC4, 0xFB, true },
-	{ "BR_INST_RETIRED.REL_CALL",		0xC4, 0xFD, true },
-	{ "BR_INST_RETIRED.TAKEN_JCC",		0xC4, 0xFE, true },
-	{ "BR_MISP_RETIRED.ALL_BRANCHES",	0xC5, 0x00, true },
-	{ "BR_MISP_RETIRED.JCC",		0xC5, 0x7E, true },
-	{ "BR_MISP_RETIRED.FAR",		0xC5, 0xBF, true },
-	{ "BR_MISP_RETIRED.NON_RETURN_IND",	0xC5, 0xEB, true },
-	{ "BR_MISP_RETIRED.RETURN",		0xC5, 0xF7, true },
-	{ "BR_MISP_RETIRED.CALL",		0xC5, 0xF9, true },
-	{ "BR_MISP_RETIRED.IND_CALL",		0xC5, 0xFB, true },
-	{ "BR_MISP_RETIRED.REL_CALL",		0xC5, 0xFD, true },
-	{ "BR_MISP_RETIRED.TAKEN_JCC",		0xC5, 0xFE, true },
-	{ "NO_ALLOC_CYCLES.ROB_FULL",		0xCA, 0x01, true },
-	{ "NO_ALLOC_CYCLES.RAT_STALL",		0xCA, 0x20, true },
-	{ "NO_ALLOC_CYCLES.ALL",		0xCA, 0x3F, true },
-	{ "NO_ALLOC_CYCLES.NOT_DELIVERED",	0xCA, 0x50, true },
-	{ "RS_FULL_STALL.MEC",			0xCB, 0x01, true },
-	{ "RS_FULL_STALL.ALL",			0xCB, 0x1F, true },
-	{ "CYCLES_DIV_BUSY.ANY",		0xCD, 0x01, true },
-	{ "BACLEARS.ALL",			0xE6, 0x01, true },
-	{ "BACLEARS.RETURN",			0xE6, 0x08, true },
-	{ "BACLEARS.COND",			0xE6, 0x10, true },
-	{ "MS_DECODED.MS_ENTRY",		0xE7, 0x01, true },
+	{ "OFFCORE_RESPONSE_0",			0xb7, 0x01, true },
+	{ "OFFCORE_RESPONSE_1",			0xb7, 0x02, true },
+	{ "INST_RETIRED.ANY_P",			0xc0, 0x00, true },
+	{ 

CVS commit: src/doc

2022-12-07 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Dec  8 01:32:36 UTC 2022

Modified Files:
src/doc: 3RDPARTY

Log Message:
3RDPARTY: note newer versions of acpica and gmake are out


To generate a diff of this commit:
cvs rdiff -u -r1.1901 -r1.1902 src/doc/3RDPARTY

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

Modified files:

Index: src/doc/3RDPARTY
diff -u src/doc/3RDPARTY:1.1901 src/doc/3RDPARTY:1.1902
--- src/doc/3RDPARTY:1.1901	Thu Nov 17 23:54:44 2022
+++ src/doc/3RDPARTY	Thu Dec  8 01:32:35 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: 3RDPARTY,v 1.1901 2022/11/17 23:54:44 wiz Exp $
+#	$NetBSD: 3RDPARTY,v 1.1902 2022/12/08 01:32:35 gutteridge Exp $
 #
 # This file contains a list of the software that has been integrated into
 # NetBSD where we are not the primary maintainer.
@@ -42,11 +42,11 @@
 
 Package:	acpica
 Version:	20220331
-Current Vers:	20220331
+Current Vers:	20221020
 Maintainer:	Intel
 Archive Site:	http://www.acpica.org/downloads/
 Home Page:	http://www.acpica.org/
-Date:		2021-08-27
+Date:		2022-12-08
 Mailing List:	de...@acpica.org
 License:	BSD-like
 Responsible:	jruoho
@@ -2132,11 +2132,11 @@ Update MDATE in src/external/gpl2/groff/
 
 Package:	gmake
 Version:	3.81 (Last GPlv2+ version)
-Current Vers:	4.3
+Current Vers:	4.4
 Maintainer:	FSF
 Archive Site:	ftp://ftp.gnu.org/gnu/make/
 Home Page:	http://www.gnu.org/software/make/
-Date:		2020-06-13
+Date:		2022-12-08
 Mailing List:	bug-m...@gnu.org
 Responsible:
 License:	GPLv2+ (3.81), GPLv3+ (3.82 and later)



CVS commit: src/doc

2022-12-07 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Dec  8 01:32:36 UTC 2022

Modified Files:
src/doc: 3RDPARTY

Log Message:
3RDPARTY: note newer versions of acpica and gmake are out


To generate a diff of this commit:
cvs rdiff -u -r1.1901 -r1.1902 src/doc/3RDPARTY

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



CVS commit: src/usr.bin/make

2022-12-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec  7 10:28:48 UTC 2022

Modified Files:
src/usr.bin/make: arch.c compat.c str.c

Log Message:
make: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/make/arch.c
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/make/compat.c
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/str.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/make/arch.c
diff -u src/usr.bin/make/arch.c:1.211 src/usr.bin/make/arch.c:1.212
--- src/usr.bin/make/arch.c:1.211	Tue Sep 27 17:46:58 2022
+++ src/usr.bin/make/arch.c	Wed Dec  7 10:28:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: arch.c,v 1.211 2022/09/27 17:46:58 rillig Exp $	*/
+/*	$NetBSD: arch.c,v 1.212 2022/12/07 10:28:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -126,7 +126,7 @@
 #include "config.h"
 
 /*	"@(#)arch.c	8.2 (Berkeley) 1/2/94"	*/
-MAKE_RCSID("$NetBSD: arch.c,v 1.211 2022/09/27 17:46:58 rillig Exp $");
+MAKE_RCSID("$NetBSD: arch.c,v 1.212 2022/12/07 10:28:48 rillig Exp $");
 
 typedef struct List ArchList;
 typedef struct ListNode ArchListNode;
@@ -305,11 +305,10 @@ Arch_ParseArchive(char **pp, GNodeList *
 		 */
 		/*
 		 * If member contains variables, try and substitute for them.
-		 * This will slow down archive specs with dynamic sources, of
-		 * course, since we'll be (non-)substituting them three
-		 * times, but them's the breaks -- we need to do this since
-		 * SuffExpandChildren calls us, otherwise we could assume the
-		 * thing would be taken care of later.
+		 * This slows down archive specs with dynamic sources, since
+		 * they are (non-)substituted three times, but we need to do
+		 * this since SuffExpandChildren calls us, otherwise we could
+		 * assume the substitutions would be taken care of later.
 		 */
 		if (doSubst) {
 			char *fullName;

Index: src/usr.bin/make/compat.c
diff -u src/usr.bin/make/compat.c:1.242 src/usr.bin/make/compat.c:1.243
--- src/usr.bin/make/compat.c:1.242	Mon Oct 10 21:17:25 2022
+++ src/usr.bin/make/compat.c	Wed Dec  7 10:28:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat.c,v 1.242 2022/10/10 21:17:25 rillig Exp $	*/
+/*	$NetBSD: compat.c,v 1.243 2022/12/07 10:28:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -91,15 +91,15 @@
 #include "pathnames.h"
 
 /*	"@(#)compat.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: compat.c,v 1.242 2022/10/10 21:17:25 rillig Exp $");
+MAKE_RCSID("$NetBSD: compat.c,v 1.243 2022/12/07 10:28:48 rillig Exp $");
 
 static GNode *curTarg = NULL;
 static pid_t compatChild;
 static int compatSigno;
 
 /*
- * CompatDeleteTarget -- delete the file of a failed, interrupted, or
- * otherwise duffed target if not inhibited by .PRECIOUS.
+ * Delete the file of a failed, interrupted, or otherwise duffed target,
+ * unless inhibited by .PRECIOUS.
  */
 static void
 CompatDeleteTarget(GNode *gn)

Index: src/usr.bin/make/str.c
diff -u src/usr.bin/make/str.c:1.93 src/usr.bin/make/str.c:1.94
--- src/usr.bin/make/str.c:1.93	Sat Jun 11 09:24:07 2022
+++ src/usr.bin/make/str.c	Wed Dec  7 10:28:48 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: str.c,v 1.93 2022/06/11 09:24:07 rillig Exp $	*/
+/*	$NetBSD: str.c,v 1.94 2022/12/07 10:28:48 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -71,7 +71,7 @@
 #include "make.h"
 
 /*	"@(#)str.c	5.8 (Berkeley) 6/1/90"	*/
-MAKE_RCSID("$NetBSD: str.c,v 1.93 2022/06/11 09:24:07 rillig Exp $");
+MAKE_RCSID("$NetBSD: str.c,v 1.94 2022/12/07 10:28:48 rillig Exp $");
 
 
 static HashTable interned_strings;
@@ -313,8 +313,8 @@ in_range(char e1, char c, char e2)
 }
 
 /*
- * Str_Match -- Test if a string matches a pattern like "*.[ch]".
- * The following special characters are known *?\[] (as in fnmatch(3)).
+ * Test if a string matches a pattern like "*.[ch]". The pattern matching
+ * characters are '*', '?' and '[]', as in fnmatch(3).
  *
  * XXX: this function does not detect or report malformed patterns.
  *



CVS commit: src/usr.bin/make

2022-12-07 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Dec  7 10:28:48 UTC 2022

Modified Files:
src/usr.bin/make: arch.c compat.c str.c

Log Message:
make: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.211 -r1.212 src/usr.bin/make/arch.c
cvs rdiff -u -r1.242 -r1.243 src/usr.bin/make/compat.c
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/make/str.c

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



CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:33:02 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
Refactor ip_encap.[ch]

- remove encap_attach() which is no longer used
- remove USE_RADIX code in ip_encap.c, which is used for
  encap_attach() only
- remove mask members in encaptab


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/netinet/ip_encap.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/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.76 src/sys/netinet/ip_encap.c:1.77
--- src/sys/netinet/ip_encap.c:1.76	Wed Dec  7 08:28:46 2022
+++ src/sys/netinet/ip_encap.c	Wed Dec  7 08:33:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.c,v 1.76 2022/12/07 08:28:46 knakahara Exp $	*/
+/*	$NetBSD: ip_encap.c,v 1.77 2022/12/07 08:33:02 knakahara Exp $	*/
 /*	$KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $	*/
 
 /*
@@ -57,18 +57,8 @@
  */
 /* XXX is M_NETADDR correct? */
 
-/*
- * With USE_RADIX the code will use radix table for tunnel lookup, for
- * tunnels registered with encap_attach() with a addr/mask pair.
- * Faster on machines with thousands of tunnel registerations (= interfaces).
- *
- * The code assumes that radix table code can handle non-continuous netmask,
- * as it will pass radix table memory region with (src + dst) sockaddr pair.
- */
-#define USE_RADIX
-
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.76 2022/12/07 08:28:46 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.77 2022/12/07 08:33:02 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -128,13 +118,6 @@ static struct encaptab *encap6_lookup(st
 static int encap_add(struct encaptab *);
 static int encap_remove(struct encaptab *);
 static void encap_afcheck(int, const struct sockaddr *, const struct sockaddr *);
-#ifdef USE_RADIX
-static struct radix_node_head *encap_rnh(int);
-static int mask_matchlen(const struct sockaddr *);
-#else
-static int mask_match(const struct encaptab *, const struct sockaddr *,
-		const struct sockaddr *);
-#endif
 static void encap_key_init(struct encap_key *, const struct sockaddr *,
 const struct sockaddr *);
 static void encap_key_inc(struct encap_key *);
@@ -158,11 +141,6 @@ static struct {
 	struct lwp	*busy;
 } encap_whole __cacheline_aligned;
 
-#ifdef USE_RADIX
-struct radix_node_head *encap_head[2];	/* 0 for AF_INET, 1 for AF_INET6 */
-static bool encap_head_updating = false;
-#endif
-
 static thmap_t *encap_map[2];	/* 0 for AF_INET, 1 for AF_INET6 */
 
 static bool encap_initialized = false;
@@ -205,18 +183,6 @@ encap_init(void)
 	PSLIST_INIT(_table);
 #endif
 
-#ifdef USE_RADIX
-	/*
-	 * initialize radix lookup table when the radix subsystem is inited.
-	 */
-	rn_delayedinit((void *)_head[0],
-	sizeof(struct sockaddr_pack) << 3);
-#ifdef INET6
-	rn_delayedinit((void *)_head[1],
-	sizeof(struct sockaddr_pack) << 3);
-#endif
-#endif
-
 	encap_map[0] = thmap_create(0, NULL, THMAP_NOCOPY);
 #ifdef INET6
 	encap_map[1] = thmap_create(0, NULL, THMAP_NOCOPY);
@@ -233,10 +199,6 @@ encap4_lookup(struct mbuf *m, int off, i
 	struct encaptab *ep, *match;
 	int prio, matchprio;
 	int s;
-#ifdef USE_RADIX
-	struct radix_node_head *rnh = encap_rnh(AF_INET);
-	struct radix_node *rn;
-#endif
 	thmap_t *emap = encap_map[0];
 	struct encap_key key;
 
@@ -260,26 +222,6 @@ encap4_lookup(struct mbuf *m, int off, i
 	matchprio = 0;
 
 	s = pserialize_read_enter();
-#ifdef USE_RADIX
-	if (encap_head_updating) {
-		/*
-		 * Update in progress. Do nothing.
-		 */
-		pserialize_read_exit(s);
-		return NULL;
-	}
-
-	rn = rnh->rnh_matchaddr((void *), rnh);
-	if (rn && (rn->rn_flags & RNF_ROOT) == 0) {
-		struct encaptab *encapp = (struct encaptab *)rn;
-
-		psref_acquire(match_psref, >psref,
-		encaptab.elem_class);
-		match = encapp;
-		matchprio = mask_matchlen(match->srcmask) +
-		mask_matchlen(match->dstmask);
-	}
-#endif
 
 	encap_key_init(, sintosa(), sintosa());
 	while ((ep = thmap_get(emap, , sizeof(key))) != NULL) {
@@ -335,42 +277,21 @@ encap4_lookup(struct mbuf *m, int off, i
 
 		psref_acquire(_psref, >psref,
 		encaptab.elem_class);
-		if (ep->func) {
-			pserialize_read_exit(s);
-			/* ep->func is sleepable. e.g. rtalloc1 */
-			prio = (*ep->func)(m, off, proto, ep->arg);
-			s = pserialize_read_enter();
-		} else {
-#ifdef USE_RADIX
-			psref_release(_psref, >psref,
-			encaptab.elem_class);
-			continue;
-#else
-			prio = mask_match(ep, (struct sockaddr *),
-			(struct sockaddr *));
-#endif
-		}
+		pserialize_read_exit(s);
+		/* ep->func is sleepable. e.g. rtalloc1 */
+		prio = (*ep->func)(m, off, proto, ep->arg);
+		s = pserialize_read_enter();
 
 		/*
 		 * We prioritize the matches by using bit length of the
-		 * matches.  mask_match() and user-supplied matching 

CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:33:02 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
Refactor ip_encap.[ch]

- remove encap_attach() which is no longer used
- remove USE_RADIX code in ip_encap.c, which is used for
  encap_attach() only
- remove mask members in encaptab


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.27 -r1.28 src/sys/netinet/ip_encap.h

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



CVS commit: src/sys

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:30:15 UTC 2022

Modified Files:
src/sys/netinet: in_gif.c in_l2tp.c
src/sys/netinet6: in6_gif.c in6_l2tp.c
src/sys/netipsec: ipsecif.c

Log Message:
gif(4), ipsec(4) and l2tp(4) use encap_attach_addr().


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet/in_gif.c
cvs rdiff -u -r1.20 -r1.21 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet6/in6_gif.c
cvs rdiff -u -r1.21 -r1.22 src/sys/netinet6/in6_l2tp.c
cvs rdiff -u -r1.19 -r1.20 src/sys/netipsec/ipsecif.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/netinet/in_gif.c
diff -u src/sys/netinet/in_gif.c:1.95 src/sys/netinet/in_gif.c:1.96
--- src/sys/netinet/in_gif.c:1.95	Thu Sep 19 06:07:25 2019
+++ src/sys/netinet/in_gif.c	Wed Dec  7 08:30:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_gif.c,v 1.95 2019/09/19 06:07:25 knakahara Exp $	*/
+/*	$NetBSD: in_gif.c,v 1.96 2022/12/07 08:30:15 knakahara Exp $	*/
 /*	$KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.95 2019/09/19 06:07:25 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.96 2022/12/07 08:30:15 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -369,12 +369,12 @@ in_gif_attach(struct gif_variant *var)
 
 	if (!var->gv_psrc || !var->gv_pdst)
 		return EINVAL;
-	var->gv_encap_cookie4 = encap_attach(AF_INET, -1, var->gv_psrc,
-	(struct sockaddr *), var->gv_pdst, (struct sockaddr *),
-	_gif_encapsw, var->gv_softc);
+
+	var->gv_encap_cookie4 = encap_attach_addr(AF_INET, -1, var->gv_psrc,
+	var->gv_pdst, NULL, _gif_encapsw, var->gv_softc);
 #else
-	var->gv_encap_cookie4 = encap_attach_func(AF_INET, -1, gif_encapcheck,
-	_gif_encapsw, var->gv_softc);
+	var->gv_encap_cookie4 = encap_attach_addr(AF_INET, -1, var->gv_psrc,
+	var->gv_pdst, gif_encapcheck, _gif_encapsw, var->gv_softc);
 #endif
 	if (var->gv_encap_cookie4 == NULL)
 		return EEXIST;

Index: src/sys/netinet/in_l2tp.c
diff -u src/sys/netinet/in_l2tp.c:1.20 src/sys/netinet/in_l2tp.c:1.21
--- src/sys/netinet/in_l2tp.c:1.20	Fri Feb 19 14:51:59 2021
+++ src/sys/netinet/in_l2tp.c	Wed Dec  7 08:30:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in_l2tp.c,v 1.20 2021/02/19 14:51:59 christos Exp $	*/
+/*	$NetBSD: in_l2tp.c,v 1.21 2022/12/07 08:30:15 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.20 2021/02/19 14:51:59 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.21 2022/12/07 08:30:15 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -404,8 +404,9 @@ in_l2tp_attach(struct l2tp_variant *var)
 
 	if (sc == NULL)
 		return EINVAL;
-	var->lv_encap_cookie = encap_attach_func(AF_INET, IPPROTO_L2TP,
-	in_l2tp_match, _l2tp_encapsw, sc);
+
+	var->lv_encap_cookie = encap_attach_addr(AF_INET, IPPROTO_L2TP,
+	var->lv_psrc, var->lv_pdst, in_l2tp_match, _l2tp_encapsw, sc);
 	if (var->lv_encap_cookie == NULL)
 		return EEXIST;
 

Index: src/sys/netinet6/in6_gif.c
diff -u src/sys/netinet6/in6_gif.c:1.95 src/sys/netinet6/in6_gif.c:1.96
--- src/sys/netinet6/in6_gif.c:1.95	Wed Oct 30 03:45:59 2019
+++ src/sys/netinet6/in6_gif.c	Wed Dec  7 08:30:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_gif.c,v 1.95 2019/10/30 03:45:59 knakahara Exp $	*/
+/*	$NetBSD: in6_gif.c,v 1.96 2022/12/07 08:30:15 knakahara Exp $	*/
 /*	$KAME: in6_gif.c,v 1.62 2001/07/29 04:27:25 itojun Exp $	*/
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.95 2019/10/30 03:45:59 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_gif.c,v 1.96 2022/12/07 08:30:15 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -433,12 +433,12 @@ in6_gif_attach(struct gif_variant *var)
 
 	if (!var->gv_psrc || !var->gv_pdst)
 		return EINVAL;
-	var->gv_encap_cookie6 = encap_attach(AF_INET6, -1, var->gv_psrc,
-	sin6tosa(), var->gv_pdst, sin6tosa(),
-	(const void *)_gif_encapsw, var->gv_softc);
+
+	var->gv_encap_cookie6 = encap_attach_addr(AF_INET6, -1, var->gv_psrc,
+	var->gv_pdst, NULL, _gif_encapsw, var->gv_softc);
 #else
-	var->gv_encap_cookie6 = encap_attach_func(AF_INET6, -1, gif_encapcheck,
-	_gif_encapsw, var->gv_softc);
+	var->gv_encap_cookie6 = encap_attach_addr(AF_INET6, -1, var->gv_psrc,
+	var->gv_pdst, gif_encapcheck, _gif_encapsw, var->gv_softc);
 #endif
 	if (var->gv_encap_cookie6 == NULL)
 		return EEXIST;

Index: src/sys/netinet6/in6_l2tp.c
diff -u src/sys/netinet6/in6_l2tp.c:1.21 src/sys/netinet6/in6_l2tp.c:1.22
--- src/sys/netinet6/in6_l2tp.c:1.21	Fri Feb 19 14:52:00 2021
+++ src/sys/netinet6/in6_l2tp.c	Wed Dec  7 08:30:15 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: in6_l2tp.c,v 1.21 2021/02/19 14:52:00 christos Exp $	*/
+/*	$NetBSD: in6_l2tp.c,v 

CVS commit: src/sys

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:30:15 UTC 2022

Modified Files:
src/sys/netinet: in_gif.c in_l2tp.c
src/sys/netinet6: in6_gif.c in6_l2tp.c
src/sys/netipsec: ipsecif.c

Log Message:
gif(4), ipsec(4) and l2tp(4) use encap_attach_addr().


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet/in_gif.c
cvs rdiff -u -r1.20 -r1.21 src/sys/netinet/in_l2tp.c
cvs rdiff -u -r1.95 -r1.96 src/sys/netinet6/in6_gif.c
cvs rdiff -u -r1.21 -r1.22 src/sys/netinet6/in6_l2tp.c
cvs rdiff -u -r1.19 -r1.20 src/sys/netipsec/ipsecif.c

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



CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:28:46 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
Implement encap_attach_addr() which is used by IP-encaped tunnels.

The tunnels attached by encap_attach() can process receiving packets
fastly as the softc is searched by radix-tree.  However, the tunnels
cannot use priority function which decides tunnel's softc by not only
source and destination but also other informations.
On the other hand, the tunnels attached by encap_attach_func() can
use priority function. However, the tunnels can be slow receiving
processing as the softc is searched by linear search (and uses each
priority function).

encap_attach_addr() can be used for tunnels which is fixed tunnel
source address and tunnel destination address.  The tunnels attached
by encap_attach_addr() is searched by thmap(9), so the receiving processing
can be fast.  Moreover, the tunnels can use priority function.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.26 -r1.27 src/sys/netinet/ip_encap.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/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.75 src/sys/netinet/ip_encap.c:1.76
--- src/sys/netinet/ip_encap.c:1.75	Wed Dec  7 08:27:03 2022
+++ src/sys/netinet/ip_encap.c	Wed Dec  7 08:28:46 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.c,v 1.75 2022/12/07 08:27:03 knakahara Exp $	*/
+/*	$NetBSD: ip_encap.c,v 1.76 2022/12/07 08:28:46 knakahara Exp $	*/
 /*	$KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $	*/
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.75 2022/12/07 08:27:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.76 2022/12/07 08:28:46 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -89,6 +89,7 @@ __KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -134,6 +135,9 @@ static int mask_matchlen(const struct so
 static int mask_match(const struct encaptab *, const struct sockaddr *,
 		const struct sockaddr *);
 #endif
+static void encap_key_init(struct encap_key *, const struct sockaddr *,
+const struct sockaddr *);
+static void encap_key_inc(struct encap_key *);
 
 /*
  * In encap[46]_lookup(), ep->func can sleep(e.g. rtalloc1) while walking
@@ -159,6 +163,8 @@ struct radix_node_head *encap_head[2];	/
 static bool encap_head_updating = false;
 #endif
 
+static thmap_t *encap_map[2];	/* 0 for AF_INET, 1 for AF_INET6 */
+
 static bool encap_initialized = false;
 /*
  * must be done before other encap interfaces initialization.
@@ -210,6 +216,11 @@ encap_init(void)
 	sizeof(struct sockaddr_pack) << 3);
 #endif
 #endif
+
+	encap_map[0] = thmap_create(0, NULL, THMAP_NOCOPY);
+#ifdef INET6
+	encap_map[1] = thmap_create(0, NULL, THMAP_NOCOPY);
+#endif
 }
 
 #ifdef INET
@@ -226,6 +237,8 @@ encap4_lookup(struct mbuf *m, int off, i
 	struct radix_node_head *rnh = encap_rnh(AF_INET);
 	struct radix_node *rn;
 #endif
+	thmap_t *emap = encap_map[0];
+	struct encap_key key;
 
 	KASSERT(m->m_len >= sizeof(*ip));
 
@@ -267,6 +280,51 @@ encap4_lookup(struct mbuf *m, int off, i
 		mask_matchlen(match->dstmask);
 	}
 #endif
+
+	encap_key_init(, sintosa(), sintosa());
+	while ((ep = thmap_get(emap, , sizeof(key))) != NULL) {
+		struct psref elem_psref;
+
+		KASSERT(ep->af == AF_INET);
+
+		if (ep->proto >= 0 && ep->proto != proto) {
+			encap_key_inc();
+			continue;
+		}
+
+		psref_acquire(_psref, >psref,
+		encaptab.elem_class);
+		if (ep->func) {
+			pserialize_read_exit(s);
+			prio = (*ep->func)(m, off, proto, ep->arg);
+			s = pserialize_read_enter();
+		} else {
+			prio = pack.mine.sin_len + pack.yours.sin_len;
+		}
+
+		if (prio <= 0) {
+			psref_release(_psref, >psref,
+			encaptab.elem_class);
+			encap_key_inc();
+			continue;
+		}
+		if (prio > matchprio) {
+			/* release last matched ep */
+			if (match != NULL)
+psref_release(match_psref, >psref,
+encaptab.elem_class);
+
+			psref_copy(match_psref, _psref,
+			encaptab.elem_class);
+			matchprio = prio;
+			match = ep;
+		}
+
+		psref_release(_psref, >psref,
+		encaptab.elem_class);
+		encap_key_inc();
+	}
+
 	PSLIST_READER_FOREACH(ep, _table, struct encaptab, chain) {
 		struct psref elem_psref;
 
@@ -386,6 +444,8 @@ encap6_lookup(struct mbuf *m, int off, i
 	struct radix_node_head *rnh = encap_rnh(AF_INET6);
 	struct radix_node *rn;
 #endif
+	thmap_t *emap = encap_map[1];
+	struct encap_key key;
 
 	KASSERT(m->m_len >= sizeof(*ip6));
 
@@ -427,6 +487,50 @@ encap6_lookup(struct mbuf *m, int off, i
 		mask_matchlen(match->dstmask);
 	}
 #endif
+
+	encap_key_init(, sin6tosa(), sin6tosa());
+	while ((ep = thmap_get(emap, , sizeof(key))) != NULL) {
+		struct psref elem_psref;
+
+		KASSERT(ep->af == 

CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:28:46 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
Implement encap_attach_addr() which is used by IP-encaped tunnels.

The tunnels attached by encap_attach() can process receiving packets
fastly as the softc is searched by radix-tree.  However, the tunnels
cannot use priority function which decides tunnel's softc by not only
source and destination but also other informations.
On the other hand, the tunnels attached by encap_attach_func() can
use priority function. However, the tunnels can be slow receiving
processing as the softc is searched by linear search (and uses each
priority function).

encap_attach_addr() can be used for tunnels which is fixed tunnel
source address and tunnel destination address.  The tunnels attached
by encap_attach_addr() is searched by thmap(9), so the receiving processing
can be fast.  Moreover, the tunnels can use priority function.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.26 -r1.27 src/sys/netinet/ip_encap.h

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



CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:27:03 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
refactor: use typedef for ip_encap priority function


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.25 -r1.26 src/sys/netinet/ip_encap.h

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



CVS commit: src/sys/netinet

2022-12-07 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Dec  7 08:27:03 UTC 2022

Modified Files:
src/sys/netinet: ip_encap.c ip_encap.h

Log Message:
refactor: use typedef for ip_encap priority function


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 src/sys/netinet/ip_encap.c
cvs rdiff -u -r1.25 -r1.26 src/sys/netinet/ip_encap.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/netinet/ip_encap.c
diff -u src/sys/netinet/ip_encap.c:1.74 src/sys/netinet/ip_encap.c:1.75
--- src/sys/netinet/ip_encap.c:1.74	Sat Aug 22 01:43:07 2020
+++ src/sys/netinet/ip_encap.c	Wed Dec  7 08:27:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.c,v 1.74 2020/08/22 01:43:07 riastradh Exp $	*/
+/*	$NetBSD: ip_encap.c,v 1.75 2022/12/07 08:27:03 knakahara Exp $	*/
 /*	$KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $	*/
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.74 2020/08/22 01:43:07 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.75 2022/12/07 08:27:03 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -750,7 +750,7 @@ fail:
 
 const struct encaptab *
 encap_attach_func(int af, int proto,
-int (*func)(struct mbuf *, int, int, void *),
+encap_priofunc_t *func,
 const struct encapsw *esw, void *arg)
 {
 	struct encaptab *ep;

Index: src/sys/netinet/ip_encap.h
diff -u src/sys/netinet/ip_encap.h:1.25 src/sys/netinet/ip_encap.h:1.26
--- src/sys/netinet/ip_encap.h:1.25	Fri Sep 14 05:09:51 2018
+++ src/sys/netinet/ip_encap.h	Wed Dec  7 08:27:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ip_encap.h,v 1.25 2018/09/14 05:09:51 maxv Exp $	*/
+/*	$NetBSD: ip_encap.h,v 1.26 2022/12/07 08:27:03 knakahara Exp $	*/
 /*	$KAME: ip_encap.h,v 1.7 2000/03/25 07:23:37 sumikawa Exp $	*/
 
 /*
@@ -62,6 +62,8 @@ struct encapsw {
 #define encapsw4 encapsw46._encapsw4
 #define encapsw6 encapsw46._encapsw6
 
+typedef	int encap_priofunc_t(struct mbuf *, int, int, void *);
+
 struct encaptab {
 	struct radix_node nodes[2];
 	struct pslist_entry chain;
@@ -73,7 +75,7 @@ struct encaptab {
 	struct sockaddr *srcmask;
 	struct sockaddr *dst;		/* remote addr */
 	struct sockaddr *dstmask;
-	int (*func) (struct mbuf *, int, int, void *);
+	encap_priofunc_t *func;
 	const struct encapsw *esw;
 	void *arg;
 	struct psref_target	psref;
@@ -106,7 +108,7 @@ const struct encaptab *encap_attach(int,
 	const struct sockaddr *, const struct sockaddr *,
 	const struct sockaddr *, const struct encapsw *, void *);
 const struct encaptab *encap_attach_func(int, int,
-	int (*)(struct mbuf *, int, int, void *),
+	encap_priofunc_t *,
 	const struct encapsw *, void *);
 void	*encap6_ctlinput(int, const struct sockaddr *, void *);
 int	encap_detach(const struct encaptab *);



CVS commit: src/usr.sbin/tprof/arch

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec  7 08:11:49 UTC 2022

Modified Files:
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
KNF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/arch/tprof_x86.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.sbin/tprof/arch/tprof_x86.c
diff -u src/usr.sbin/tprof/arch/tprof_x86.c:1.12 src/usr.sbin/tprof/arch/tprof_x86.c:1.13
--- src/usr.sbin/tprof/arch/tprof_x86.c:1.12	Mon Jun 13 09:28:58 2022
+++ src/usr.sbin/tprof/arch/tprof_x86.c	Wed Dec  7 08:11:49 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: tprof_x86.c,v 1.12 2022/06/13 09:28:58 msaitoh Exp $	*/
+/*	$NetBSD: tprof_x86.c,v 1.13 2022/12/07 08:11:49 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@ static void x86_cpuid(unsigned int *eax,
 	: "0" (*eax), "2" (*ecx));
 }
 
-/* -- */
+/* - */
 
 /*
  * Intel Architectural Version 1.
@@ -374,142 +374,143 @@ init_intel_goldmontplus(void)
  */
 static struct name_to_event intel_skylake_kabylake_names[] = {
 	/* Event Name - Event Select - UMask */
-	{ "LD_BLOCKS.STORE_FORWARD",	0x03, 0x02, true },
-	{ "LD_BLOCKS.NO_SR",		0x03, 0x08, true },
-	{ "LD_BLOCKS_PARTIAL.ADDRESS_ALIAS",0x07, 0x01, true },
-	{ "DTLB_LOAD_MISSES.MISS_CAUSES_A_WALK",			0x08, 0x01, true },
-	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_4K",0x08, 0x02, true },
-	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_2M_4M",			0x08, 0x04, true },
-	{ "DTLB_LOAD_MISSES.WALK_COMPLETED_1G",0x08, 0x08, true },
-	{ "DTLB_LOAD_MISSES.WALK_COMPLETED",0x08, 0x0E, true },
-	{ "DTLB_LOAD_MISSES.WALK_PENDING",0x08, 0x10, true },
-	{ "DTLB_LOAD_MISSES.STLB_HIT",	0x08, 0x20, true },
-	{ "INT_MISC.RECOVERY_CYCLES",	0x0D, 0x01, true },
-	{ "INT_MISC.CLEAR_RESTEER_CYCLES",0x0D, 0x80, true },
-	{ "UOPS_ISSUED.ANY",		0x0E, 0x01, true },
-	{ "UOPS_ISSUED.VECTOR_WIDTH_MISMATCH",0x0E, 0x02, true },
-	{ "UOPS_ISSUED.SLOW_LEA",	0x0E, 0x20, true },
-	{ "L2_RQSTS.DEMAND_DATA_RD_MISS",0x24, 0x21, true },
-	{ "L2_RQSTS.RFO_MISS",		0x24, 0x22, true },
-	{ "L2_RQSTS.CODE_RD_MISS",	0x24, 0x24, true },
-	{ "L2_RQSTS.ALL_DEMAND_MISS",	0x24, 0x27, true },
-	{ "L2_RQSTS.PF_MISS",		0x24, 0x38, true },
-	{ "L2_RQSTS.MISS",		0x24, 0x3F, true },
-	{ "L2_RQSTS.DEMAND_DATA_RD_HIT",0x24, 0x41, true },
-	{ "L2_RQSTS.RFO_HIT",		0x24, 0x42, true },
-	{ "L2_RQSTS.CODE_RD_HIT",	0x24, 0x44, true },
-	{ "L2_RQSTS.PF_HIT",		0x24, 0xD8, true },
-	{ "L2_RQSTS.ALL_DEMAND_DATA_RD",0x24, 0xE1, true },
-	{ "L2_RQSTS.ALL_RFO",		0x24, 0xE2, true },
-	{ "L2_RQSTS.ALL_CODE_RD",	0x24, 0xE4, true },
-	{ "L2_RQSTS.ALL_DEMAND_REFERENCES",0x24, 0xE7, true },
-	{ "L2_RQSTS.ALL_PF",		0x24, 0xF8, true },
-	{ "L2_RQSTS.REFERENCES",	0x24, 0xFF, true },
-	{ "SW_PREFETCH_ACCESS.NTA",	0x32, 0x01, true },
-	{ "SW_PREFETCH_ACCESS.T0",	0x32, 0x02, true },
-	{ "SW_PREFETCH_ACCESS.T1_T2",	0x32, 0x04, true },
-	{ "SW_PREFETCH_ACCESS.PREFETCHW",0x32, 0x08, true },
-	{ "CPU_CLK_THREAD_UNHALTED.ONE_THREAD_ACTIVE",			0x3C, 0x02, true },
-	{ "CPU_CLK_UNHALTED.ONE_THREAD_ACTIVE",0x3C, 0x02, true },
-	{ "L1D_PEND_MISS.PENDING",	0x48, 0x01, true },
-	{ "L1D_PEND_MISS.FB_FULL",	0x48, 0x02, true },
-	{ "DTLB_STORE_MISSES.MISS_CAUSES_A_WALK",			0x49, 0x01, true },
-	{ "DTLB_STORE_MISSES.WALK_COMPLETED_4K",			0x49, 0x02, true },
-	{ "DTLB_STORE_MISSES.WALK_COMPLETED_2M_4M",			0x49, 0x04, true },
-	{ "DTLB_STORE_MISSES.WALK_COMPLETED_1G",			0x49, 0x08, true },
-	{ "DTLB_STORE_MISSES.WALK_COMPLETED",0x49, 0x0E, true },
-	{ "DTLB_STORE_MISSES.WALK_PENDING",0x49, 0x10, true },
-	{ "DTLB_STORE_MISSES.STLB_HIT",	0x49, 0x20, true },
-	{ "LOAD_HIT_PRE.SW_PF",		0x4C, 0x01, true },
-	{ "EPT.WALK_PENDING",		0x4F, 0x10, true },
-	{ "L1D.REPLACEMENT",		0x51, 0x01, true },
-	{ "RS_EVENTS.EMPTY_CYCLES",	0x5E, 0x01, true },
-	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_DATA_RD",		0x60, 0x01, true },
-	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_CODE_RD",		0x60, 0x02, true },
-	{ "OFFCORE_REQUESTS_OUTSTANDING.DEMAND_RFO",			0x60, 0x04, true },
-	{ "OFFCORE_REQUESTS_OUTSTANDING.ALL_DATA_RD",			0x60, 0x08, true },
-	{ "OFFCORE_REQUESTS_OUTSTANDING.L3_MISS_DEMAND_DATA_RD",	0x60, 0x10, true },
-	{ "IDQ.MITE_UOPS",		0x79, 0x04, true },
-	{ "IDQ.DSB_UOPS",		0x79, 0x08, true },
-	{ "IDQ.MS_MITE_UOPS",		0x79, 0x20, true },
-	{ "IDQ.MS_UOPS",		0x79, 0x30, true },
-	{ "ICACHE_16B.IFDATA_STALL",	0x80, 0x04, true },
-	{ "ICACHE_64B.IFTAG_HIT",	0x83, 0x01, true },
-	{ "ICACHE_64B.IFTAG_MISS",	0x83, 0x02, true },
-	{ "ICACHE_64B.IFTAG_STALL",	0x83, 0x04, true },
-	{ 

CVS commit: src/usr.sbin/tprof/arch

2022-12-07 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Dec  7 08:11:49 UTC 2022

Modified Files:
src/usr.sbin/tprof/arch: tprof_x86.c

Log Message:
KNF. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/tprof/arch/tprof_x86.c

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