Merge "Allow multiple processes' threads tracked at the same time" am: 20bfae742b
Original change: https://android-review.googlesource.com/c/platform/system/bpf/+/1508927
Change-Id: I9b587eb69b3b0069adeb5dba71ffa0cc2e816285
diff --git a/progs/include/bpf_timeinstate.h b/progs/include/bpf_timeinstate.h
index 61d3324..7cb7baa 100644
--- a/progs/include/bpf_timeinstate.h
+++ b/progs/include/bpf_timeinstate.h
@@ -45,6 +45,24 @@
uint32_t freq;
} freq_idx_key_t;
+// Maximum number of processes whose thread CPU time-in-state can be tracked simultaneously.
+#define MAX_TRACKED_PIDS 8
+
+// Indicates that the pid_tracked_map item is unused and further items in the array are also
+// unused
+#define TRACKED_PID_STATE_UNUSED 0
+// Indicates that the pid_tracked_map item contains a PID that is currently tracked
+#define TRACKED_PID_STATE_ACTIVE 1
+// Indicates that the pid_tracked_map item is vacant, but further items in the array may
+// contain tracked PIDs
+#define TRACKED_PID_STATE_EXITED 2
+
+typedef struct {
+ pid_t pid;
+ // TRACKED_PID_STATE_UNUSED, TRACKED_PID_STATE_ACTIVE or TRACKED_PID_STATE_EXITED
+ uint8_t state;
+} tracked_pid_t;
+
typedef struct {
pid_t tgid;
uint16_t aggregation_key;