Module Name:    src
Committed By:   maxv
Date:           Wed Apr 15 17:16:22 UTC 2020

Modified Files:
        src/sys/arch/amd64/conf: GENERIC
        src/sys/conf: files
        src/sys/kern: subr_pool.c

Log Message:
Introduce POOL_NOCACHE, simple option to cancel pool_caches and go directly
to the pool layer. It is taken out of POOL_QUARANTINE.

Advertise POOL_NOCACHE for kMSan rather than POOL_QUARANTINE. With kMSan
we are only interested in the no-caching effect, not the quarantine. This
reduces memory pressure on kMSan kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.564 -r1.565 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.1264 -r1.1265 src/sys/conf/files
cvs rdiff -u -r1.267 -r1.268 src/sys/kern/subr_pool.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/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.564 src/sys/arch/amd64/conf/GENERIC:1.565
--- src/sys/arch/amd64/conf/GENERIC:1.564	Sat Mar 28 08:35:36 2020
+++ src/sys/arch/amd64/conf/GENERIC	Wed Apr 15 17:16:22 2020
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.564 2020/03/28 08:35:36 isaki Exp $
+# $NetBSD: GENERIC,v 1.565 2020/04/15 17:16:22 maxv Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@ include 	"arch/amd64/conf/std.amd64"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident		"GENERIC-$Revision: 1.564 $"
+#ident		"GENERIC-$Revision: 1.565 $"
 
 maxusers	64		# estimated number of users
 
@@ -134,14 +134,14 @@ options 	KDTRACE_HOOKS	# kernel DTrace h
 #options 	KCSAN_PANIC	# optional
 
 # Kernel Memory Sanitizer (kMSan). You need to disable SVS and kernel modules
-# to use it. The quarantine is optional and can help KMSAN find uninitialized
+# to use it. POOL_NOCACHE is optional and can help KMSAN find uninitialized
 # memory in pool caches. Note that KMSAN requires at least 4GB of RAM.
 #makeoptions 	KMSAN=1		# mandatory
 #options 	KMSAN		# mandatory
 #no options	SVS		# mandatory
 #no options 	MODULAR		# mandatory
 #no options 	MODULAR_DEFAULT_AUTOLOAD	# mandatory
-#options	POOL_QUARANTINE	# optional
+#options 	POOL_NOCACHE	# optional
 #options 	KMSAN_PANIC	# optional
 
 # Kernel Code Coverage Driver.

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1264 src/sys/conf/files:1.1265
--- src/sys/conf/files:1.1264	Sat Apr  4 19:02:53 2020
+++ src/sys/conf/files	Wed Apr 15 17:16:22 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1264 2020/04/04 19:02:53 jdolecek Exp $
+#	$NetBSD: files,v 1.1265 2020/04/15 17:16:22 maxv Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -37,6 +37,7 @@ defflag				KMSAN
 defflag opt_kmsan.h		KMSAN_PANIC
 defflag				KCOV
 defflag opt_pool.h		POOL_QUARANTINE
+defflag opt_pool.h		POOL_NOCACHE
 
 defparam opt_copy_symtab.h	makeoptions_COPY_SYMTAB
 

Index: src/sys/kern/subr_pool.c
diff -u src/sys/kern/subr_pool.c:1.267 src/sys/kern/subr_pool.c:1.268
--- src/sys/kern/subr_pool.c:1.267	Mon Apr 13 00:27:17 2020
+++ src/sys/kern/subr_pool.c	Wed Apr 15 17:16:22 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_pool.c,v 1.267 2020/04/13 00:27:17 chs Exp $	*/
+/*	$NetBSD: subr_pool.c,v 1.268 2020/04/15 17:16:22 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010, 2014, 2015, 2018
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.267 2020/04/13 00:27:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.268 2020/04/15 17:16:22 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -87,6 +87,10 @@ static struct pool phpool[PHPOOL_MAX];
 #define POOL_REDZONE
 #endif
 
+#if defined(POOL_QUARANTINE)
+#define POOL_NOCACHE
+#endif
+
 #ifdef POOL_REDZONE
 # ifdef KASAN
 #  define POOL_REDZONE_SIZE 8
@@ -121,12 +125,16 @@ static void pool_quarantine_init(struct 
 static void pool_quarantine_flush(struct pool *);
 static bool pool_put_quarantine(struct pool *, void *,
     struct pool_pagelist *);
-static bool pool_cache_put_quarantine(pool_cache_t, void *, paddr_t);
 #else
 #define pool_quarantine_init(a)			__nothing
 #define pool_quarantine_flush(a)		__nothing
 #define pool_put_quarantine(a, b, c)		false
-#define pool_cache_put_quarantine(a, b, c)	false
+#endif
+
+#ifdef POOL_NOCACHE
+static bool pool_cache_put_nocache(pool_cache_t, void *);
+#else
+#define pool_cache_put_nocache(a, b)		false
 #endif
 
 #define NO_CTOR	__FPTRCAST(int (*)(void *, void *, int), nullop)
@@ -2705,7 +2713,7 @@ pool_cache_put_paddr(pool_cache_t pc, vo
 		pc_phinpage_check(pc, object);
 	}
 
-	if (pool_cache_put_quarantine(pc, object, pa)) {
+	if (pool_cache_put_nocache(pc, object)) {
 		return;
 	}
 
@@ -2961,9 +2969,11 @@ pool_put_quarantine(struct pool *pp, voi
 
 	return true;
 }
+#endif
 
+#ifdef POOL_NOCACHE
 static bool
-pool_cache_put_quarantine(pool_cache_t pc, void *p, paddr_t pa)
+pool_cache_put_nocache(pool_cache_t pc, void *p)
 {
 	pool_cache_destruct_object(pc, p);
 	return true;

Reply via email to