metric: support runqlat for upstream kernel
Change-Id: If1bda054b1befc35b8767469a81b9ac00984ebea Signed-off-by: Honglei Wang <jameshongleiwang@126.com> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
This commit is contained in:
parent
bfdc010cc1
commit
dffa1284a2
|
@ -112,12 +112,34 @@ int sched_wakeup_entry(struct trace_event_raw_sched_wakeup_template *ctx)
|
|||
return trace_enqueue(ctx->pid);
|
||||
}
|
||||
|
||||
struct task_struct___5_14 {
|
||||
unsigned int __state;
|
||||
} __attribute__((preserve_access_index));
|
||||
|
||||
long get_task_state(struct task_struct *task)
|
||||
{
|
||||
long state;
|
||||
|
||||
if (task == NULL)
|
||||
return -1;
|
||||
|
||||
if (bpf_core_field_exists(task->state))
|
||||
state = BPF_CORE_READ(task, state);
|
||||
else {
|
||||
struct task_struct___5_14 *task_new = (struct task_struct___5_14 *)task;
|
||||
state = (long)BPF_CORE_READ(task_new, __state);
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
SEC("raw_tracepoint/sched_switch")
|
||||
int sched_switch_entry(struct bpf_raw_tracepoint_args *ctx)
|
||||
{
|
||||
u32 prev_pid, next_pid, g_key = 0;
|
||||
u64 now, *tsp, delta;
|
||||
bool is_voluntary;
|
||||
long state;
|
||||
struct stat_t *entry;
|
||||
struct g_stat_t *g_entry;
|
||||
|
||||
|
@ -134,9 +156,7 @@ int sched_switch_entry(struct bpf_raw_tracepoint_args *ctx)
|
|||
u32 key = BPF_CORE_READ(prev, nsproxy, pid_ns_for_children, ns.inum);
|
||||
#endif
|
||||
|
||||
long state;
|
||||
// to avoid compilation warning, use raw interface instead of macro _()
|
||||
bpf_probe_read(&state, sizeof(long), (void *)&(prev->state));
|
||||
state = get_task_state(prev);
|
||||
|
||||
// ivcsw: treat like an enqueue event and store timestamp
|
||||
prev_pid = _(prev->pid);
|
||||
|
|
Loading…
Reference in New Issue