Thu Apr 23 21:53:01 2020 UTC ()
Enable ubc_direct by default, but only on systems with no more than 2 CPUs
for now.


(ad)
diff -r1.110 -r1.111 src/sys/uvm/uvm_bio.c
diff -r1.177 -r1.178 src/sys/uvm/uvm_glue.c

cvs diff -r1.110 -r1.111 src/sys/uvm/uvm_bio.c (expand / switch to unified diff)

--- src/sys/uvm/uvm_bio.c 2020/04/23 21:47:09 1.110
+++ src/sys/uvm/uvm_bio.c 2020/04/23 21:53:01 1.111
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad Exp $ */ 1/* $NetBSD: uvm_bio.c,v 1.111 2020/04/23 21:53:01 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1998 Chuck Silvers. 4 * Copyright (c) 1998 Chuck Silvers.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE. 28 * SUCH DAMAGE.
29 * 29 *
30 */ 30 */
31 31
32/* 32/*
33 * uvm_bio.c: buffered i/o object mapping cache 33 * uvm_bio.c: buffered i/o object mapping cache
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.110 2020/04/23 21:47:09 ad Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.111 2020/04/23 21:53:01 ad Exp $");
38 38
39#include "opt_uvmhist.h" 39#include "opt_uvmhist.h"
40#include "opt_ubc.h" 40#include "opt_ubc.h"
41 41
42#include <sys/param.h> 42#include <sys/param.h>
43#include <sys/systm.h> 43#include <sys/systm.h>
44#include <sys/kmem.h> 44#include <sys/kmem.h>
45#include <sys/kernel.h> 45#include <sys/kernel.h>
46#include <sys/proc.h> 46#include <sys/proc.h>
47#include <sys/vnode.h> 47#include <sys/vnode.h>
48 48
49#include <uvm/uvm.h> 49#include <uvm/uvm.h>
50 50
@@ -54,27 +54,27 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v  @@ -54,27 +54,27 @@ __KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v
54 54
55/* 55/*
56 * local functions 56 * local functions
57 */ 57 */
58 58
59static int ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **, 59static int ubc_fault(struct uvm_faultinfo *, vaddr_t, struct vm_page **,
60 int, int, vm_prot_t, int); 60 int, int, vm_prot_t, int);
61static struct ubc_map *ubc_find_mapping(struct uvm_object *, voff_t); 61static struct ubc_map *ubc_find_mapping(struct uvm_object *, voff_t);
62#ifdef UBC_USE_PMAP_DIRECT 62#ifdef UBC_USE_PMAP_DIRECT
63static int __noinline ubc_uiomove_direct(struct uvm_object *, struct uio *, vsize_t, 63static int __noinline ubc_uiomove_direct(struct uvm_object *, struct uio *, vsize_t,
64 int, int); 64 int, int);
65static void __noinline ubc_zerorange_direct(struct uvm_object *, off_t, size_t, int); 65static void __noinline ubc_zerorange_direct(struct uvm_object *, off_t, size_t, int);
66 66
67bool ubc_direct = false; /* XXX */ 67bool ubc_direct = true;
68#endif 68#endif
69 69
70/* 70/*
71 * local data structues 71 * local data structues
72 */ 72 */
73 73
74#define UBC_HASH(uobj, offset) \ 74#define UBC_HASH(uobj, offset) \
75 (((((u_long)(uobj)) >> 8) + (((u_long)(offset)) >> PAGE_SHIFT)) & \ 75 (((((u_long)(uobj)) >> 8) + (((u_long)(offset)) >> PAGE_SHIFT)) & \
76 ubc_object.hashmask) 76 ubc_object.hashmask)
77 77
78#define UBC_QUEUE(offset) \ 78#define UBC_QUEUE(offset) \
79 (&ubc_object.inactive[(((u_long)(offset)) >> ubc_winshift) & \ 79 (&ubc_object.inactive[(((u_long)(offset)) >> ubc_winshift) & \
80 (UBC_NQUEUES - 1)]) 80 (UBC_NQUEUES - 1)])

cvs diff -r1.177 -r1.178 src/sys/uvm/uvm_glue.c (expand / switch to unified diff)

