Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/puffs Make sure pagedaemon does not sleep for memory ...
details: https://anonhg.NetBSD.org/src/rev/bbc9eef13b6f
branches: trunk
changeset: 770477:bbc9eef13b6f
user: manu <manu%NetBSD.org@localhost>
date: Tue Oct 18 15:39:09 2011 +0000
description:
Make sure pagedaemon does not sleep for memory in puffs_vnop_sleep.
Add KASSERT on any sleeping memory allocation to check it cannot happen again.
diffstat:
sys/fs/puffs/puffs_msgif.c | 20 ++++++++++++++++++--
sys/fs/puffs/puffs_node.c | 10 ++++++++--
sys/fs/puffs/puffs_vfsops.c | 12 ++++++++++--
sys/fs/puffs/puffs_vnops.c | 18 ++++++++++++++----
4 files changed, 50 insertions(+), 10 deletions(-)
diffs (226 lines):
diff -r 27161994419b -r bbc9eef13b6f sys/fs/puffs/puffs_msgif.c
--- a/sys/fs/puffs/puffs_msgif.c Tue Oct 18 14:25:06 2011 +0000
+++ b/sys/fs/puffs/puffs_msgif.c Tue Oct 18 15:39:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_msgif.c,v 1.87 2011/07/03 08:57:43 mrg Exp $ */
+/* $NetBSD: puffs_msgif.c,v 1.88 2011/10/18 15:39:09 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.87 2011/07/03 08:57:43 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_msgif.c,v 1.88 2011/10/18 15:39:09 manu Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -44,6 +44,8 @@
#include <sys/vnode.h>
#include <sys/atomic.h>
+#include <uvm/uvm.h>
+
#include <dev/putter/putter_sys.h>
#include <fs/puffs/puffs_msgif.h>
@@ -132,6 +134,10 @@
{
struct puffs_msgpark *park;
+#ifdef DIAGNOSTIC
+ if (curlwp == uvm.pagedaemon_lwp)
+ KASSERT(!waitok);
+#endif
park = pool_cache_get(parkpc, waitok ? PR_WAITOK : PR_NOWAIT);
if (park == NULL)
return park;
@@ -232,6 +238,10 @@
struct puffs_msgpark *park;
void *m;
+#ifdef DIAGNOSTIC
+ if (curlwp == uvm.pagedaemon_lwp)
+ KASSERT(!cansleep);
+#endif
m = kmem_zalloc(len, cansleep ? KM_SLEEP : KM_NOSLEEP);
if (m == NULL) {
KASSERT(cansleep == 0);
@@ -950,6 +960,9 @@
}
pf = (struct puffs_flush *)preq;
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
psopr = kmem_alloc(sizeof(*psopr), KM_SLEEP);
memcpy(&psopr->psopr_pf, pf, sizeof(*pf));
psopr->psopr_sopreq = PUFFS_SOPREQ_FLUSH;
@@ -973,6 +986,9 @@
DPRINTF(("dispatch: unmount 0x%x\n", preq->preq_optype));
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
psopr = kmem_alloc(sizeof(*psopr), KM_SLEEP);
psopr->psopr_preq = *preq;
psopr->psopr_sopreq = PUFFS_SOPREQ_UNMOUNT;
diff -r 27161994419b -r bbc9eef13b6f sys/fs/puffs/puffs_node.c
--- a/sys/fs/puffs/puffs_node.c Tue Oct 18 14:25:06 2011 +0000
+++ b/sys/fs/puffs/puffs_node.c Tue Oct 18 15:39:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_node.c,v 1.20 2011/08/29 04:12:45 manu Exp $ */
+/* $NetBSD: puffs_node.c,v 1.21 2011/10/18 15:39:09 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.20 2011/08/29 04:12:45 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_node.c,v 1.21 2011/10/18 15:39:09 manu Exp $");
#include <sys/param.h>
#include <sys/hash.h>
@@ -40,6 +40,8 @@
#include <sys/namei.h>
#include <sys/vnode.h>
+#include <uvm/uvm.h>
+
#include <fs/puffs/puffs_msgif.h>
#include <fs/puffs/puffs_sys.h>
@@ -228,6 +230,10 @@
return EPROTO;
}
}
+
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
pnc = kmem_alloc(sizeof(struct puffs_newcookie), KM_SLEEP);
pnc->pnc_cookie = ck;
LIST_INSERT_HEAD(&pmp->pmp_newcookie, pnc, pnc_entries);
diff -r 27161994419b -r bbc9eef13b6f sys/fs/puffs/puffs_vfsops.c
--- a/sys/fs/puffs/puffs_vfsops.c Tue Oct 18 14:25:06 2011 +0000
+++ b/sys/fs/puffs/puffs_vfsops.c Tue Oct 18 15:39:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vfsops.c,v 1.98 2011/10/07 09:35:05 hannken Exp $ */
+/* $NetBSD: puffs_vfsops.c,v 1.99 2011/10/18 15:39:09 manu Exp $ */
/*
* Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.98 2011/10/07 09:35:05 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vfsops.c,v 1.99 2011/10/18 15:39:09 manu Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -44,6 +44,8 @@
#include <sys/module.h>
#include <sys/kthread.h>
+#include <uvm/uvm.h>
+
#include <dev/putter/putter_sys.h>
#include <miscfs/genfs/genfs.h>
@@ -233,6 +235,9 @@
copy_statvfs_info(&args->pa_svfsb, mp);
(void)memcpy(&mp->mnt_stat, &args->pa_svfsb, sizeof(mp->mnt_stat));
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
pmp = kmem_zalloc(sizeof(struct puffs_mount), KM_SLEEP);
mp->mnt_fs_bshift = DEV_BSHIFT;
@@ -414,6 +419,9 @@
* Release kernel thread now that there is nothing
* it would be wanting to lock.
*/
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
psopr = kmem_alloc(sizeof(*psopr), KM_SLEEP);
psopr->psopr_sopreq = PUFFS_SOPREQSYS_EXIT;
mutex_enter(&pmp->pmp_sopmtx);
diff -r 27161994419b -r bbc9eef13b6f sys/fs/puffs/puffs_vnops.c
--- a/sys/fs/puffs/puffs_vnops.c Tue Oct 18 14:25:06 2011 +0000
+++ b/sys/fs/puffs/puffs_vnops.c Tue Oct 18 15:39:09 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: puffs_vnops.c,v 1.158 2011/10/17 23:54:01 manu Exp $ */
+/* $NetBSD: puffs_vnops.c,v 1.159 2011/10/18 15:39:09 manu Exp $ */
/*
* Copyright (c) 2005, 2006, 2007 Antti Kantee. All Rights Reserved.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.158 2011/10/17 23:54:01 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: puffs_vnops.c,v 1.159 2011/10/18 15:39:09 manu Exp $");
#include <sys/param.h>
#include <sys/buf.h>
@@ -1243,6 +1243,9 @@
/* provide cookies to caller if so desired */
if (ap->a_cookies) {
+#ifdef DIAGNOSTIC
+ KASSERT(curlwp != uvm.pagedaemon_lwp);
+#endif
*ap->a_cookies = malloc(readdir_msg->pvnr_ncookies*CSIZE,
M_TEMP, M_WAITOK);
*ap->a_ncookies = readdir_msg->pvnr_ncookies;
@@ -2217,12 +2220,13 @@
struct buf *bp;
size_t argsize;
size_t tomove, moved;
- int error, dofaf, dobiodone;
+ int error, dofaf, cansleep, dobiodone;
pmp = MPTOPUFFSMP(vp->v_mount);
bp = ap->a_bp;
error = 0;
dofaf = 0;
+ cansleep = 0;
pn = VPTOPP(vp);
park_rw = NULL; /* explicit */
dobiodone = 1;
@@ -2262,6 +2266,8 @@
mutex_exit(vp->v_interlock);
}
+ cansleep = (curlwp == uvm.pagedaemon_lwp || dofaf) ? 0 : 1;
+
#ifdef DIAGNOSTIC
if (curlwp == uvm.pagedaemon_lwp)
KASSERT(dofaf || BIOASYNC(bp));
@@ -2271,7 +2277,7 @@
tomove = PUFFS_TOMOVE(bp->b_bcount, pmp);
argsize = sizeof(struct puffs_vnmsg_rw);
error = puffs_msgmem_alloc(argsize + tomove, &park_rw,
- (void *)&rw_msg, dofaf);
+ (void *)&rw_msg, cansleep);
if (error)
goto out;
RWARGS(rw_msg, 0, tomove, bp->b_blkno << DEV_BSHIFT, FSCRED);
@@ -2531,6 +2537,10 @@
#ifdef notnowjohn
/* allocate worst-case memory */
runsizes = ((npages / 2) + 1) * sizeof(struct puffs_cacherun);
+#ifdef DIAGNOSTIC
+ if (curlwp == uvm.pagedaemon_lwp)
+ KASSERT(locked);
+#endif
pcinfo = kmem_zalloc(sizeof(struct puffs_cacheinfo) + runsize,
locked ? KM_NOSLEEP : KM_SLEEP);
Home |
Main Index |
Thread Index |
Old Index