lmkd: move sundry pieces to statslog.h
Pragma once is not part of the standard, and is actually a gnu
C++ addition. Android coding standard requires the #ifndef header
wrappers. Moved things that belong in statslog.h from the lmkd files.
SideEffects: None
Test: lmkd_unit_tests
Bug: 33808187
Bug: 72838192
Change-Id: I9686b1a0791ee2b723d05b91905eda0bb64a1156
diff --git a/lmkd/lmkd.c b/lmkd/lmkd.c
index 3545400..1d8afb4 100644
--- a/lmkd/lmkd.c
+++ b/lmkd/lmkd.c
@@ -37,7 +37,6 @@
#include <log/log.h>
#ifdef LMKD_LOG_STATS
-#include <log/log_event_list.h>
#include <statslog.h>
#endif
@@ -76,18 +75,6 @@
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#define EIGHT_MEGA (1 << 23)
-#ifdef LMKD_LOG_STATS
-#define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%d/pid_%d/memory.stat"
-/*
- * These are defined in
- * http://cs/android/frameworks/base/cmds/statsd/src/atoms.proto
- */
-#define LMK_KILL_OCCURRED 51
-#define LMK_STATE_CHANGED 54
-#define LMK_STATE_CHANGE_START 1
-#define LMK_STATE_CHANGE_STOP 2
-#endif
-
/* default to old in-kernel interface if no memory pressure events */
static int use_inkernel_interface = 1;
static bool has_inkernel_module;
@@ -182,13 +169,6 @@
};
#ifdef LMKD_LOG_STATS
-struct memory_stat {
- int64_t pgfault;
- int64_t pgmajfault;
- int64_t rss_in_bytes;
- int64_t cache_in_bytes;
- int64_t swap_in_bytes;
-};
static bool enable_stats_log;
static android_log_context log_ctx;
#endif
@@ -1221,11 +1201,7 @@
(unsigned long)property_get_int32("ro.lmk.kill_timeout_ms", 0);
#ifdef LMKD_LOG_STATS
- enable_stats_log = property_get_bool("ro.lmk.log_stats", false);
-
- if (enable_stats_log) {
- log_ctx = create_android_logger(kStatsEventTag);
- }
+ statlog_init();
#endif
// MCL_ONFAULT pins pages as they fault instead of loading
@@ -1245,9 +1221,7 @@
mainloop();
#ifdef LMKD_LOG_STATS
- if (log_ctx) {
- android_log_destroy(&log_ctx);
- }
+ statslog_destroy();
#endif
ALOGI("exiting");