From 541fe6b3959f9dab857b400f33d622b20eb42fa4 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Tue, 13 Jun 2006 17:59:58 +0000 Subject: [PATCH] only punt mtrr write-back if way off from MemTotal --- src/os/linux/linux_sigar.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 791bb6ee..1eb5ae19 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -264,6 +264,7 @@ static int get_ram(sigar_t *sigar, sigar_mem_t *mem) char buffer[BUFSIZ], *ptr; FILE *fp; int total = 0; + sigar_uint64_t sys_total = (mem->total / (1024 * 1024)); if (sigar->ram > 0) { /* return cached value */ @@ -295,26 +296,27 @@ static int get_ram(sigar_t *sigar, sigar_mem_t *mem) continue; } - if (total) { - /* punt if there is more than 1 write-back register */ - total = 0; - break; - } - ptr += 5; while (sigar_isspace(*ptr)) { ++ptr; } - total = atoi(ptr); + total += atoi(ptr); } 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) { return ENOENT; } - + mem->ram = sigar->ram = total; return SIGAR_OK;