Module Name: src Committed By: riastradh Date: Mon Jul 17 12:55:38 UTC 2023
Modified Files: src/sys/uvm: uvm.h uvm_fault.c uvm_init.c uvm_page.c Added Files: src/sys/uvm: uvm_rndsource.h Log Message: 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 To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/sys/uvm/uvm.h cvs rdiff -u -r1.232 -r1.233 src/sys/uvm/uvm_fault.c cvs rdiff -u -r1.55 -r1.56 src/sys/uvm/uvm_init.c cvs rdiff -u -r1.252 -r1.253 src/sys/uvm/uvm_page.c cvs rdiff -u -r0 -r1.1 src/sys/uvm/uvm_rndsource.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/uvm/uvm.h diff -u src/sys/uvm/uvm.h:1.77 src/sys/uvm/uvm.h:1.78 --- src/sys/uvm/uvm.h:1.77 Sun May 17 15:11:57 2020 +++ src/sys/uvm/uvm.h Mon Jul 17 12:55:37 2023 @@ -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 */ Index: src/sys/uvm/uvm_fault.c diff -u src/sys/uvm/uvm_fault.c:1.232 src/sys/uvm/uvm_fault.c:1.233 --- src/sys/uvm/uvm_fault.c:1.232 Sun Apr 9 09:00:56 2023 +++ src/sys/uvm/uvm_fault.c Mon Jul 17 12:55:37 2023 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_fault.c, #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) ? Index: src/sys/uvm/uvm_init.c diff -u src/sys/uvm/uvm_init.c:1.55 src/sys/uvm/uvm_init.c:1.56 --- src/sys/uvm/uvm_init.c:1.55 Wed Nov 4 01:30:19 2020 +++ src/sys/uvm/uvm_init.c Mon Jul 17 12:55:37 2023 @@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_init.c,v #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); } Index: src/sys/uvm/uvm_page.c diff -u src/sys/uvm/uvm_page.c:1.252 src/sys/uvm/uvm_page.c:1.253 --- src/sys/uvm/uvm_page.c:1.252 Sun Apr 9 09:00:56 2023 +++ src/sys/uvm/uvm_page.c Mon Jul 17 12:55:37 2023 @@ -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); } /* Added files: Index: src/sys/uvm/uvm_rndsource.h diff -u /dev/null src/sys/uvm/uvm_rndsource.h:1.1 --- /dev/null Mon Jul 17 12:55:38 2023 +++ src/sys/uvm/uvm_rndsource.h Mon Jul 17 12:55:37 2023 @@ -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 */