From 5860e852f88e4eb859c5c6bf51b929cfdcfc9dd5 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Fri, 19 May 2023 14:06:46 -0700 Subject: [PATCH] lmkd: remove unused LMK_STAT_STATE_CHANGED notification The LmkStateChanged atom was historically used to mark lmk activity and trigger additional stats polling. For more than a year this has not been used at all (as statsd supported event-based triggering). Remove unnecessary functionality. Bug: 278174420 Signed-off-by: Suren Baghdasaryan Change-Id: I9f7f56711fabb751cf7a57ea7279759bcc4a3dff --- include/lmkd.h | 1 - lmkd.cpp | 25 ------------------------- statslog.cpp | 12 ------------ statslog.h | 20 -------------------- 4 files changed, 58 deletions(-) diff --git a/include/lmkd.h b/include/lmkd.h index c814d17..d710d50 100644 --- a/include/lmkd.h +++ b/include/lmkd.h @@ -36,7 +36,6 @@ enum lmk_cmd { LMK_PROCKILL, /* Unsolicited msg to subscribed clients on proc kills */ LMK_UPDATE_PROPS, /* Reinit properties */ LMK_STAT_KILL_OCCURRED, /* Unsolicited msg to subscribed clients on proc kills for statsd log */ - LMK_STAT_STATE_CHANGED, /* Unsolicited msg to subscribed clients on state changed */ }; /* diff --git a/lmkd.cpp b/lmkd.cpp index fcb06fe..02fb553 100644 --- a/lmkd.cpp +++ b/lmkd.cpp @@ -810,22 +810,6 @@ static void stats_write_lmk_kill_occurred_pid(int pid, struct kill_stat *kill_st } } -/* - * Write the state_changed over the data socket to be propagated via AMS to statsd - */ -static void stats_write_lmk_state_changed(enum lmk_state state) { - LMKD_CTRL_PACKET packet_state_changed; - const size_t len = lmkd_pack_set_state_changed(packet_state_changed, state); - if (len == 0) { - return; - } - for (int i = 0; i < MAX_DATA_CONN; i++) { - if (data_sock[i].sock >= 0 && data_sock[i].async_event_mask & 1 << LMK_ASYNC_EVENT_STAT) { - ctrl_data_write(i, (char*)packet_state_changed, len); - } - } -} - static void poll_kernel(int poll_fd) { if (poll_fd == -1) { // not waiting @@ -2423,7 +2407,6 @@ static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union struct psi_data *pd) { int i; int killed_size = 0; - bool lmk_state_change_start = false; bool choose_heaviest_task = kill_heaviest_task; for (i = OOM_SCORE_ADJ_MAX; i >= min_score_adj; i--) { @@ -2446,10 +2429,6 @@ static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union killed_size = kill_one_process(procp, min_score_adj, ki, mi, wi, tm, pd); if (killed_size >= 0) { - if (!lmk_state_change_start) { - lmk_state_change_start = true; - stats_write_lmk_state_changed(STATE_START); - } break; } } @@ -2458,10 +2437,6 @@ static int find_and_kill_process(int min_score_adj, struct kill_info *ki, union } } - if (lmk_state_change_start) { - stats_write_lmk_state_changed(STATE_STOP); - } - return killed_size; } diff --git a/statslog.cpp b/statslog.cpp index 26a6d86..6e6cb42 100644 --- a/statslog.cpp +++ b/statslog.cpp @@ -336,16 +336,4 @@ size_t lmkd_pack_set_kill_occurred(LMK_KILL_OCCURRED_PACKET packet, return index; } -size_t lmkd_pack_set_state_changed(LMKD_CTRL_PACKET packet, - enum lmk_state state) { - if (!enable_stats_log) { - return 0; - } - - packet[0] = htonl(LMK_STAT_STATE_CHANGED); - packet[1] = htonl(state); - - return 2 * sizeof(int); -} - #endif /* LMKD_LOG_STATS */ diff --git a/statslog.h b/statslog.h index e3f8b72..c61cf29 100644 --- a/statslog.h +++ b/statslog.h @@ -83,27 +83,12 @@ struct kill_stat { /* LMKD reply packet to hold data for the LmkKillOccurred statsd atom */ typedef char LMK_KILL_OCCURRED_PACKET[LMKD_REPLY_MAX_SIZE]; -// If you update this, also update the corresponding stats enum mapping. -enum lmk_state { - STATE_UNKNOWN = 0, - STATE_START, - STATE_STOP, -}; - #ifdef LMKD_LOG_STATS #define PROC_STAT_FILE_PATH "/proc/%d/stat" #define PROC_STAT_BUFFER_SIZE 1024 #define BYTES_IN_KILOBYTE 1024 -/** - * Produces packet with the change in LMKD state which is used as start/stop boundaries for logging - * LMK_KILL_OCCURRED event. - * Code: LMK_STATE_CHANGED = 54 - */ -size_t lmkd_pack_set_state_changed(LMKD_CTRL_PACKET packet, - enum lmk_state state); - /** * Produces packet with the event when LMKD kills a process to reduce memory pressure. * Code: LMK_KILL_OCCURRED = 51 @@ -137,11 +122,6 @@ const char* stats_get_task_name(int pid); #else /* LMKD_LOG_STATS */ -static inline size_t -lmkd_pack_set_state_changed(LMKD_CTRL_PACKET packet __unused, enum lmk_state state __unused) { - return -EINVAL; -} - static inline size_t lmkd_pack_set_kill_occurred(LMK_KILL_OCCURRED_PACKET packet __unused, struct kill_stat *kill_st __unused,