123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- #ifndef _STATSLOG_H_
- #define _STATSLOG_H_
- #include <assert.h>
- #include <stats_event_list.h>
- #include <stdbool.h>
- #include <sys/cdefs.h>
- #include <cutils/properties.h>
- __BEGIN_DECLS
- #define LMK_KILL_OCCURRED 51
- #define LMK_STATE_CHANGED 54
- #define LMK_STATE_CHANGE_START 1
- #define LMK_STATE_CHANGE_STOP 2
- const static int kStatsEventTag = 1937006964;
- static inline void statslog_init(android_log_context* log_ctx, bool* enable_stats_log) {
- assert(log_ctx != NULL);
- assert(enable_stats_log != NULL);
- *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(android_log_context* log_ctx) {
- assert(log_ctx != NULL);
- 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;
- int64_t process_start_time_ns;
- };
- #define MEMCG_PROCESS_MEMORY_STAT_PATH "/dev/memcg/apps/uid_%u/pid_%u/memory.stat"
- #define PROC_STAT_FILE_PATH "/proc/%d/stat"
- #define PROC_STAT_BUFFER_SIZE 1024
- #define BYTES_IN_KILOBYTE 1024
- int
- stats_write_lmk_state_changed(android_log_context ctx, int32_t code, int32_t state);
- int
- 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,
- int64_t pgmajfault, int64_t rss_in_bytes, int64_t cache_in_bytes,
- int64_t swap_in_bytes, int64_t process_start_time_ns,
- int32_t min_oom_score);
- __END_DECLS
- #endif
|