Source-Changes-HG archive

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

[src/trunk]: src/sys/uvm uvm(9): One rndsource for faults -- not one per CPU.



details:   https://anonhg.NetBSD.org/src/rev/83c06431c578
branches:  trunk
changeset: 377558:83c06431c578
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Jul 17 12:55:37 2023 +0000

description:
uvm(9): One rndsource for faults -- not one per CPU.

All relevant state is per-CPU anyway; the only substantive difference
this makes is how many entries appear in `rndctl -l' output and what
they are called -- formerly the somewhat confusing `cpuN', meaning
`page faults on cpuN', and now just `uvmfault'.  I don't think
there's any real value in being able to enable or disable measurement
or counting of page faults on one CPU vs others, so although this
could be a minor compatibility change, it's hard to imagine it
matters much.

XXX kernel ABI change in struct cpu_info

diffstat:

 sys/uvm/uvm.h           |   6 +-----
 sys/uvm/uvm_fault.c     |   7 ++++---
 sys/uvm/uvm_init.c      |  16 ++++++++++++++--
 sys/uvm/uvm_page.c      |  11 ++---------
 sys/uvm/uvm_rndsource.h |  36 ++++++++++++++++++++++++++++++++++++
 5 files changed, 57 insertions(+), 19 deletions(-)

diffs (188 lines):

diff -r c231857432e9 -r 83c06431c578 sys/uvm/uvm.h
--- a/sys/uvm/uvm.h     Mon Jul 17 12:55:20 2023 +0000
+++ b/sys/uvm/uvm.h     Mon Jul 17 12:55:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm.h,v 1.77 2020/05/17 15:11:57 ad Exp $      */
+/*     $NetBSD: uvm.h,v 1.78 2023/07/17 12:55:37 riastradh Exp $       */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -63,7 +63,6 @@
 #ifdef _KERNEL
 
 #include <uvm/uvm_physseg.h>
-#include <sys/rndsource.h>
 
 /*
  * pull in VM_NFREELIST
@@ -85,9 +84,6 @@ struct uvm_cpu {
        u_int           pgflcolor;              /* next color to allocate */
        u_int           pgflbucket;             /* where to send our pages */
 
-       /* entropy */
-       krndsource_t    rs;                     /* entropy source */
-
        /* uvmpdpol: queue of intended page status changes. */
        struct vm_page  **pdq;                  /* queue entries */
        u_int           pdqhead;                /* current queue head */
diff -r c231857432e9 -r 83c06431c578 sys/uvm/uvm_fault.c
--- a/sys/uvm/uvm_fault.c       Mon Jul 17 12:55:20 2023 +0000
+++ b/sys/uvm/uvm_fault.c       Mon Jul 17 12:55:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_fault.c,v 1.232 2023/04/09 09:00:56 riastradh Exp $        */
+/*     $NetBSD: uvm_fault.c,v 1.233 2023/07/17 12:55:37 riastradh Exp $        */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.232 2023/04/09 09:00:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_fault.c,v 1.233 2023/07/17 12:55:37 riastradh Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -44,6 +44,7 @@
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pdpolicy.h>
+#include <uvm/uvm_rndsource.h>
 
 /*
  *
@@ -865,7 +866,7 @@ uvm_fault_internal(struct vm_map *orig_m
                /* Don't flood RNG subsystem with samples. */
                if (++(ci->ci_faultrng) == 503) {
                        ci->ci_faultrng = 0;
-                       rnd_add_uint32(&curcpu()->ci_data.cpu_uvm->rs,
+                       rnd_add_uint32(&uvm_fault_rndsource,
                            sizeof(vaddr_t) == sizeof(uint32_t) ?
                            (uint32_t)vaddr : sizeof(vaddr_t) ==
                            sizeof(uint64_t) ?
diff -r c231857432e9 -r 83c06431c578 sys/uvm/uvm_init.c
--- a/sys/uvm/uvm_init.c        Mon Jul 17 12:55:20 2023 +0000
+++ b/sys/uvm/uvm_init.c        Mon Jul 17 12:55:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_init.c,v 1.55 2020/11/04 01:30:19 chs Exp $        */
+/*     $NetBSD: uvm_init.c,v 1.56 2023/07/17 12:55:37 riastradh Exp $  */
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.55 2020/11/04 01:30:19 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v 1.56 2023/07/17 12:55:37 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -43,11 +43,13 @@
 #include <sys/kmem.h>
 #include <sys/mman.h>
 #include <sys/vnode.h>
+#include <sys/rndsource.h>
 
 #include <uvm/uvm.h>
 #include <uvm/uvm_pdpolicy.h>
 #include <uvm/uvm_physseg.h>
 #include <uvm/uvm_readahead.h>
+#include <uvm/uvm_rndsource.h>
 
 /*
  * struct uvm: we store most global vars in this structure to make them
@@ -66,6 +68,8 @@ const int * const uvmexp_pageshift = &uv
 
 kmutex_t uvm_kentry_lock __cacheline_aligned;
 
+struct krndsource uvm_fault_rndsource;
+
 /*
  * uvm_md_init: Init dependant on the MD boot context.
  *             called from MD code.
@@ -189,4 +193,12 @@ uvm_init(void)
         */
 
        uvm_ra_init();
+
+       /*
+        * Initialize random source for page fault events.
+        */
+
+       rnd_attach_source(&uvm_fault_rndsource, "uvmfault", RND_TYPE_VM,
+           RND_FLAG_COLLECT_TIME|RND_FLAG_COLLECT_VALUE|
+           RND_FLAG_ESTIMATE_VALUE);
 }
diff -r c231857432e9 -r 83c06431c578 sys/uvm/uvm_page.c
--- a/sys/uvm/uvm_page.c        Mon Jul 17 12:55:20 2023 +0000
+++ b/sys/uvm/uvm_page.c        Mon Jul 17 12:55:37 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uvm_page.c,v 1.252 2023/04/09 09:00:56 riastradh Exp $ */
+/*     $NetBSD: uvm_page.c,v 1.253 2023/07/17 12:55:37 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -95,7 +95,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.252 2023/04/09 09:00:56 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_page.c,v 1.253 2023/07/17 12:55:37 riastradh Exp $");
 
 #include "opt_ddb.h"
 #include "opt_uvm.h"
@@ -980,13 +980,6 @@ uvm_cpu_attach(struct cpu_info *ci)
        }
 
        uvmpdpol_init_cpu(ucpu);
-
-       /*
-        * Attach RNG source for this CPU's VM events
-        */
-        rnd_attach_source(&ucpu->rs, ci->ci_data.cpu_name, RND_TYPE_VM,
-           RND_FLAG_COLLECT_TIME|RND_FLAG_COLLECT_VALUE|
-           RND_FLAG_ESTIMATE_VALUE);
 }
 
 /*
diff -r c231857432e9 -r 83c06431c578 sys/uvm/uvm_rndsource.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/uvm/uvm_rndsource.h   Mon Jul 17 12:55:37 2023 +0000
@@ -0,0 +1,36 @@
+/*     $NetBSD: uvm_rndsource.h,v 1.1 2023/07/17 12:55:37 riastradh Exp $      */
+
+/*-
+ * Copyright (c) 2023 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef        _UVM_UVM_RNDSOURCE_H
+#define        _UVM_UVM_RNDSOURCE_H
+
+#include <sys/rndsource.h>
+
+extern struct krndsource uvm_fault_rndsource;
+
+#endif /* _UVM_UVM_RNDSOURCE_H */



Home | Main Index | Thread Index | Old Index