ANDROID: sched_clock: Add vendor hook to print epoch values

Add vendor hook to print epoch values when system enter and exit
out of suspend and resume. These epoch values are useful to know
how long the device is in suspend state. These values can be used
to synchronize various subsystem timestamps and have an unique
timestamp to correlate between various subsystems.

Bug: 172945021
Change-Id: I82a01e348d05a46c9c3921869cc9d2fc0fd28867
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>
This commit is contained in:
Murali Nalajala
2020-11-10 14:21:37 -08:00
committed by Todd Kjos
parent 7e4da32f44
commit 76b58ff07b
3 changed files with 37 additions and 0 deletions

View File

@@ -23,6 +23,7 @@
#include <trace/hooks/sysrqcrash.h>
#include <trace/hooks/printk.h>
#include <trace/hooks/gic_v3.h>
#include <trace/hooks/epoch.h>
/*
* Export tracepoints that act as a bare tracehook (ie: have no trace event
@@ -70,3 +71,5 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_printk_hotplug);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_jiffies_update);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v3_set_affinity);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_gic_v3_affinity_init);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_suspend_epoch_val);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_show_resume_epoch_val);

View File

@@ -0,0 +1,31 @@
/* SPDX-License-Identifier: GPL-2.0 */
#undef TRACE_SYSTEM
#define TRACE_SYSTEM epoch
#define TRACE_INCLUDE_PATH trace/hooks
#if !defined(_TRACE_HOOK_EPOCH_H) || defined(TRACE_HEADER_MULTI_READ)
#define _TRACE_HOOK_EPOCH_H
#include <linux/tracepoint.h>
#include <trace/hooks/vendor_hooks.h>
#if defined(CONFIG_TRACEPOINTS) && defined(CONFIG_ANDROID_VENDOR_HOOKS)
DECLARE_HOOK(android_vh_show_suspend_epoch_val,
TP_PROTO(u64 suspend_ns, u64 suspend_cycles),
TP_ARGS(suspend_ns, suspend_cycles));
DECLARE_HOOK(android_vh_show_resume_epoch_val,
TP_PROTO(u64 resume_cycles),
TP_ARGS(resume_cycles));
#else
#define trace_android_vh_show_suspend_epoch_val(suspend_ns, suspend_cycles)
#define trace_android_vh_show_resume_epoch_val(resume_cycles)
#endif
#endif /* _TRACE_HOOK_EPOCH_H */
/* This part must be outside protection */
#include <trace/define_trace.h>

View File

@@ -16,6 +16,7 @@
#include <linux/sched_clock.h>
#include <linux/seqlock.h>
#include <linux/bitops.h>
#include <trace/hooks/epoch.h>
#include "timekeeping.h"
@@ -270,6 +271,7 @@ int sched_clock_suspend(void)
update_sched_clock();
hrtimer_cancel(&sched_clock_timer);
rd->read_sched_clock = suspended_sched_clock_read;
trace_android_vh_show_suspend_epoch_val(rd->epoch_ns, rd->epoch_cyc);
return 0;
}
@@ -281,6 +283,7 @@ void sched_clock_resume(void)
rd->epoch_cyc = cd.actual_read_sched_clock();
hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL_HARD);
rd->read_sched_clock = cd.actual_read_sched_clock;
trace_android_vh_show_resume_epoch_val(rd->epoch_cyc);
}
static struct syscore_ops sched_clock_ops = {