only punt mtrr write-back if way off from MemTotal

This commit is contained in:
Doug MacEachern 2006-06-13 17:59:58 +00:00
parent 3ff6042aaf
commit 541fe6b395
1 changed files with 10 additions and 8 deletions

View File

@ -264,6 +264,7 @@ static int get_ram(sigar_t *sigar, sigar_mem_t *mem)
char buffer[BUFSIZ], *ptr; char buffer[BUFSIZ], *ptr;
FILE *fp; FILE *fp;
int total = 0; int total = 0;
sigar_uint64_t sys_total = (mem->total / (1024 * 1024));
if (sigar->ram > 0) { if (sigar->ram > 0) {
/* return cached value */ /* return cached value */
@ -295,22 +296,23 @@ static int get_ram(sigar_t *sigar, sigar_mem_t *mem)
continue; continue;
} }
if (total) {
/* punt if there is more than 1 write-back register */
total = 0;
break;
}
ptr += 5; ptr += 5;
while (sigar_isspace(*ptr)) { while (sigar_isspace(*ptr)) {
++ptr; ++ptr;
} }
total = atoi(ptr); total += atoi(ptr);
} }
fclose(fp); fclose(fp);
if ((total - sys_total) > 256) {
/* mtrr write-back registers are way off
* kernel should not be using more that 256MB of mem
*/
total = 0; /* punt */
}
if (total == 0) { if (total == 0) {
return ENOENT; return ENOENT;
} }