--- src/sys/uvm/uvm_glue.c 2020/03/05 12:21:00 1.177
+++ src/sys/uvm/uvm_glue.c 2020/04/23 21:53:01 1.178
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: uvm_glue.c,v 1.177 2020/03/05 12:21:00 rin Exp $ */ 1/* $NetBSD: uvm_glue.c,v 1.178 2020/04/23 21:53:01 ad Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1997 Charles D. Cranor and Washington University. 4 * Copyright (c) 1997 Charles D. Cranor and Washington University.
5 * Copyright (c) 1991, 1993, The Regents of the University of California. 5 * Copyright (c) 1991, 1993, The Regents of the University of California.
6 * 6 *
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * This code is derived from software contributed to Berkeley by 9 * This code is derived from software contributed to Berkeley by
10 * The Mach Operating System project at Carnegie-Mellon University. 10 * The Mach Operating System project at Carnegie-Mellon University.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -52,27 +52,27 @@ @@ -52,27 +52,27 @@
52 * 52 *
53 * Carnegie Mellon requests users of this software to return to 53 * Carnegie Mellon requests users of this software to return to
54 * 54 *
55 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU 55 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
56 * School of Computer Science 56 * School of Computer Science
57 * Carnegie Mellon University 57 * Carnegie Mellon University
58 * Pittsburgh PA 15213-3890 58 * Pittsburgh PA 15213-3890
59 * 59 *
60 * any improvements or extensions that they make and grant Carnegie the 60 * any improvements or extensions that they make and grant Carnegie the
61 * rights to redistribute these changes. 61 * rights to redistribute these changes.
62 */ 62 */
63 63
64#include <sys/cdefs.h> 64#include <sys/cdefs.h>
65__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.177 2020/03/05 12:21:00 rin Exp $"); 65__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.178 2020/04/23 21:53:01 ad Exp $");
66 66
67#include "opt_kgdb.h" 67#include "opt_kgdb.h"
68#include "opt_kstack.h" 68#include "opt_kstack.h"
69#include "opt_uvmhist.h" 69#include "opt_uvmhist.h"
70 70
71/* 71/*
72 * uvm_glue.c: glue functions 72 * uvm_glue.c: glue functions
73 */ 73 */
74 74
75#include <sys/param.h> 75#include <sys/param.h>
76#include <sys/kernel.h> 76#include <sys/kernel.h>
77 77
78#include <sys/systm.h> 78#include <sys/systm.h>
@@ -494,26 +494,38 @@ extern struct loadavg averunnable; @@ -494,26 +494,38 @@ extern struct loadavg averunnable;
494void 494void
495uvm_scheduler(void) 495uvm_scheduler(void)
496{ 496{
497 lwp_t *l = curlwp; 497 lwp_t *l = curlwp;
498 498
499 lwp_lock(l); 499 lwp_lock(l);
500 l->l_class = SCHED_FIFO; 500 l->l_class = SCHED_FIFO;
501 lwp_changepri(l, PRI_VM); 501 lwp_changepri(l, PRI_VM);
502 lwp_unlock(l); 502 lwp_unlock(l);
503 503
504 /* Start the freelist cache. */ 504 /* Start the freelist cache. */
505 uvm_pgflcache_start(); 505 uvm_pgflcache_start();
506 506
 507#ifdef PMAP_DIRECT
 508 /*
 509 * XXX Temporary ugly hack. Just before boot, disable ubc_direct if
 510 * there's more than a couple of CPUs, since it has concurrency
 511 * problems.
 512 */
 513 if (ncpu > 2) {
 514 extern bool ubc_direct;
 515 ubc_direct = false;
 516 }
 517#endif
 518
507 for (;;) { 519 for (;;) {
508 /* Update legacy stats for post-mortem debugging. */ 520 /* Update legacy stats for post-mortem debugging. */
509 uvm_update_uvmexp(); 521 uvm_update_uvmexp();
510 522
511 /* See if the pagedaemon needs to generate some free pages. */ 523 /* See if the pagedaemon needs to generate some free pages. */
512 uvm_kick_pdaemon(); 524 uvm_kick_pdaemon();
513 525
514 /* Calculate process statistics. */ 526 /* Calculate process statistics. */
515 sched_pstats(); 527 sched_pstats();
516 (void)kpause("uvm", false, hz, NULL); 528 (void)kpause("uvm", false, hz, NULL);
517 } 529 }
518} 530}
519 531