mirror of
https://github.com/sched-ext/scx.git
synced 2024-12-12 11:37:18 +00:00
share the sdt_stats struct between userspace and kernel
This commit is contained in:
parent
b8c30308e1
commit
2044301cf8
@ -2,16 +2,14 @@
|
|||||||
#include <scx/common.bpf.h>
|
#include <scx/common.bpf.h>
|
||||||
#include <scx/sdt_task_impl.bpf.h>
|
#include <scx/sdt_task_impl.bpf.h>
|
||||||
|
|
||||||
|
#include "scx_sdt.h"
|
||||||
|
|
||||||
char _license[] SEC("license") = "GPL";
|
char _license[] SEC("license") = "GPL";
|
||||||
|
|
||||||
UEI_DEFINE(uei);
|
UEI_DEFINE(uei);
|
||||||
|
|
||||||
#define SHARED_DSQ 0
|
#define SHARED_DSQ 0
|
||||||
|
|
||||||
struct sdt_task_ctx {
|
|
||||||
int seq;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
|
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
|
||||||
__uint(key_size, sizeof(u32));
|
__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 scx_init_task_args *args)
|
||||||
{
|
{
|
||||||
struct sdt_task_data __arena *data;
|
struct sdt_task_data __arena *data;
|
||||||
|
struct sdt_task_stats __arena *stats;
|
||||||
|
|
||||||
data = sdt_task_alloc(p);
|
data = sdt_task_alloc(p);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
stats = (struct sdt_task_stats __arena *)data->data;
|
||||||
|
stats->pid = p->pid;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +75,8 @@ void BPF_STRUCT_OPS(sdt_exit_task, struct task_struct *p,
|
|||||||
s32 BPF_STRUCT_OPS_SLEEPABLE(sdt_init)
|
s32 BPF_STRUCT_OPS_SLEEPABLE(sdt_init)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
ret = sdt_task_init(sizeof(struct sdt_task_ctx));
|
|
||||||
|
ret = sdt_task_init(sizeof(struct sdt_task_stats));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/* SPDX-License-Identifier: GPL-2.0 */
|
/* SPDX-License-Identifier: GPL-2.0 */
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2022 Meta Platforms, Inc. and affiliates.
|
* Copyright (c) 2024 Meta Platforms, Inc. and affiliates.
|
||||||
* Copyright (c) 2022 Tejun Heo <tj@kernel.org>
|
* Copyright (c) 2024 Emil Tsalapatis <etsal@meta.com>
|
||||||
|
* Copyright (c) 2024 Tejun Heo <tj@kernel.org>
|
||||||
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
|
* Copyright (c) 2022 David Vernet <dvernet@meta.com>
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -13,6 +14,8 @@
|
|||||||
#include <scx/sdt_task.h>
|
#include <scx/sdt_task.h>
|
||||||
#include "scx_sdt.bpf.skel.h"
|
#include "scx_sdt.bpf.skel.h"
|
||||||
|
|
||||||
|
#include "scx_sdt.h"
|
||||||
|
|
||||||
const char help_fmt[] =
|
const char help_fmt[] =
|
||||||
"A simple sched_ext scheduler.\n"
|
"A simple sched_ext scheduler.\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
5
scheds/c/scx_sdt.h
Normal file
5
scheds/c/scx_sdt.h
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#pragma once
|
||||||
|
struct sdt_task_stats {
|
||||||
|
int seq;
|
||||||
|
pid_t pid;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user