Sat Jan 8 09:40:05 2011 UTC ()
Do a minidehumanizenumber for RUMP_MEMLIMIT.  Now you can set it
to e.g. 16m instead of having to type out 16777216.


(pooka)
diff -r1.104 -r1.105 src/sys/rump/librump/rumpkern/vm.c

cvs diff -r1.104 -r1.105 src/sys/rump/librump/rumpkern/vm.c (expand / switch to unified diff)

--- src/sys/rump/librump/rumpkern/vm.c 2010/12/01 20:29:57 1.104
+++ src/sys/rump/librump/rumpkern/vm.c 2011/01/08 09:40:05 1.105
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: vm.c,v 1.104 2010/12/01 20:29:57 pooka Exp $ */ 1/* $NetBSD: vm.c,v 1.105 2011/01/08 09:40:05 pooka Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved. 4 * Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
5 * 5 *
6 * Development of this software was supported by 6 * Development of this software was supported by
7 * The Finnish Cultural Foundation and the Research Foundation of 7 * The Finnish Cultural Foundation and the Research Foundation of
8 * The Helsinki University of Technology. 8 * The Helsinki University of Technology.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -31,27 +31,27 @@ @@ -31,27 +31,27 @@
31 31
32/* 32/*
33 * Virtual memory emulation routines. 33 * Virtual memory emulation routines.
34 */ 34 */
35 35
36/* 36/*
37 * XXX: we abuse pg->uanon for the virtual address of the storage 37 * XXX: we abuse pg->uanon for the virtual address of the storage
38 * for each page. phys_addr would fit the job description better, 38 * for each page. phys_addr would fit the job description better,
39 * except that it will create unnecessary lossage on some platforms 39 * except that it will create unnecessary lossage on some platforms
40 * due to not being a pointer type. 40 * due to not being a pointer type.
41 */ 41 */
42 42
43#include <sys/cdefs.h> 43#include <sys/cdefs.h>
44__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.104 2010/12/01 20:29:57 pooka Exp $"); 44__KERNEL_RCSID(0, "$NetBSD: vm.c,v 1.105 2011/01/08 09:40:05 pooka Exp $");
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/atomic.h> 47#include <sys/atomic.h>
48#include <sys/buf.h> 48#include <sys/buf.h>
49#include <sys/kernel.h> 49#include <sys/kernel.h>
50#include <sys/kmem.h> 50#include <sys/kmem.h>
51#include <sys/mman.h> 51#include <sys/mman.h>
52#include <sys/null.h> 52#include <sys/null.h>
53#include <sys/vnode.h> 53#include <sys/vnode.h>
54 54
55#include <machine/pmap.h> 55#include <machine/pmap.h>
56 56
57#include <rump/rumpuser.h> 57#include <rump/rumpuser.h>
@@ -246,30 +246,59 @@ uvm_pagezero(struct vm_page *pg) @@ -246,30 +246,59 @@ uvm_pagezero(struct vm_page *pg)
246/* 246/*
247 * Misc routines 247 * Misc routines
248 */ 248 */
249 249
250static kmutex_t pagermtx; 250static kmutex_t pagermtx;
251 251
252void 252void
253uvm_init(void) 253uvm_init(void)
254{ 254{
255 char buf[64]; 255 char buf[64];
256 int error; 256 int error;
257 257
258 if (rumpuser_getenv("RUMP_MEMLIMIT", buf, sizeof(buf), &error) == 0) { 258 if (rumpuser_getenv("RUMP_MEMLIMIT", buf, sizeof(buf), &error) == 0) {
259 rump_physmemlimit = strtoll(buf, NULL, 10); 259 unsigned long tmp;
 260 char *ep;
 261 int mult;
 262
 263 tmp = strtoll(buf, &ep, 10);
 264 if (strlen(ep) > 1)
 265 panic("uvm_init: invalid RUMP_MEMLIMIT: %s", buf);
 266
 267 /* mini-dehumanize-number */
 268 mult = 1;
 269 switch (*ep) {
 270 case 'k':
 271 mult = 1024;
 272 break;
 273 case 'm':
 274 mult = 1024*1024;
 275 break;
 276 case 'g':
 277 mult = 1024*1024*1024;
 278 break;
 279 case 0:
 280 break;
 281 default:
 282 panic("uvm_init: invalid RUMP_MEMLIMIT: %s", buf);
 283 }
 284 rump_physmemlimit = tmp * mult;
 285
 286 if (rump_physmemlimit / mult != tmp)
 287 panic("uvm_init: RUMP_MEMLIMIT overflow: %s", buf);
260 /* it's not like we'd get far with, say, 1 byte, but ... */ 288 /* it's not like we'd get far with, say, 1 byte, but ... */
261 if (rump_physmemlimit == 0) 289 if (rump_physmemlimit == 0)
262 panic("uvm_init: no memory available"); 290 panic("uvm_init: no memory");
 291
263#define HUMANIZE_BYTES 9 292#define HUMANIZE_BYTES 9
264 CTASSERT(sizeof(buf) >= HUMANIZE_BYTES); 293 CTASSERT(sizeof(buf) >= HUMANIZE_BYTES);
265 format_bytes(buf, HUMANIZE_BYTES, rump_physmemlimit); 294 format_bytes(buf, HUMANIZE_BYTES, rump_physmemlimit);
266#undef HUMANIZE_BYTES 295#undef HUMANIZE_BYTES
267 dddlim = 9 * (rump_physmemlimit / 10); 296 dddlim = 9 * (rump_physmemlimit / 10);
268 } else { 297 } else {
269 strlcpy(buf, "unlimited (host limit)", sizeof(buf)); 298 strlcpy(buf, "unlimited (host limit)", sizeof(buf));
270 } 299 }
271 aprint_verbose("total memory = %s\n", buf); 300 aprint_verbose("total memory = %s\n", buf);
272 301
273 TAILQ_INIT(&vmpage_lruqueue); 302 TAILQ_INIT(&vmpage_lruqueue);
274 303
275 uvmexp.free = 1024*1024; /* XXX: arbitrary & not updated */ 304 uvmexp.free = 1024*1024; /* XXX: arbitrary & not updated */