diff --git a/scheds/c/scx_sdt.bpf.c b/scheds/c/scx_sdt.bpf.c index 0347ac3a..1c14f009 100644 --- a/scheds/c/scx_sdt.bpf.c +++ b/scheds/c/scx_sdt.bpf.c @@ -2,16 +2,14 @@ #include #include +#include "scx_sdt.h" + char _license[] SEC("license") = "GPL"; UEI_DEFINE(uei); #define SHARED_DSQ 0 -struct sdt_task_ctx { - int seq; -}; - struct { __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); __uint(key_size, sizeof(u32)); @@ -56,11 +54,15 @@ s32 BPF_STRUCT_OPS_SLEEPABLE(sdt_init_task, struct task_struct *p, struct scx_init_task_args *args) { struct sdt_task_data __arena *data; + struct sdt_task_stats __arena *stats; data = sdt_task_alloc(p); if (!data) return -ENOMEM; + stats = (struct sdt_task_stats __arena *)data->data; + stats->pid = p->pid; + return 0; } @@ -73,7 +75,8 @@ void BPF_STRUCT_OPS(sdt_exit_task, struct task_struct *p, s32 BPF_STRUCT_OPS_SLEEPABLE(sdt_init) { int ret; - ret = sdt_task_init(sizeof(struct sdt_task_ctx)); + + ret = sdt_task_init(sizeof(struct sdt_task_stats)); if (ret < 0) return ret; diff --git a/scheds/c/scx_sdt.c b/scheds/c/scx_sdt.c index c9a9e701..85226080 100644 --- a/scheds/c/scx_sdt.c +++ b/scheds/c/scx_sdt.c @@ -1,7 +1,8 @@ /* SPDX-License-Identifier: GPL-2.0 */ /* - * Copyright (c) 2022 Meta Platforms, Inc. and affiliates. - * Copyright (c) 2022 Tejun Heo + * Copyright (c) 2024 Meta Platforms, Inc. and affiliates. + * Copyright (c) 2024 Emil Tsalapatis + * Copyright (c) 2024 Tejun Heo * Copyright (c) 2022 David Vernet */ #include @@ -13,6 +14,8 @@ #include #include "scx_sdt.bpf.skel.h" +#include "scx_sdt.h" + const char help_fmt[] = "A simple sched_ext scheduler.\n" "\n" diff --git a/scheds/c/scx_sdt.h b/scheds/c/scx_sdt.h new file mode 100644 index 00000000..511044dd --- /dev/null +++ b/scheds/c/scx_sdt.h @@ -0,0 +1,5 @@ +#pragma once +struct sdt_task_stats { + int seq; + pid_t pid; +};