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 <liumartin@google.com>
This commit is contained in:
Martin Liu
2025-01-19 14:51:51 +00:00
committed by Treehugger Robot
parent 7658169f5f
commit 3031fa1817
2 changed files with 34 additions and 0 deletions

View File

@@ -75,6 +75,7 @@
#include <trace/hooks/usb.h>
#include <trace/hooks/sound.h>
#include <trace/hooks/fuse.h>
#include <trace/events/android_vendor_lmk.h>
/*
* 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);

View File

@@ -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 <linux/tracepoint.h>
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 <trace/define_trace.h>