lmkd: Maintain pid to taskname mapping to amend kill reports.

Required because the kernel cannot always get the taskname safely at
the time the process is killed (due to competition for mm->mmap_sem).

Test: manually
Bug: 130017100
Signed-off-by: Jim Blackler <jimblackler@google.com>
Change-Id: I27a2c3340da321570f0832d58fe9e79ca031620b
diff --git a/lmkd/statslog.h b/lmkd/statslog.h
index 2edba7a..50d69f7 100644
--- a/lmkd/statslog.h
+++ b/lmkd/statslog.h
@@ -85,12 +85,41 @@
  * Code: LMK_KILL_OCCURRED = 51
  */
 int
+stats_write_lmk_kill_occurred_pid(android_log_context ctx, int32_t code, int32_t uid, int pid,
+                                  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);
+
+/**
+ * Logs the event when LMKD kills a process to reduce memory pressure.
+ * Code: LMK_KILL_OCCURRED = 51
+ */
+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);
 
+/**
+ * Registers a process taskname by pid, while it is still alive.
+ */
+void
+stats_store_taskname(int pid, const char* taskname);
+
+/**
+ * Unregister all process tasknames.
+ */
+void
+stats_purge_tasknames();
+
+/**
+ * Unregister a process taskname, e.g. after it has been killed.
+ */
+void
+stats_remove_taskname(int pid);
+
 __END_DECLS
 
 #endif /* _STATSLOG_H_ */