Module Name:    src
Committed By:   pooka
Date:           Mon Mar  3 16:50:28 UTC 2014

Modified Files:
        src/sys/rump/librump/rumpkern: vm.c

Log Message:
Fix the memory limiter to work for non-pagedaemon threads again

reported by njoly


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/sys/rump/librump/rumpkern/vm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/vm.c
diff -u src/sys/rump/librump/rumpkern/vm.c:1.149 src/sys/rump/librump/rumpkern/vm.c:1.150
--- src/sys/rump/librump/rumpkern/vm.c:1.149	Tue Feb 18 06:18:13 2014
+++ src/sys/rump/librump/rumpkern/vm.c	Mon Mar  3 16:50:28 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: vm.c,v 1.149 2014/02/18 06:18:13 pooka Exp $	*/
+/*	$NetBSD: vm.c,v 1.150 2014/03/03 16:50:28 pooka 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.149 2014/02/18 06:18:13 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.150 2014/03/03 16:50:28 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -1158,6 +1158,8 @@ uvm_kick_pdaemon()
 void *
 rump_hypermalloc(size_t howmuch, int alignment, bool waitok, const char *wmsg)
 {
+	const unsigned long thelimit =
+	    curlwp == uvm.pagedaemon_lwp ? pdlimit : rump_physmemlimit;
 	unsigned long newmem;
 	void *rv;
 	int error;
@@ -1166,10 +1168,9 @@ rump_hypermalloc(size_t howmuch, int ali
 
 	/* first we must be within the limit */
  limitagain:
-	if (rump_physmemlimit != RUMPMEM_UNLIMITED) {
+	if (thelimit != RUMPMEM_UNLIMITED) {
 		newmem = atomic_add_long_nv(&curphysmem, howmuch);
-		if ((newmem > rump_physmemlimit) &&
-		    !(curlwp == uvm.pagedaemon_lwp || newmem > pdlimit)) {
+		if (newmem > thelimit) {
 			newmem = atomic_add_long_nv(&curphysmem, -howmuch);
 			if (!waitok) {
 				return NULL;

Reply via email to