diff options
author | Noam Preil <noam@pixelhero.dev> | 2021-06-21 03:52:09 +0000 |
---|---|---|
committer | Noam Preil <noam@pixelhero.dev> | 2021-06-21 03:52:09 +0000 |
commit | e7715ce2c669fd4ac95dec7851c71136aeb0053f (patch) | |
tree | 1489fda7a57a704660e00a9d25fbf3fc58e3e7e7 | |
parent | a22697039dfb531634f084e28517e60c766fa9dd (diff) | |
download | plan9front-e7715ce2c669fd4ac95dec7851c71136aeb0053f.tar.xz |
venti: fix detection of available RAM (fixes -m)
-rwxr-xr-x | sys/src/cmd/venti/srv/venti.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/sys/src/cmd/venti/srv/venti.c b/sys/src/cmd/venti/srv/venti.c index 6b02efa6f..fd0ff5c07 100755 --- a/sys/src/cmd/venti/srv/venti.c +++ b/sys/src/cmd/venti/srv/venti.c @@ -35,7 +35,7 @@ freemem(void) Biobuf *bp; size = 64*1024*1024; - bp = Bopen("#c/swap", OREAD); + bp = Bopen("/dev/swap", OREAD); if (bp != nil) { while ((ln = Brdline(bp, '\n')) != nil) { ln[Blinelen(bp)-1] = '\0'; @@ -57,8 +57,17 @@ freemem(void) size = (userpgs - userused) * pgsize; } /* cap it to keep the size within 32 bits */ - if (size >= 3840UL * 1024 * 1024) + if (size >= 3840UL * 1024 * 1024){ size = 3840UL * 1024 * 1024; + fprint(2, "%s: Reduced free memory detected to 3840MiB because we don't support 64-bit addresses yet.\n", argv0); + } + /* FIXME: we use signed 32-bit integers in some places for some fucking reason. + Limiting accordingly for now. + */ + if (size >= 2047UL * 1024 * 1024){ + size = 2047UL * 1024 * 1024; + fprint(2, "%s: Reduced free memory detected to 2047MiB because we have bugz.\n", argv0); + } return size; } @@ -97,9 +106,9 @@ allocbypcnt(u32int mempcnt, u32int stfree) fprint(2, "%s: bloom filter bigger than mem pcnt; " "resorting to minimum values (9MB total)\n", argv0); else { - if (avail >= 3840UL * 1024 * 1024){ - avail = 3840UL * 1024 * 1024; /* sanity */ - fprint(2, "%s: restricting memory usage to 3840MiB\n", argv0); + if (avail >= 2047UL * 1024 * 1024){ + avail = 2047UL * 1024 * 1024; /* sanity */ + fprint(2, "%s: restricting memory usage to 2047MiB\n", argv0); } avail /= 2; all.icmem = avail; |