From 5ff5b9d14529e850b6e4803b9406dadc4bdce361 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 9 Jun 2006 18:39:28 +0000 Subject: [PATCH] [SIGAR-6] Use rounding for mem.ram on Linux rather than /proc/mtrr --- ChangeLog | 2 ++ src/os/linux/linux_sigar.c | 57 +------------------------------------- 2 files changed, 3 insertions(+), 56 deletions(-) diff --git a/ChangeLog b/ChangeLog index a6b0ce22..4b14fe42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2006-06-09 Doug MacEachern + * [SIGAR-6] Use rounding for mem.ram on Linux rather than /proc/mtrr + * [SIGAR-5] Fix netinfo default gateway where the first gateway in the routing table had been selected without checking for the default destination == 0.0.0.0 diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 520b008d..55b93baa 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -258,58 +258,6 @@ static int is_ht_enabled(sigar_t *sigar) return sigar->ht_enabled; } -static int get_ram(sigar_t *sigar, sigar_mem_t *mem) -{ - char buffer[BUFSIZ], *ptr; - FILE *fp; - int total = 0; - - if (sigar->ram > 0) { - /* return cached value */ - mem->ram = sigar->ram; - return SIGAR_OK; - } - - if (sigar->ram == 0) { - return ENOENT; - } - - /* - * Memory Type Range Registers - * write-back registers add up to the total. - */ - if (!(fp = fopen("/proc/mtrr", "r"))) { - return errno; - } - - while ((ptr = fgets(buffer, sizeof(buffer), fp))) { - if (!(ptr = strstr(ptr, "size="))) { - continue; - } - - if (!strstr(ptr, "write-back")) { - continue; - } - - ptr += 5; - while (sigar_isspace(*ptr)) { - ++ptr; - } - - total += atoi(ptr); - } - - fclose(fp); - - if (total == 0) { - return ENOENT; - } - - mem->ram = sigar->ram = total; - - return SIGAR_OK; -} - #define MEMINFO_PARAM(a) a ":", SSTRLEN(a ":") static SIGAR_INLINE sigar_uint64_t sigar_meminfo(char *buffer, @@ -360,10 +308,7 @@ int sigar_mem_get(sigar_t *sigar, sigar_mem_t *mem) mem->shared = SIGAR_FIELD_NOTIMPL; /* XXX where did this go in 2.6?? */ - if (get_ram(sigar, mem) != SIGAR_OK) { - /* XXX other options on failure? */ - sigar_mem_calc_ram(sigar, mem); - } + sigar_mem_calc_ram(sigar, mem); return SIGAR_OK; }