Skip to content

Commit 42884e3

Browse files
docs: Revise README files for clarity on extending kernel behavior with BPF struct_ops
1 parent 34f6903 commit 42884e3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/features/struct_ops/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# eBPF Tutorial: Extending Kernel Subsystems with BPF struct_ops
22

3-
Have you ever wanted to implement a kernel feature, like a new network protocol or a custom security policy, but were put off by the complexity of writing and maintaining a full kernel module? What if you could define the operational logic of a kernel subsystem directly in eBPF, allowing for dynamic updates, safe execution, and programmable control, all without recompiling the kernel or risking system stability?
3+
Have you ever wanted to extend kernel behavior—like adding a custom scheduler, network protocol, or security policybut were put off by the complexity of writing and maintaining a full kernel module? What if you could define the logic directly in eBPF, with dynamic updates, safe execution, and programmable control, all without recompiling the kernel or risking system stability?
44

5-
This is the power of **BPF struct_ops**. This advanced eBPF feature allows BPF programs to implement the callbacks for a kernel structure of operations, effectively allowing you to "plug in" BPF code to act as a kernel subsystem. It's a step beyond simple tracing or filtering; it's about implementing core kernel logic in BPF. For instance, we also use it to implement GPU scheduling and memory offloading extensions with eBPF in GPU drivers (see [LPC 2024 talk](https://lpc.events/event/19/contributions/2168/) and the [gpu_ext project](https://github.com/eunomia-bpf/gpu_ext)).
5+
This is the power of **BPF struct_ops**. This advanced eBPF feature allows BPF programs to implement the callbacks of a kernel operations structure, effectively letting you "plug in" custom logic to extend kernel subsystems. It goes beyond simple tracing or filtering—you can now implement core kernel operations in BPF. For example, we use it to implement GPU scheduling and memory offloading extensions in GPU drivers (see [LPC 2024 talk](https://lpc.events/event/19/contributions/2168/) and [gpu_ext project](https://github.com/eunomia-bpf/gpu_ext)).
66

77
In this tutorial, we will explore how to use `struct_ops` to dynamically extend kernel subsystem behavior. We won't be using the common TCP congestion control example. Instead, we'll take a more fundamental approach that mirrors the extensibility seen with kfuncs. We will create a custom kernel module that defines a new, simple subsystem with a set of operations. This module will act as a placeholder, creating new attachment points for our BPF programs. Then, we will write a BPF program to implement the logic for these operations. This demonstrates a powerful pattern: using a minimal kernel module to expose a `struct_ops` interface, and then using BPF to provide the full, complex implementation.
88

src/features/struct_ops/README.zh.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# eBPF 教程:使用 BPF struct_ops 扩展内核子系统
22

3-
你是否曾经想过实现一项内核功能,比如一个新的网络协议或一个自定义的安全策略,但却因为编写和维护一个完整内核模块的复杂性而望而却步?设想一下,如果你可以直接在 eBPF 中定义一个内核子系统的操作逻辑,从而实现动态更新、安全执行和可编程控制,而这一切都无需重新编译内核或冒着系统稳定的风险,那会是怎样一种体验
3+
你是否想过扩展内核行为——比如添加自定义调度器、网络协议或安全策略——却因为编写和维护内核模块的复杂性而望而却步?如果你可以直接用 eBPF 定义这些逻辑,实现动态更新、安全执行和可编程控制,同时无需重新编译内核或担心系统稳定性呢
44

5-
这就是 **BPF struct_ops** 的强大之处。这个先进的 eBPF 功能允许 BPF 程序实现内核操作结构的回调函数,实际上是让你能够“插入”BPF 代码来充当一个内核子系统。这已经超越了简单的跟踪或过滤;这是关于在 BPF 中实现核心的内核逻辑。例如,我们还使用它在 GPU 驱动中通过 eBPF 实现 GPU 调度和内存卸载扩展(请参阅 [LPC 2024 演讲](https://lpc.events/event/19/contributions/2168/)[gpu_ext 项目](https://github.com/eunomia-bpf/gpu_ext))。
5+
这就是 **BPF struct_ops** 的强大之处。它允许 BPF 程序实现内核操作结构体的回调函数,让你能够"插入"自定义逻辑来扩展内核子系统的行为。这已经超越了简单的跟踪或过滤——你现在可以用 BPF 实现核心的内核操作。例如,我们用它在 GPU 驱动中实现了 GPU 调度和内存卸载扩展(参见 [LPC 2024 演讲](https://lpc.events/event/19/contributions/2168/)[gpu_ext 项目](https://github.com/eunomia-bpf/gpu_ext))。
66

77
在本教程中,我们将探讨如何使用 `struct_ops` 来动态地扩展内核子系统的行为。我们不会使用常见的 TCP 拥塞控制示例。相反,我们将采用一种更基础的方法,这种方法反映了与 kfuncs 相似的可扩展性。我们将创建一个自定义的内核模块,该模块定义了一组新的、简单的操作。这个模块将充当一个占位符,为我们的 BPF 程序创建新的附加点。然后,我们将编写一个 BPF 程序来实现这些操作的逻辑。这演示了一种强大的模式:使用一个最小化的内核模块来暴露一个 `struct_ops` 接口,然后使用 BPF 来提供完整、复杂的实现。
88

0 commit comments

Comments
 (0)