Source-Changes-HG archive

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

[src/trunk]: src/sys Introduce POOL_NOCACHE, simple option to cancel pool_cac...



details:   https://anonhg.NetBSD.org/src/rev/f498f595601f
branches:  trunk
changeset: 930864:f498f595601f
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Apr 15 17:16:22 2020 +0000

description:
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.

diffstat:

 sys/arch/amd64/conf/GENERIC |   8 ++++----
 sys/conf/files              |   3 ++-
 sys/kern/subr_pool.c        |  24 +++++++++++++++++-------
 3 files changed, 23 insertions(+), 12 deletions(-)

diffs (123 lines):

diff -r 2df4627083a6 -r f498f595601f sys/arch/amd64/conf/GENERIC
--- a/sys/arch/amd64/conf/GENERIC       Wed Apr 15 17:00:07 2020 +0000
+++ b/sys/arch/amd64/conf/GENERIC       Wed Apr 15 17:16:22 2020 +0000
@@ -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 @@
 
 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       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.
diff -r 2df4627083a6 -r f498f595601f sys/conf/files
--- a/sys/conf/files    Wed Apr 15 17:00:07 2020 +0000
+++ b/sys/conf/files    Wed Apr 15 17:16:22 2020 +0000
@@ -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 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
 
diff -r 2df4627083a6 -r f498f595601f sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c      Wed Apr 15 17:00:07 2020 +0000
+++ b/sys/kern/subr_pool.c      Wed Apr 15 17:16:22 2020 +0000
@@ -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 @@
 #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_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 @@
                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 @@
 
        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;



Home | Main Index | Thread Index | Old Index