diff options
author | Rajeev Kumar <rajekumar@google.com> | 2018-01-31 18:13:46 -0800 |
---|---|---|
committer | Rajeev Kumar <rajekumar@google.com> | 2018-01-31 18:13:46 -0800 |
commit | 2af695c4fad3507bf4dfe86cc64dd6616a8208cf (patch) | |
tree | 991bf16ce5cfa17c2daa856fe8a6f60a636fdedc /lmkd | |
parent | 418f0e982d65febc64b67d9704ebdb239757b99f (diff) | |
download | core-2af695c4fad3507bf4dfe86cc64dd6616a8208cf.tar.gz core-2af695c4fad3507bf4dfe86cc64dd6616a8208cf.tar.bz2 core-2af695c4fad3507bf4dfe86cc64dd6616a8208cf.zip |
Cleanup zoneinfo parsing function.
Usage of this function was removed in http://ag/2402070
Bug: 62626918
Test: Manual
Change-Id: Ib6af945d1005062d4219deae078a415bb7369261
Diffstat (limited to 'lmkd')
-rw-r--r-- | lmkd/lmkd.c | 71 |
1 files changed, 0 insertions, 71 deletions
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c index 1eec2f258..42ec3ca5e 100644 --- a/lmkd/lmkd.c +++ b/lmkd/lmkd.c @@ -62,7 +62,6 @@ #define MEMCG_SYSFS_PATH "/dev/memcg/" #define MEMCG_MEMORY_USAGE "/dev/memcg/memory.usage_in_bytes" #define MEMCG_MEMORYSW_USAGE "/dev/memcg/memory.memsw.usage_in_bytes" -#define ZONEINFO_PATH "/proc/zoneinfo" #define LINE_MAX 128 #define INKERNEL_MINFREE_PATH "/sys/module/lowmemorykiller/parameters/minfree" @@ -544,76 +543,6 @@ static void ctrl_connect_handler(int data __unused, uint32_t events __unused) { maxevents++; } -static int zoneinfo_parse_protection(char *cp) { - int max = 0; - int zoneval; - char *save_ptr; - - for (cp = strtok_r(cp, "(), ", &save_ptr); cp; cp = strtok_r(NULL, "), ", &save_ptr)) { - zoneval = strtol(cp, &cp, 0); - if (zoneval > max) - max = zoneval; - } - - return max; -} - -static void zoneinfo_parse_line(char *line, struct sysmeminfo *mip) { - char *cp = line; - char *ap; - char *save_ptr; - - cp = strtok_r(line, " ", &save_ptr); - if (!cp) - return; - - ap = strtok_r(NULL, " ", &save_ptr); - if (!ap) - return; - - if (!strcmp(cp, "nr_free_pages")) - mip->nr_free_pages += strtol(ap, NULL, 0); - else if (!strcmp(cp, "nr_file_pages")) - mip->nr_file_pages += strtol(ap, NULL, 0); - else if (!strcmp(cp, "nr_shmem")) - mip->nr_shmem += strtol(ap, NULL, 0); - else if (!strcmp(cp, "high")) - mip->totalreserve_pages += strtol(ap, NULL, 0); - else if (!strcmp(cp, "protection:")) - mip->totalreserve_pages += zoneinfo_parse_protection(ap); -} - -static int zoneinfo_parse(struct sysmeminfo *mip) { - int fd; - ssize_t size; - char buf[PAGE_SIZE]; - char *save_ptr; - char *line; - - memset(mip, 0, sizeof(struct sysmeminfo)); - - fd = open(ZONEINFO_PATH, O_RDONLY | O_CLOEXEC); - if (fd == -1) { - ALOGE("%s open: errno=%d", ZONEINFO_PATH, errno); - return -1; - } - - size = read_all(fd, buf, sizeof(buf) - 1); - if (size < 0) { - ALOGE("%s read: errno=%d", ZONEINFO_PATH, errno); - close(fd); - return -1; - } - ALOG_ASSERT((size_t)size < sizeof(buf) - 1, "/proc/zoneinfo too large"); - buf[size] = 0; - - for (line = strtok_r(buf, "\n", &save_ptr); line; line = strtok_r(NULL, "\n", &save_ptr)) - zoneinfo_parse_line(line, mip); - - close(fd); - return 0; -} - static int get_free_memory(struct mem_size *ms) { struct sysinfo si; |