Update idle thread identification.
All threads now have KOIDs, including the kernel idle threads.
Update the importer to properly identify when CPUs are idle.
Change-Id: I02449260b538f7f71077fd0d065fc1ba0d9189de
Reviewed-on: https://chromium-review.googlesource.com/c/catapult/+/2738956
Reviewed-by: Fadi Meawad <fmeawad@chromium.org>
Reviewed-by: oysteine <oysteine@chromium.org>
Commit-Queue: Fadi Meawad <fmeawad@chromium.org>
diff --git a/tracing/tracing/extras/importer/fuchsia_importer.html b/tracing/tracing/extras/importer/fuchsia_importer.html
index 8fd2fcb..80079c7 100644
--- a/tracing/tracing/extras/importer/fuchsia_importer.html
+++ b/tracing/tracing/extras/importer/fuchsia_importer.html
@@ -14,7 +14,6 @@
tr.exportTo('tr.e.importer.fuchsia', function() {
const IMPORT_PRIORITY = 0;
- const IDLE_THREAD_THRESHOLD = 6444000000;
// Zircon thread state constants from:
// https://fuchsia.googlesource.com/zircon/+/master/docs/syscalls/object_get_info.md
@@ -64,19 +63,12 @@
finalizeImport() {
}
- isIdleThread(prio, tid) {
- if (prio === undefined) {
- // If the "prio" field is not available (if we were, for example,
- // using an old trace), then fall back to the legacy heuristic of
- // assuming that large numbered threads are idle ones.
- return tid > IDLE_THREAD_THRESHOLD;
- }
- // A thread is idle iff its priority is set to 0.
- return prio === 0;
+ isIdleThread(pid, prio) {
+ return pid === 0 && prio === 0;
}
- recordThreadState_(tid, timestamp, state, prio) {
- if (this.isIdleThread(prio, tid)) {
+ recordThreadState_(pid, tid, timestamp, state, prio) {
+ if (this.isIdleThread(pid, prio)) {
return;
}
const states =
@@ -104,6 +96,7 @@
// },
processContextSwitchEvent_(event) {
let tid = event.in.tid;
+ let pid = event.in.pid;
let threadName = tid.toString();
let procName = '';
const prio = event.in.prio;
@@ -119,7 +112,7 @@
const name = procName + threadName;
- if (this.isIdleThread(prio, tid)) {
+ if (this.isIdleThread(pid, prio)) {
tid = undefined; // Fake kernel idle task
}
@@ -128,7 +121,7 @@
cpu.switchActiveThread(timestamp, {}, tid, name, tid);
const SCHEDULING_STATE = tr.model.SCHEDULING_STATE;
- this.recordThreadState_(tid, timestamp, SCHEDULING_STATE.RUNNING, prio);
+ this.recordThreadState_(pid, tid, timestamp, SCHEDULING_STATE.RUNNING, prio);
let outState = SCHEDULING_STATE.UNKNOWN;
@@ -153,7 +146,7 @@
outState = SCHEDULING_STATE.TASK_DEAD;
break;
}
- this.recordThreadState_(event.out.tid, timestamp, outState,
+ this.recordThreadState_(event.out.pid, event.out.tid, timestamp, outState,
event.out.prio);
}