Skip to content

eBPF-based security platform

skills: write upatch code for preemptible RCU when kernels are unnamed

Daniel Borkmann9f5304ff7cdb
diff --git a/.agents/skills/bpf-concurrency/SKILL.md b/.agents/skills/bpf-concurrency/SKILL.md
index f3ef8231..73122952 100644
--- a/.agents/skills/bpf-concurrency/SKILL.md
+++ b/.agents/skills/bpf-concurrency/SKILL.md
@@ -1,6 +1,9 @@
---
name: bpf-concurrency
-description: Write or review BPF code in a shirudo upatch whose runs share state, across CPUs at once or interleaved on one. Covers shared map values, per-CPU scratch, inserting and deleting entries, compare-and-swap, publishing records, double buffers, user memory, and the runs the kernel skips. Use when a upatch program updates state other runs read, when a lock, atomic, acquire or release is involved, or to check such code with the Coccinelle rules and blitmus.
+description: Writes or reviews BPF code in a shirudo upatch whose runs share state, across CPUs at once or interleaved on one. Covers shared map values, per-CPU scratch, inserting and deleting entries, compare-and-swap, publishing records, double buffers, user memory, and the runs the kernel skips. Use when a upatch program updates state other runs read, when a lock, atomic, acquire or release is involved, or to check such code with the Coccinelle rules and blitmus.
+paths:
+ - "upatches/**/*.bpf.c"
+ - "upatches/**/*.h"
---
# Concurrent BPF code in upatches
@@ -22,9 +25,9 @@ socket or cgroup storage, an arena, or the stack.
## 2. Fix the model
-Ask which kernels the upatch is for when the task does not say, and
-without an answer write for preemptible RCU, which is right on every
-model; the `upatch` skill says how to read a target's model. Runs on
+When the task does not say which kernels the upatch is for, write for
+preemptible RCU, which is right on every model, as the `upatch` skill
+says; it also says how to read a target's model. Runs on
different CPUs at once happen on every kernel. A second run on
the same CPU before the first ends depends on the kernel's preemption
model and the program types, as the table in "Where each hazard
diff --git a/.agents/skills/upatch/SKILL.md b/.agents/skills/upatch/SKILL.md
index 59ff34cf..0b83f431 100644
--- a/.agents/skills/upatch/SKILL.md
+++ b/.agents/skills/upatch/SKILL.md
@@ -1,9 +1,10 @@
---
name: upatch
-description: Write, build, sign, inspect and package a shirudo upatch. Covers the BPF C program written for the target kernels' preemption model and at a low cost on machines large and small, `shirudo build` for a .upatch and its unload directive, the Beefile and `shirudo bpm build` for a .bee package, `bpm info` to inspect one, `bpm push` and `bpm tree append` to publish, `bpm tree show` to read a publication back, and loading it on a test target. Use when asked to create, change or ship a upatch or a bpm package, or to reproduce a failed upatch build or load.
+description: Writes, builds, signs, inspects and packages a shirudo upatch. Covers the BPF C program written for the target kernels' preemption model and at a low cost on machines large and small, `shirudo build` for a .upatch and its unload directive, the Beefile and `shirudo bpm build` for a .bee package, `bpm info` to inspect one, `bpm push` and `bpm tree append` to publish, `bpm tree show` to read a publication back, and loading it on a test target. Use when asked to create, change or ship a upatch or a bpm package, or to reproduce a failed upatch build or load.
---
-# Upatch
+# upatch
+
`Documentation/upatches/` is the reference: `learn/concepts.rst`, then
under `write/` the attach kinds, maps, arenas and serializers, decoders,
@@ -110,9 +111,13 @@ needs, depends on the target kernels' preemption model
(`Documentation/upatches/write/memory-consistency/hazards.rst`). Settle
it before writing code that shares state:
-- When the task does not say which kernels the upatch is for, ask:
- distribution kernels (`PREEMPT_DYNAMIC`, booted `full` or `lazy`),
- `PREEMPT_RT`, `PREEMPT_LAZY` alone as the test VM runs, or a mix.
+- When the task does not say which kernels the upatch is for, write for
+ preemptible RCU, the weakest guarantee and what distribution kernels
+ give, so the code is right on every model, and say so in the reply:
+ the user may name distribution kernels (`PREEMPT_DYNAMIC`, booted
+ `full` or `lazy`), `PREEMPT_RT`, `PREEMPT_LAZY` alone as the test VM
+ runs, or a mix, which can let a guard go. Ask first only when a hot
+ path's cost turns on the answer.
- On a target, `CONFIG_PREEMPT_RCU` in `/proc/config.gz` or
`/boot/config-$(uname -r)` says whether RCU is preemptible, `uname -v`
names `PREEMPT_DYNAMIC` or `PREEMPT_RT`, and with `PREEMPT_DYNAMIC`