Skip to content

Commit

Permalink
Hard core fix suspend/resume latency slice for older devices
Browse files Browse the repository at this point in the history
Bug: 250608374

Test: tools/diff_test_trace_processor.py <trace_processor_shell> \
      --query-metric-filter='suspend_resume'

Test: tools/diff_test_trace_processor.py <trace_processor_shell> \
      --trace-filter='suspend_period'

Signed-off-by: Luke Chang <[email protected]>
Change-Id: If268e900d53c585f0360473d291f7dfcd3cbe9da
  • Loading branch information
Luke Chang committed Oct 7, 2022
1 parent 6f9968b commit 19e8046
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/trace_processor/importers/ftrace/ftrace_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2259,18 +2259,24 @@ void FtraceParser::ParseSuspendResume(int64_t timestamp,
auto async_track = context_->async_track_set_tracker->InternGlobalTrackSet(
suspend_resume_name_id_);

// Hard code fix the timekeeping_freeze action's value to zero, the value is
// processor_id and device could enter suspend/resume from different
// processor.
auto val =
(evt.action().ToStdString() == "timekeeping_freeze") ? 0 : evt.val();

base::StackString<64> str("%s(%" PRIu32 ")",
evt.action().ToStdString().c_str(), evt.val());
evt.action().ToStdString().c_str(), val);
StringId slice_name_id = context_->storage->InternString(str.string_view());

if (evt.start()) {
TrackId start_id = context_->async_track_set_tracker->Begin(
async_track, static_cast<int64_t>(evt.val()));
async_track, static_cast<int64_t>(val));
context_->slice_tracker->Begin(timestamp, start_id, suspend_resume_name_id_,
slice_name_id);
} else {
TrackId end_id = context_->async_track_set_tracker->End(
async_track, static_cast<int64_t>(evt.val()));
async_track, static_cast<int64_t>(val));
context_->slice_tracker->End(timestamp, end_id);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/trace_processor/metrics/sql/android/android_batt.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ FROM
ON slice.track_id = track.id
WHERE
track.name = 'Suspend/Resume Latency'
AND slice.name = 'syscore_resume(0)'
AND (slice.name = 'syscore_resume(0)' OR slice.name = 'timekeeping_freeze(0)')
AND dur != -1
;

Expand Down
6 changes: 5 additions & 1 deletion test/trace_processor/power/suspend_period.out
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
android_batt {
battery_aggregates {
sleep_ns: 10000
sleep_ns: 20000
}
suspend_period {
timestamp_ns: 30000
duration_ns: 10000
}
suspend_period {
timestamp_ns: 50000
duration_ns: 10000
}
}
28 changes: 28 additions & 0 deletions test/trace_processor/power/suspend_period.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,31 @@ packet {
}
}
}
packet {
ftrace_events {
cpu: 4
event {
timestamp: 50000
pid: 0
suspend_resume {
action: "timekeeping_freeze"
val: 4
start: 1
}
}
}
}
packet {
ftrace_events {
cpu: 1
event {
timestamp: 60000
pid: 0
suspend_resume {
action: "timekeeping_freeze"
val: 1
start: 0
}
}
}
}
1 change: 1 addition & 0 deletions test/trace_processor/power/suspend_resume.out
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"ts","dur","action"
10000,10000,"suspend_enter(3)"
30000,10000,"CPU(0)"
50000,10000,"timekeeping_freeze(0)"
28 changes: 28 additions & 0 deletions test/trace_processor/power/suspend_resume.textproto
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,31 @@ packet {
}
}
}
packet {
ftrace_events {
cpu: 4
event {
timestamp: 50000
pid: 0
suspend_resume {
action: "timekeeping_freeze"
val: 4
start: 1
}
}
}
}
packet {
ftrace_events {
cpu: 1
event {
timestamp: 60000
pid: 0
suspend_resume {
action: "timekeeping_freeze"
val: 1
start: 0
}
}
}
}

0 comments on commit 19e8046

Please sign in to comment.