ANDROID: psi: Add vendor hooks for PSI tracing

Add hooks to capture various per-zone memory stats when
a trigger threshold is hit.

Bug: 268290366
Change-Id: Ibe39263ddb05ffc3fa63b5225497a90c6480c8d7
Signed-off-by: Georgi Djakov <quic_c_gdjako@quicinc.com>
This commit is contained in:
Georgi Djakov
2021-04-19 09:55:11 -07:00
committed by Todd Kjos
parent af8dfb011f
commit 5a6502af11
3 changed files with 34 additions and 0 deletions

View File

@@ -109,6 +109,7 @@
#include <trace/hooks/dm.h>
#include <trace/hooks/direct_io.h>
#include <trace/hooks/loop.h>
#include <trace/hooks/psi.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
* associated with them) to allow external modules to probe them.
@@ -417,6 +418,8 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_dm_update_clone_bio);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_rvh_ctl_dirty_rate);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_direct_io_update_bio);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_loop_prepare_cmd);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_event);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_psi_group);
/*
* For type visibility
*/

25
include/trace/hooks/psi.h Normal file
View File

@@ -0,0 +1,25 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM psi
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_PSI_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_PSI_H
#include <trace/hooks/vendor_hooks.h>
struct psi_trigger;
struct psi_group;
DECLARE_HOOK(android_vh_psi_event,
TP_PROTO(struct psi_trigger *t),
TP_ARGS(t));
DECLARE_HOOK(android_vh_psi_group,
TP_PROTO(struct psi_group *group),
TP_ARGS(group));
#endif /* _TRACE_HOOK_PSI_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -151,6 +151,8 @@
#include <linux/psi.h>
#include "sched.h"
#include <trace/hooks/psi.h>
static int psi_bug __read_mostly;
DEFINE_STATIC_KEY_FALSE(psi_disabled);
@@ -576,12 +578,16 @@ static u64 update_triggers(struct psi_group *group, u64 now)
if (now < t->last_event_time + t->win.size)
continue;
trace_android_vh_psi_event(t);
/* Generate an event */
if (cmpxchg(&t->event, 0, 1) == 0)
wake_up_interruptible(&t->event_wait);
t->last_event_time = now;
}
trace_android_vh_psi_group(group);
if (new_stall)
memcpy(group->polling_total, total,
sizeof(group->polling_total));