Module Name: src Committed By: jym Date: Tue Jun 5 22:51:47 UTC 2012
Modified Files: src/external/cddl/osnet/sys/kern: misc.c src/sys/kern: subr_pool.c src/sys/rump/librump/rumpkern: memalloc.c vm.c src/sys/sys: pool.h src/sys/uvm: uvm_pdaemon.c Log Message: Now that pool_cache_invalidate() is synchronous and can handle per-CPU caches, merge together pool_drain_start() and pool_drain_end() into bool pool_drain(struct pool **ppp); "bool" value indicates whether reclaiming was fully done (true) or not (false) "ppp" will contain a pointer to the pool that was drained (optional). See http://mail-index.netbsd.org/tech-kern/2012/06/04/msg013287.html To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/external/cddl/osnet/sys/kern/misc.c cvs rdiff -u -r1.196 -r1.197 src/sys/kern/subr_pool.c cvs rdiff -u -r1.15 -r1.16 src/sys/rump/librump/rumpkern/memalloc.c cvs rdiff -u -r1.126 -r1.127 src/sys/rump/librump/rumpkern/vm.c cvs rdiff -u -r1.74 -r1.75 src/sys/sys/pool.h cvs rdiff -u -r1.105 -r1.106 src/sys/uvm/uvm_pdaemon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/external/cddl/osnet/sys/kern/misc.c diff -u src/external/cddl/osnet/sys/kern/misc.c:1.3 src/external/cddl/osnet/sys/kern/misc.c:1.4 --- src/external/cddl/osnet/sys/kern/misc.c:1.3 Thu Mar 10 19:35:24 2011 +++ src/external/cddl/osnet/sys/kern/misc.c Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: misc.c,v 1.3 2011/03/10 19:35:24 pooka Exp $ */ +/* $NetBSD: misc.c,v 1.4 2012/06/05 22:51:47 jym Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -133,15 +133,8 @@ void kmem_reap(void) { int bufcnt; - uint64_t where; struct pool *pp; - /* - * start draining pool resources now that we're not - * holding any locks. - */ - pool_drain_start(&pp, &where); - bufcnt = uvmexp.freetarg - uvmexp.free; if (bufcnt < 0) bufcnt = 0; @@ -153,9 +146,9 @@ kmem_reap(void) mutex_exit(&bufcache_lock); /* - * complete draining the pools. + * drain the pools. */ - pool_drain_end(pp, where); + pool_drain(&pp); // printf("XXXNETBSD kmem_reap called, write me\n"); } Index: src/sys/kern/subr_pool.c diff -u src/sys/kern/subr_pool.c:1.196 src/sys/kern/subr_pool.c:1.197 --- src/sys/kern/subr_pool.c:1.196 Tue Jun 5 22:28:11 2012 +++ src/sys/kern/subr_pool.c Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $ */ +/* $NetBSD: subr_pool.c,v 1.197 2012/06/05 22:51:47 jym Exp $ */ /*- * Copyright (c) 1997, 1999, 2000, 2002, 2007, 2008, 2010 @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.196 2012/06/05 22:28:11 jym Exp $"); +__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.197 2012/06/05 22:51:47 jym Exp $"); #include "opt_ddb.h" #include "opt_lockdebug.h" @@ -1300,7 +1300,7 @@ pool_sethardlimit(struct pool *pp, int n /* * Release all complete pages that have not been used recently. * - * Might be called from interrupt context. + * Must not be called from interrupt context. */ int pool_reclaim(struct pool *pp) @@ -1311,9 +1311,7 @@ pool_reclaim(struct pool *pp) bool klock; int rv; - if (cpu_intr_p() || cpu_softintr_p()) { - KASSERT(pp->pr_ipl != IPL_NONE); - } + KASSERT(!cpu_intr_p() && !cpu_softintr_p()); if (pp->pr_drain_hook != NULL) { /* @@ -1387,17 +1385,14 @@ pool_reclaim(struct pool *pp) } /* - * Drain pools, one at a time. This is a two stage process; - * drain_start kicks off a cross call to drain CPU-level caches - * if the pool has an associated pool_cache. drain_end waits - * for those cross calls to finish, and then drains the cache - * (if any) and pool. + * Drain pools, one at a time. The drained pool is returned within ppp. * * Note, must never be called from interrupt context. */ -void -pool_drain_start(struct pool **ppp, uint64_t *wp) +bool +pool_drain(struct pool **ppp) { + bool reclaimed; struct pool *pp; KASSERT(!TAILQ_EMPTY(&pool_head)); @@ -1422,28 +1417,6 @@ pool_drain_start(struct pool **ppp, uint pp->pr_refcnt++; mutex_exit(&pool_head_lock); - /* If there is a pool_cache, drain CPU level caches. */ - *ppp = pp; - if (pp->pr_cache != NULL) { - *wp = xc_broadcast(0, (xcfunc_t)pool_cache_transfer, - pp->pr_cache, NULL); - } -} - -bool -pool_drain_end(struct pool *pp, uint64_t where) -{ - bool reclaimed; - - if (pp == NULL) - return false; - - KASSERT(pp->pr_refcnt > 0); - - /* Wait for remote draining to complete. */ - if (pp->pr_cache != NULL) - xc_wait(where); - /* Drain the cache (if any) and pool.. */ reclaimed = pool_reclaim(pp); @@ -1453,6 +1426,9 @@ pool_drain_end(struct pool *pp, uint64_t cv_broadcast(&pool_busy); mutex_exit(&pool_head_lock); + if (ppp != NULL) + *ppp = pp; + return reclaimed; } Index: src/sys/rump/librump/rumpkern/memalloc.c diff -u src/sys/rump/librump/rumpkern/memalloc.c:1.15 src/sys/rump/librump/rumpkern/memalloc.c:1.16 --- src/sys/rump/librump/rumpkern/memalloc.c:1.15 Sun Apr 29 20:27:32 2012 +++ src/sys/rump/librump/rumpkern/memalloc.c Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: memalloc.c,v 1.15 2012/04/29 20:27:32 dsl Exp $ */ +/* $NetBSD: memalloc.c,v 1.16 2012/06/05 22:51:47 jym Exp $ */ /* * Copyright (c) 2009 Antti Kantee. All Rights Reserved. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.15 2012/04/29 20:27:32 dsl Exp $"); +__KERNEL_RCSID(0, "$NetBSD: memalloc.c,v 1.16 2012/06/05 22:51:47 jym Exp $"); #include <sys/param.h> #include <sys/kmem.h> @@ -285,15 +285,8 @@ pool_cache_set_drain_hook(pool_cache_t p pc->pc_pool.pr_drain_hook_arg = arg; } -void -pool_drain_start(struct pool **ppp, uint64_t *wp) -{ - - /* nada */ -} - bool -pool_drain_end(struct pool *pp, uint64_t w) +pool_drain(struct pool **ppp) { /* can't reclaim anything in this model */ Index: src/sys/rump/librump/rumpkern/vm.c diff -u src/sys/rump/librump/rumpkern/vm.c:1.126 src/sys/rump/librump/rumpkern/vm.c:1.127 --- src/sys/rump/librump/rumpkern/vm.c:1.126 Wed May 23 14:59:21 2012 +++ src/sys/rump/librump/rumpkern/vm.c Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vm.c,v 1.126 2012/05/23 14:59:21 martin Exp $ */ +/* $NetBSD: vm.c,v 1.127 2012/06/05 22:51:47 jym Exp $ */ /* * Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved. @@ -41,7 +41,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.126 2012/05/23 14:59:21 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.127 2012/06/05 22:51:47 jym Exp $"); #include <sys/param.h> #include <sys/atomic.h> @@ -989,7 +989,6 @@ uvm_pageout(void *arg) { struct vm_page *pg; struct pool *pp, *pp_first; - uint64_t where; int cleaned, skip, skipped; int waspaging; bool succ; @@ -1094,19 +1093,15 @@ uvm_pageout(void *arg) /* * And then drain the pools. Wipe them out ... all of them. */ - - pool_drain_start(&pp_first, &where); - pp = pp_first; - for (;;) { + for (pp_first = NULL;;) { rump_vfs_drainbufs(10 /* XXX: estimate better */); - succ = pool_drain_end(pp, where); - if (succ) - break; - pool_drain_start(&pp, &where); - if (pp == pp_first) { - succ = pool_drain_end(pp, where); + + succ = pool_drain(&pp); + if (succ || pp == pp_first) break; - } + + if (pp_first == NULL) + pp_first = pp; } /* Index: src/sys/sys/pool.h diff -u src/sys/sys/pool.h:1.74 src/sys/sys/pool.h:1.75 --- src/sys/sys/pool.h:1.74 Sat May 5 19:15:10 2012 +++ src/sys/sys/pool.h Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: pool.h,v 1.74 2012/05/05 19:15:10 rmind Exp $ */ +/* $NetBSD: pool.h,v 1.75 2012/06/05 22:51:47 jym Exp $ */ /*- * Copyright (c) 1997, 1998, 1999, 2000, 2007 The NetBSD Foundation, Inc. @@ -263,8 +263,7 @@ int pool_prime(struct pool *, int); void pool_setlowat(struct pool *, int); void pool_sethiwat(struct pool *, int); void pool_sethardlimit(struct pool *, int, const char *, int); -void pool_drain_start(struct pool **, uint64_t *); -bool pool_drain_end(struct pool *, uint64_t); +bool pool_drain(struct pool **); /* * Debugging and diagnostic aides. Index: src/sys/uvm/uvm_pdaemon.c diff -u src/sys/uvm/uvm_pdaemon.c:1.105 src/sys/uvm/uvm_pdaemon.c:1.106 --- src/sys/uvm/uvm_pdaemon.c:1.105 Wed Feb 1 23:43:49 2012 +++ src/sys/uvm/uvm_pdaemon.c Tue Jun 5 22:51:47 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_pdaemon.c,v 1.105 2012/02/01 23:43:49 para Exp $ */ +/* $NetBSD: uvm_pdaemon.c,v 1.106 2012/06/05 22:51:47 jym Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.105 2012/02/01 23:43:49 para Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_pdaemon.c,v 1.106 2012/06/05 22:51:47 jym Exp $"); #include "opt_uvmhist.h" #include "opt_readahead.h" @@ -228,7 +228,6 @@ uvm_pageout(void *arg) int bufcnt, npages = 0; int extrapages = 0; struct pool *pp; - uint64_t where; UVMHIST_FUNC("uvm_pageout"); UVMHIST_CALLED(pdhist); @@ -328,12 +327,6 @@ uvm_pageout(void *arg) continue; /* - * start draining pool resources now that we're not - * holding any locks. - */ - pool_drain_start(&pp, &where); - - /* * kill unused metadata buffers. */ mutex_enter(&bufcache_lock); @@ -341,9 +334,9 @@ uvm_pageout(void *arg) mutex_exit(&bufcache_lock); /* - * complete draining the pools. + * drain the pools. */ - pool_drain_end(pp, where); + pool_drain(&pp); } /*NOTREACHED*/ }