Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Now that pool_cache_invalidate() is synchronous and can hand...
details: https://anonhg.NetBSD.org/src/rev/757a386b3e07
branches: trunk
changeset: 779623:757a386b3e07
user: jym <jym%NetBSD.org@localhost>
date: Tue Jun 05 22:51:47 2012 +0000
description:
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
diffstat:
external/cddl/osnet/sys/kern/misc.c | 13 ++-------
sys/kern/subr_pool.c | 46 ++++++++---------------------------
sys/rump/librump/rumpkern/memalloc.c | 13 ++-------
sys/rump/librump/rumpkern/vm.c | 23 +++++++----------
sys/sys/pool.h | 5 +--
sys/uvm/uvm_pdaemon.c | 15 +++--------
6 files changed, 32 insertions(+), 83 deletions(-)
diffs (294 lines):
diff -r 9b009b7ef2ac -r 757a386b3e07 external/cddl/osnet/sys/kern/misc.c
--- a/external/cddl/osnet/sys/kern/misc.c Tue Jun 05 22:46:54 2012 +0000
+++ b/external/cddl/osnet/sys/kern/misc.c Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
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 @@
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");
}
diff -r 9b009b7ef2ac -r 757a386b3e07 sys/kern/subr_pool.c
--- a/sys/kern/subr_pool.c Tue Jun 05 22:46:54 2012 +0000
+++ b/sys/kern/subr_pool.c Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
/*
* 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 @@
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 @@
}
/*
- * 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 @@
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 @@
cv_broadcast(&pool_busy);
mutex_exit(&pool_head_lock);
+ if (ppp != NULL)
+ *ppp = pp;
+
return reclaimed;
}
diff -r 9b009b7ef2ac -r 757a386b3e07 sys/rump/librump/rumpkern/memalloc.c
--- a/sys/rump/librump/rumpkern/memalloc.c Tue Jun 05 22:46:54 2012 +0000
+++ b/sys/rump/librump/rumpkern/memalloc.c Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
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 */
diff -r 9b009b7ef2ac -r 757a386b3e07 sys/rump/librump/rumpkern/vm.c
--- a/sys/rump/librump/rumpkern/vm.c Tue Jun 05 22:46:54 2012 +0000
+++ b/sys/rump/librump/rumpkern/vm.c Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
{
struct vm_page *pg;
struct pool *pp, *pp_first;
- uint64_t where;
int cleaned, skip, skipped;
int waspaging;
bool succ;
@@ -1094,19 +1093,15 @@
/*
* 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)
+
+ succ = pool_drain(&pp);
+ if (succ || pp == pp_first)
break;
- pool_drain_start(&pp, &where);
- if (pp == pp_first) {
- succ = pool_drain_end(pp, where);
- break;
- }
+
+ if (pp_first == NULL)
+ pp_first = pp;
}
/*
diff -r 9b009b7ef2ac -r 757a386b3e07 sys/sys/pool.h
--- a/sys/sys/pool.h Tue Jun 05 22:46:54 2012 +0000
+++ b/sys/sys/pool.h Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
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.
diff -r 9b009b7ef2ac -r 757a386b3e07 sys/uvm/uvm_pdaemon.c
--- a/sys/uvm/uvm_pdaemon.c Tue Jun 05 22:46:54 2012 +0000
+++ b/sys/uvm/uvm_pdaemon.c Tue Jun 05 22:51:47 2012 +0000
@@ -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 @@
int bufcnt, npages = 0;
int extrapages = 0;
struct pool *pp;
- uint64_t where;
UVMHIST_FUNC("uvm_pageout"); UVMHIST_CALLED(pdhist);
@@ -328,12 +327,6 @@
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 @@
mutex_exit(&bufcache_lock);
/*
- * complete draining the pools.
+ * drain the pools.
*/
- pool_drain_end(pp, where);
+ pool_drain(&pp);
}
/*NOTREACHED*/
}
Home |
Main Index |
Thread Index |
Old Index