ref: 66aa9490398fa43d1bbec73f0e12899582a73fe7
parent: 712ce5d9fff96a46f51b37a65532022b1a9b833c
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue Apr 15 17:34:41 EDT 2014
kernel: fix printing wrong memory sizes in pageinit(), overflowed on amd64 (thanks aram)
--- a/sys/src/9/port/page.c
+++ b/sys/src/9/port/page.c
@@ -15,7 +15,8 @@
int color, i, j;
Page *p;
Pallocmem *pm;
- ulong m, np, k, vkb, pkb;
+ vlong m, v, u;
+ ulong np;
np = 0;
for(i=0; i<nelem(palloc.mem); i++){
@@ -46,8 +47,8 @@
palloc.tail->next = 0;
palloc.user = p - palloc.pages;
- pkb = palloc.user*BY2PG/1024;
- vkb = pkb + (conf.nswap*BY2PG)/1024;
+ u = palloc.user*BY2PG;
+ v = u + conf.nswap*BY2PG;
/* Paging numbers */
swapalloc.highwater = (palloc.user*5)/100;
@@ -57,11 +58,12 @@
for(i=0; i<nelem(conf.mem); i++)
if(conf.mem[i].npage)
m += conf.mem[i].npage*BY2PG;
- k = PGROUND(end - (char*)KTZERO);
- print("%ldM memory: ", (m+k+1024*1024-1)/(1024*1024));
- print("%ldM kernel data, ", (m+k-pkb*1024+1024*1024-1)/(1024*1024));
- print("%ldM user, ", pkb/1024);
- print("%ldM swap\n", vkb/1024);
+ m += PGROUND(end - (char*)KTZERO);
+
+ print("%lldM memory: ", (m+1024*1024-1)/(1024*1024));
+ print("%lldM kernel data, ", (m-u+1024*1024-1)/(1024*1024));
+ print("%lldM user, ", u/(1024*1024));
+ print("%lldM swap\n", v/(1024*1024));
}
void