Message ID | 20240403140116.3002809-6-vineeth@bitbyteword.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Paravirt Scheduling (Dynamic vcpu priority management) | expand |
Adding sched_ext folks On Wed, Apr 3, 2024 at 10:01 AM Vineeth Pillai (Google) <vineeth@bitbyteword.org> wrote: > > A dummy skeleton of a bpf pvsched driver. This is just for demonstration > purpose and would need more work to be included as a test for this > feature. > > Not-Signed-off-by: Vineeth Pillai (Google) <vineeth@bitbyteword.org> > --- > .../testing/selftests/bpf/progs/bpf_pvsched.c | 37 +++++++++++++++++++ > 1 file changed, 37 insertions(+) > create mode 100644 tools/testing/selftests/bpf/progs/bpf_pvsched.c > > diff --git a/tools/testing/selftests/bpf/progs/bpf_pvsched.c b/tools/testing/selftests/bpf/progs/bpf_pvsched.c > new file mode 100644 > index 000000000000..a653baa3034b > --- /dev/null > +++ b/tools/testing/selftests/bpf/progs/bpf_pvsched.c > @@ -0,0 +1,37 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* Copyright (c) 2019 Facebook */ > + > +#include "vmlinux.h" > +#include "bpf_tracing_net.h" > +#include <bpf/bpf_tracing.h> > +#include <bpf/bpf_helpers.h> > + > +char _license[] SEC("license") = "GPL"; > + > +SEC("struct_ops/pvsched_vcpu_reg") > +int BPF_PROG(pvsched_vcpu_reg, struct pid *pid) > +{ > + bpf_printk("pvsched_vcpu_reg: pid: %p", pid); > + return 0; > +} > + > +SEC("struct_ops/pvsched_vcpu_unreg") > +void BPF_PROG(pvsched_vcpu_unreg, struct pid *pid) > +{ > + bpf_printk("pvsched_vcpu_unreg: pid: %p", pid); > +} > + > +SEC("struct_ops/pvsched_vcpu_notify_event") > +void BPF_PROG(pvsched_vcpu_notify_event, void *addr, struct pid *pid, __u32 event) > +{ > + bpf_printk("pvsched_vcpu_notify: pid: %p, event:%u", pid, event); > +} > + > +SEC(".struct_ops") > +struct pvsched_vcpu_ops pvsched_ops = { > + .pvsched_vcpu_register = (void *)pvsched_vcpu_reg, > + .pvsched_vcpu_unregister = (void *)pvsched_vcpu_unreg, > + .pvsched_vcpu_notify_event = (void *)pvsched_vcpu_notify_event, > + .events = 0x6, > + .name = "bpf_pvsched_ops", > +}; > -- > 2.40.1 >
diff --git a/tools/testing/selftests/bpf/progs/bpf_pvsched.c b/tools/testing/selftests/bpf/progs/bpf_pvsched.c new file mode 100644 index 000000000000..a653baa3034b --- /dev/null +++ b/tools/testing/selftests/bpf/progs/bpf_pvsched.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2019 Facebook */ + +#include "vmlinux.h" +#include "bpf_tracing_net.h" +#include <bpf/bpf_tracing.h> +#include <bpf/bpf_helpers.h> + +char _license[] SEC("license") = "GPL"; + +SEC("struct_ops/pvsched_vcpu_reg") +int BPF_PROG(pvsched_vcpu_reg, struct pid *pid) +{ + bpf_printk("pvsched_vcpu_reg: pid: %p", pid); + return 0; +} + +SEC("struct_ops/pvsched_vcpu_unreg") +void BPF_PROG(pvsched_vcpu_unreg, struct pid *pid) +{ + bpf_printk("pvsched_vcpu_unreg: pid: %p", pid); +} + +SEC("struct_ops/pvsched_vcpu_notify_event") +void BPF_PROG(pvsched_vcpu_notify_event, void *addr, struct pid *pid, __u32 event) +{ + bpf_printk("pvsched_vcpu_notify: pid: %p, event:%u", pid, event); +} + +SEC(".struct_ops") +struct pvsched_vcpu_ops pvsched_ops = { + .pvsched_vcpu_register = (void *)pvsched_vcpu_reg, + .pvsched_vcpu_unregister = (void *)pvsched_vcpu_unreg, + .pvsched_vcpu_notify_event = (void *)pvsched_vcpu_notify_event, + .events = 0x6, + .name = "bpf_pvsched_ops", +};