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
This commit is contained in:
parent
10a75706de
commit
0b08d5067c
30
lmkd.c
30
lmkd.c
|
|
@ -37,7 +37,6 @@
|
||||||
#include <log/log.h>
|
#include <log/log.h>
|
||||||
|
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
#include <log/log_event_list.h>
|
|
||||||
#include <statslog.h>
|
#include <statslog.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -76,18 +75,6 @@
|
||||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
|
||||||
#define EIGHT_MEGA (1 << 23)
|
#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 */
|
/* default to old in-kernel interface if no memory pressure events */
|
||||||
static int use_inkernel_interface = 1;
|
static int use_inkernel_interface = 1;
|
||||||
static bool has_inkernel_module;
|
static bool has_inkernel_module;
|
||||||
|
|
@ -182,13 +169,6 @@ struct proc {
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef LMKD_LOG_STATS
|
#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 bool enable_stats_log;
|
||||||
static android_log_context log_ctx;
|
static android_log_context log_ctx;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -1221,11 +1201,7 @@ int main(int argc __unused, char **argv __unused) {
|
||||||
(unsigned long)property_get_int32("ro.lmk.kill_timeout_ms", 0);
|
(unsigned long)property_get_int32("ro.lmk.kill_timeout_ms", 0);
|
||||||
|
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
enable_stats_log = property_get_bool("ro.lmk.log_stats", false);
|
statlog_init();
|
||||||
|
|
||||||
if (enable_stats_log) {
|
|
||||||
log_ctx = create_android_logger(kStatsEventTag);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// MCL_ONFAULT pins pages as they fault instead of loading
|
// MCL_ONFAULT pins pages as they fault instead of loading
|
||||||
|
|
@ -1245,9 +1221,7 @@ int main(int argc __unused, char **argv __unused) {
|
||||||
mainloop();
|
mainloop();
|
||||||
|
|
||||||
#ifdef LMKD_LOG_STATS
|
#ifdef LMKD_LOG_STATS
|
||||||
if (log_ctx) {
|
statslog_destroy();
|
||||||
android_log_destroy(&log_ctx);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ALOGI("exiting");
|
ALOGI("exiting");
|
||||||
|
|
|
||||||
44
statslog.h
44
statslog.h
|
|
@ -14,11 +14,50 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#ifndef _STATSLOG_H_
|
||||||
|
#define _STATSLOG_H_
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
#include <cutils/properties.h>
|
||||||
|
#include <log/log_event_list.h>
|
||||||
|
|
||||||
__BEGIN_DECLS
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
|
||||||
|
static inline void statslog_init() {
|
||||||
|
enable_stats_log = property_get_bool("ro.lmk.log_stats", false);
|
||||||
|
|
||||||
|
if (enable_stats_log) {
|
||||||
|
log_ctx = create_android_logger(kStatsEventTag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void statslog_destroy() {
|
||||||
|
if (log_ctx) {
|
||||||
|
android_log_destroy(&log_ctx);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct memory_stat {
|
||||||
|
int64_t pgfault;
|
||||||
|
int64_t pgmajfault;
|
||||||
|
int64_t rss_in_bytes;
|
||||||
|
int64_t cache_in_bytes;
|
||||||
|
int64_t swap_in_bytes;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%u/pid_%u/memory.stat"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The single event tag id for all stats logs.
|
* The single event tag id for all stats logs.
|
||||||
* Keep this in sync with system/core/logcat/event.logtags
|
* Keep this in sync with system/core/logcat/event.logtags
|
||||||
|
|
@ -42,4 +81,7 @@ stats_write_lmk_kill_occurred(android_log_context ctx, int32_t code, int32_t uid
|
||||||
char const* process_name, int32_t oom_score, int64_t pgfault,
|
char const* process_name, int32_t oom_score, int64_t pgfault,
|
||||||
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
|
||||||
int64_t swap_in_bytes);
|
int64_t swap_in_bytes);
|
||||||
|
|
||||||
__END_DECLS
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif /* _STATSLOG_H_ */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue