From 4f50ca45bc5fe9574be975fcd403de0b0d23f777 Mon Sep 17 00:00:00 2001 From: Dmitri Plotnikov Date: Mon, 23 Nov 2020 15:57:02 -0800 Subject: [PATCH] Allow multiple processes' threads tracked at the same time Bug: 169279846 Test: atest bpf-time-in-state-tests Change-Id: Ia2aa4dc3d87610651195c5f50d58fc37a9a84a2a --- progs/include/bpf_timeinstate.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 @@ typedef struct { 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;