From 3031fa181796e0a4818d7ff6bdc75b0f49b0576e Mon Sep 17 00:00:00 2001 From: Martin Liu Date: Sun, 19 Jan 2025 14:51:51 +0000 Subject: [PATCH] ANDROID: Adding an Android vendor LMK event This change adds an android_trigger_vendor_lmk_kill() trace event which can be used by vendor modules to send LMKD kill requests. LMKD attaches a BPF program to this trace event if it exists and expects it to be in a particular format. To provide a standardized definition for this event, we define and export it inside the GKI even though there are no users. Android vendors can use this event to emit this trace event inside their modules and experiment with different kill strategies before upstreaming them into LMKD. Bug: 385050909 Test: build and check the ftrace event Change-Id: Ida4d9202675a90d6cc891e242c0621c5386df8cc Signed-off-by: Martin Liu --- drivers/android/vendor_hooks.c | 2 ++ include/trace/events/android_vendor_lmk.h | 32 +++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 include/trace/events/android_vendor_lmk.h diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 6da9ef6372b2..27a420dce9a5 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -75,6 +75,7 @@ #include #include #include +#include /* * Export tracepoints that act as a bare tracehook (ie: have no trace event @@ -470,3 +471,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_blk_reset); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_attach_sd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sdhci_get_cd); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_mmc_gpio_cd_irqt); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_trigger_vendor_lmk_kill); diff --git a/include/trace/events/android_vendor_lmk.h b/include/trace/events/android_vendor_lmk.h new file mode 100644 index 000000000000..ad6b18ca0b4b --- /dev/null +++ b/include/trace/events/android_vendor_lmk.h @@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (C) 2025 Google, Inc. + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM android_vendor_lmk +#undef TRACE_INCLUDE_PATH +#define TRACE_INCLUDE_PATH trace/events +#if !defined(_ANDROID_VENDOR_LMK_H) || defined(TRACE_HEADER_MULTI_READ) +#define _ANDROID_VENDOR_LMK_H + +#include + +TRACE_EVENT(android_trigger_vendor_lmk_kill, + TP_PROTO(int reason, short min_oom_score_adj), + TP_ARGS(reason, min_oom_score_adj), + + TP_STRUCT__entry( + __field(int, reason) + __field(short, min_oom_score_adj) + ), + TP_fast_assign( + __entry->reason = reason; + __entry->min_oom_score_adj = min_oom_score_adj; + ), + TP_printk("reason=%u min_oom_score_adj=%hd", __entry->reason, __entry->min_oom_score_adj) +); + +#endif /* _ANDROID_VENDOR_LMK_H */ +/* This part must be outside protection */ +#include