block: Introduce a BPF-based I/O scheduler
Subsystems (2)
v3 cover block: Introduce a BPF-based I/O scheduler
From: Kaitao Cheng <[email protected]>
Hi,
This is the third RFC version of UFQ (User-programmable Flexible Queueing), a BPF-based I/O scheduler for blk-mq. The goal is to let developers build and iterate on I/O scheduling policies as BPF programs, with userspace loaders handling configuration and attachment.
The code in this series is an intermediate version under active development and continued iteration. I am posting it to seek community feedback on whether the overall direction and design make sense, identify problems in the approach, and get suggestions for improving the design.
UFQ provides the block-layer integration and request lifecycle management. It exposes struct_ops callbacks for scheduler initialization and teardown, request insertion, dispatch, completion, and request and bio merging. Without an attached BPF scheduler, UFQ uses a simple per-ctx queueing policy. Once a BPF scheduler is attached, its callbacks implement the scheduling policy, while UFQ retains fallback handling for failed inserts and resumes its built-in policy after detach.
The series contains three patches:
1. Add the UFQ elevator, struct_ops interface, and request-management and merge kfuncs.
2. Add ufq_simple, a minimal BPF scheduler for exercising the UFQ interface, together with userspace loading helpers and build scaffolding.
3. Add PFQ (Priority Fair Queue), a newly developed BPF scheduler that demonstrates a more complete policy on top of UFQ.
PFQ gives us a concrete policy to explore how well the UFQ interface supports more involved scheduling decisions and to guide further work on the framework. It has not yet been used in production, and further testing and workload evaluation are needed.
The underlying BPF support needed by UFQ and its examples, including the graph APIs and support for KF_SPINLOCK_SAFE kfuncs, has been merged upstream. Those changes are therefore omitted from this version, which contains only the UFQ framework and its example schedulers.
TODO:
- More thorough correctness and stress testing, including scheduler transitions, merging, and error paths.
- Evaluate PFQ fairness, latency, and throughput across workloads.
- Split the kernel implementation into smaller patches for review.
In particular, I would appreciate suggestions on the boundary between the UFQ framework and BPF policies, the struct_ops interface, and request ownership and fallback handling. Feedback on alternative approaches or missing pieces would also help guide the next iteration.
Changes in v3:
- Add PFQ, its userspace loader, statistics, and usage documentation.
- Serialize BPF scheduler attach/detach and combine the callback enable state and user count into a single atomic state.
- Refine request reference handling and isolate failed BPF inserts on a separate fallback dispatch list.
- Use trylocks in merge kfuncs to avoid blocking on nested scheduler and ctx locks, and add a kfunc for setting request->elv.priv[1].
- Drop the BPF kfunc spin-lock support patch included in v2, since the required support has been merged upstream.
Changes in v2:
- Remove bpf_request_put (Alexei Starovoitov)
- Update the UFQ README (Miguel Ojeda)
- Add bio merge support
- Fix synchronization issues during UFQ scheduler transitions
Link to v2:
https://lore.kernel.org/all/[email protected]/
Link to v1:
https://lore.kernel.org/bpf/[email protected]/
Kaitao Cheng (3):
block: Introduce the UFQ I/O scheduler tools/ufq_iosched: add BPF example scheduler and build scaffolding tools/ufq_iosched: add PFQ eBPF I/O scheduler
block/Kconfig.iosched | 8 + block/Makefile | 1 + block/blk-merge.c | 28 +- block/blk-mq.c | 8 +- block/blk-mq.h | 2 +- block/blk.h | 5 + block/ufq-bpfops.c | 267 ++ block/ufq-iosched.c | 789 +++++ block/ufq-iosched.h | 79 + block/ufq-kfunc.c | 169 + tools/ufq_iosched/.gitignore | 2 + tools/ufq_iosched/Makefile | 262 ++ tools/ufq_iosched/README.md | 198 ++ .../include/bpf-compat/gnu/stubs.h | 7 + tools/ufq_iosched/include/ufq/common.bpf.h | 83 + tools/ufq_iosched/include/ufq/common.h | 87 + tools/ufq_iosched/include/ufq/pfq.bpf.h | 125 + tools/ufq_iosched/include/ufq/pfq_disk.h | 38 + tools/ufq_iosched/include/ufq/pfq_stat.h | 44 + tools/ufq_iosched/include/ufq/pfq_tunable.h | 23 + tools/ufq_iosched/include/ufq/simple_stat.h | 23 + tools/ufq_iosched/pfq.bpf.c | 2736 +++++++++++++++++ tools/ufq_iosched/pfq.c | 329 ++ tools/ufq_iosched/ufq_simple.bpf.c | 604 ++++ tools/ufq_iosched/ufq_simple.c | 120 + 25 files changed, 6024 insertions(+), 13 deletions(-) create mode 100644 block/ufq-bpfops.c create mode 100644 block/ufq-iosched.c create mode 100644 block/ufq-iosched.h create mode 100644 block/ufq-kfunc.c create mode 100644 tools/ufq_iosched/.gitignore create mode 100644 tools/ufq_iosched/Makefile create mode 100644 tools/ufq_iosched/README.md create mode 100644 tools/ufq_iosched/include/bpf-compat/gnu/stubs.h create mode 100644 tools/ufq_iosched/include/ufq/common.bpf.h create mode 100644 tools/ufq_iosched/include/ufq/common.h create mode 100644 tools/ufq_iosched/include/ufq/pfq.bpf.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_disk.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_stat.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_tunable.h create mode 100644 tools/ufq_iosched/include/ufq/simple_stat.h create mode 100644 tools/ufq_iosched/pfq.bpf.c create mode 100644 tools/ufq_iosched/pfq.c create mode 100644 tools/ufq_iosched/ufq_simple.bpf.c create mode 100644 tools/ufq_iosched/ufq_simple.c
Signature · 1 line
2.53.0
RFC v3 1/3 block: Introduce the UFQ I/O scheduler
From: Kaitao Cheng <[email protected]>
Introduce IOSCHED_UFQ, a blk-mq elevator ("ufq: User-programmable Flexible Queueing") whose policy is supplied by an eBPF program via struct_ops (insert, dispatch, merge, finish, etc.).
When no eBPF program is attached, the UFQ I/O scheduler uses a simple, per-ctx queueing policy (similar to none). After an eBPF program is attached, the user-defined scheduling policy replaces UFQ’s built-in queueing policy, while per-ctx queues remain available as a fallback mechanism.
--- block/Kconfig.iosched | 8 + block/Makefile | 1 + block/blk-merge.c | 28 +- block/blk-mq.c | 8 +- block/blk-mq.h | 2 +- block/blk.h | 5 + block/ufq-bpfops.c | 267 ++++++++++++++ block/ufq-iosched.c | 789 ++++++++++++++++++++++++++++++++++++++++++ block/ufq-iosched.h | 79 +++++ block/ufq-kfunc.c | 169 +++++++++ 10 files changed, 1343 insertions(+), 13 deletions(-) create mode 100644 block/ufq-bpfops.c create mode 100644 block/ufq-iosched.c create mode 100644 block/ufq-iosched.h create mode 100644 block/ufq-kfunc.c
block/Kconfig.iosched +8 -0
@@ -44,4 +44,12 @@ config BFQ_CGROUP_DEBUG Enable some debugging help. Currently it exports additional stat files in a cgroup which can be useful for debugging. +config IOSCHED_UFQ + tristate "UFQ I/O scheduler" + default y + help + The UFQ I/O scheduler is a programmable I/O scheduler. When + enabled, an out-of-kernel I/O scheduler based on eBPF can be + designed to interact with it, leveraging its customizable + hooks to redefine I/O scheduling policies. endmenu
block/Makefile +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_MQ_IOSCHED_DEADLINE) += mq-deadline.o obj-$(CONFIG_MQ_IOSCHED_KYBER) += kyber-iosched.o bfq-y := bfq-iosched.o bfq-wf2q.o bfq-cgroup.o obj-$(CONFIG_IOSCHED_BFQ) += bfq.o +obj-$(CONFIG_IOSCHED_UFQ) += ufq-iosched.o ufq-bpfops.o ufq-kfunc.o obj-$(CONFIG_BLK_DEV_INTEGRITY) += bio-integrity.o blk-integrity.o t10-pi.o \ bio-integrity-auto.o bio-integrity-fs.o
block/blk-merge.c +17 -11
@@ -771,8 +771,8 @@ u8 bio_seg_gap(struct request_queue *q, struct bio *prev, struct bio *next,* For non-mq, this has to be called with the request spinlock acquired. * For mq with scheduling, the appropriate queue wide lock should be held. */ -static struct request *attempt_merge (struct request_queue *q, -struct request *req,struct request *next) +static struct request *attempt_merge (struct request_queue *q,struct request *req, +struct request *next,bool nohash) {if (!rq_mergeable (req) || !rq_mergeable (next))return NULL ;
@@ -839,7 +839,7 @@ static struct request *attempt_merge(struct request_queue *q, req->__data_len +=blk_rq_bytes (next); -if (!blk_discard_mergable (req)) +if (!nohash && !blk_discard_mergable (req))elv_merge_requests (q, req, next);blk_crypto_rq_put_keyslot (next);
@@ -865,7 +865,7 @@ static struct request *attempt_back_merge(struct request_queue *q,struct request *next =elv_latter_request (q, rq);if (next) -return attempt_merge (q, rq, next); +return attempt_merge (q, rq, next, false);return NULL ; }
@@ -876,11 +876,17 @@ static struct request *attempt_front_merge(struct request_queue *q,struct request *prev =elv_former_request (q, rq);if (prev) -return attempt_merge (q, prev, rq); +return attempt_merge (q, prev, rq, false);return NULL ; } +struct request *bpf_attempt_merge (struct request_queue *q,struct request *rq, +struct request *next) +{ +return attempt_merge (q, rq, next, true); +} +/* * Try to merge 'next' into 'rq'. Return true if the merge happened, false * otherwise. The caller is responsible for freeing 'next' if the merge
@@ -889,7 +895,7 @@ static struct request *attempt_front_merge(struct request_queue *q,bool blk_attempt_req_merge (struct request_queue *q,struct request *rq,struct request *next) { -return attempt_merge (q, rq, next); +return attempt_merge (q, rq, next, false); }bool blk_rq_merge_ok (struct request *rq,struct bio *bio)
@@ -1032,11 +1038,11 @@ static enum bio_merge_status bio_attempt_discard_merge(struct request_queue *q,return BIO_MERGE_FAILED ; } -static enum bio_merge_status blk_attempt_bio_merge (struct request_queue *q, -struct request *rq, -struct bio *bio, -unsigned int nr_segs, -bool sched_allow_merge) +enum bio_merge_status blk_attempt_bio_merge (struct request_queue *q, +struct request *rq, +struct bio *bio, +unsigned int nr_segs, +bool sched_allow_merge) {if (!blk_rq_merge_ok (rq, bio))return BIO_MERGE_NONE ;
block/blk-mq.c +7 -1
@@ -796,7 +796,7 @@ static void blk_mq_finish_request(struct request *rq) } } -static void __blk_mq_free_request (struct request *rq) +void __blk_mq_free_request (struct request *rq) {struct request_queue *q = rq->q;struct blk_mq_ctx *ctx = rq->mq_ctx;
@@ -1813,6 +1813,12 @@ static bool dispatch_rq_from_ctx(struct sbitmap *sb, unsigned int bitnr,if (list_empty (&ctx->rq_lists[type]))sbitmap_clear_bit (sb, bitnr); } + +if (dispatch_data->rq) { + dispatch_data->rq->rq_flags |=RQF_STARTED ; +if (hctx->queue->last_merge == dispatch_data->rq) + hctx->queue->last_merge =NULL ; + }spin_unlock (&ctx->lock);return !dispatch_data->rq;
block/blk-mq.h +1 -1
@@ -56,7 +56,7 @@ void blk_mq_flush_busy_ctxs(struct blk_mq_hw_ctx *hctx, struct list_head *list);struct request *blk_mq_dequeue_from_ctx (struct blk_mq_hw_ctx *hctx,struct blk_mq_ctx *start);void blk_mq_put_rq_ref (struct request *rq); - +void __blk_mq_free_request (struct request *rq);/* * Internal helpers for allocating/freeing the request map */
block/blk.h +5 -0
@@ -340,6 +340,9 @@ enum bio_merge_status {enum bio_merge_status bio_attempt_back_merge (struct request *req,struct bio *bio,unsigned int nr_segs); +enum bio_merge_status blk_attempt_bio_merge (struct request_queue *q, +struct request *rq,struct bio *bio,unsigned int nr_segs, +bool sched_allow_merge);bool blk_attempt_plug_merge (struct request_queue *q,struct bio *bio,unsigned int nr_segs); bool blk_bio_list_merge(struct request_queue *q, struct list_head *list,
@@ -473,6 +476,8 @@ static inline unsigned get_max_segment_size(const struct queue_limits *lim,int ll_back_merge_fn (struct request *req,struct bio *bio,unsigned int nr_segs); +struct request *bpf_attempt_merge (struct request_queue *q,struct request *rq, +struct request *next);bool blk_attempt_req_merge (struct request_queue *q,struct request *rq,struct request *next);unsigned int blk_recalc_rq_segments (struct request *rq);
block/ufq-bpfops.c new file +267 -0
267 lines not on this page · raw message
block/ufq-iosched.c new file +789 -0
789 lines not on this page · raw message
block/ufq-iosched.h new file +79 -0
79 lines not on this page · raw message
block/ufq-kfunc.c new file +169 -0
169 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [RFC v3 1/3] block: Introduce the UFQ I/O scheduler
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider: - [Critical] block: ufq_bio_merge() destroys active target request leading to UAF - [Critical] block…
Thank you for your contribution! Sashiko AI review found 11 potential issue(s) to consider:
- [Critical] block: ufq_bio_merge() destroys active target request leading to UAF
- [Critical] block: missing state validation in UFQ merges allows corruption of in-flight requests
- [Critical] bpf: unbounded stack buffer overflow in UFQ struct_ops via PTR_TO_BUF
- [High] bpf: bpf_request_try_merge() permanently leaks absorbed requests
- [High] block: ufq_insert_requests() re-inserts requests that absorbed a back-merge
- [High] bpf: incompatible reference contract in dispatch_req leads to UAF
- [High] block: TOCTOU Use-After-Free in UFQ merge and dispatch paths
- [High] bpf: bpf_request_bio_try_merge() allows double-merging of bios causing list corruption
- [High] bpf: bpf_request_try_merge() crashes on already-merged requests
- [Medium] bpf: spin_trylock() inside KF_SPINLOCK_SAFE causes Invalid wait context on PREEMPT_RT
- [Low] block: modpost failure due to missing EXPORT_SYMBOL_GPL for core functions --
commit 439b7e4704107bb499b42ef24fd4ef9ddf9e15ea
Author: Kaitao Cheng <[email protected]>
block: Introduce the UFQ I/O scheduler
Introduce IOSCHED_UFQ, a blk-mq elevator ("ufq: User-programmable Flexible Queueing") whose policy is supplied by an eBPF program via struct_ops (insert, dispatch, merge, finish, etc.).
block/blk-mq.c static void blk_mq_finish_request(struct request *rq) · line 813
Quoted 11 lines
block/blk-mq.c +1
-1@@ -809,7 +809,7 @@ static void blk_mq_finish_request(struct request *rq) } } -static void __blk_mq_free_request (struct request *rq) +void __blk_mq_free_request (struct request *rq) {
[Severity: Low]
Will this cause a modpost failure?
CONFIG_IOSCHED_UFQ can be compiled as a module, and it calls __blk_mq_free_request(), bpf_attempt_merge(), and blk_attempt_bio_merge(). Since these core block layer functions are not exported via EXPORT_SYMBOL_GPL, linking the module will fail during modpost.
Quoted 10 lines
block/ufq-bpfops.c new file +4
-0+static bool bpf_ufq_is_valid_access (int off,int size, +enum bpf_access_type type, +const struct bpf_prog *prog, +struct bpf_insn_access_aux *info)
block/ufq-bpfops.c line 87
Quoted 10 lines
block/ufq-bpfops.c new file +9
-0+{ +if (size ==sizeof (__u64) && prog->aux->attach_func_name && + ((!strcmp (prog->aux->attach_func_name,"merge_req" ) && off ==16 ) || + (!strcmp (prog->aux->attach_func_name,"merge_bio" ) && off ==24 ))) { +if (!btf_ctx_access (off, size, type, prog, info)) +return false; + info->reg_type =PTR_TO_BUF ; +return true; + }
[Severity: Critical]
Does this allow an unbounded stack buffer overflow?
The verifier is told to treat the pointer as a variable-sized buffer (PTR_TO_BUF) to allow pointer writes, but the subsystem fails to validate the size against the actual variable size in the check_member callback. A malicious BPF program can write out of bounds into the stack variables passed to merge_req and merge_bio.
Quoted 8 lines
block/ufq-iosched.c new file +2
-0+static struct request *ufq_dispatch_request (struct blk_mq_hw_ctx *hctx) +{
block/ufq-iosched.c line 163
Quoted 10 lines
block/ufq-iosched.c new file +9
-0+/* +* The BPF insert_req callback bumps the request's reference +* count; dispatch_req returns that same request with an extra +* reference held. The kernel must put that reference here, +* and the request's refcount is always greater than zero at +* this point. +*/ +if (WARN_ON_ONCE (req_ref_put_and_test (rq))) { +__blk_mq_free_request (rq);
[Severity: High]
Is the reference contract here incompatible with the BPF verifier?
ufq_dispatch_request() expects BPF to transfer an acquired reference. However, BPF struct_ops do not support returning acquired references. To bypass the verifier, a BPF program must return an unacquired pointer, which causes the kernel to decrement the core reference count instead of an extra one, freeing an active request prematurely.
block/ufq-iosched.c line 169
Quoted 6 lines
block/ufq-iosched.c new file +6
-0+ufq_bpfops_put (); +return NULL ; + } + + ctx = rq->mq_ctx; +spin_lock (&ctx->lock);
[Severity: High]
Does this expose a Time-of-Check to Time-of-Use race?
The BPF-owned reference is dropped via req_ref_put_and_test() before dereferencing rq->mq_ctx and acquiring the lock. If the request completes concurrently during this window, the reference count drops to zero and it is freed, resulting in a Use-After-Free.
Quoted 5 lines
[ ... ]
block/ufq-iosched.c new file +3
-0+static bool ufq_bio_merge (struct request_queue *q,struct bio *bio, +unsigned int nr_segs) +{
block/ufq-iosched.c line 449
Quoted 10 lines
block/ufq-iosched.c new file +10
-0+if (rq) { +spin_lock (&rq->mq_ctx->lock); +if (!list_empty (&rq->queuelist)) { +list_del_init (&rq->queuelist); +atomic_dec (&ufq->rqs_count); + } +spin_unlock (&rq->mq_ctx->lock); +/* merge_bio transfers an extra BPF-owned reference. */ +WARN_ON_ONCE (req_ref_put_and_test (rq)); +blk_mq_free_request (rq);
[Severity: Critical]
Does this cause a Use-After-Free by destroying the active target request?
If the BPF policy's merge_bio hook successfully merges a bio into a request, it returns the target rq. The kernel then erroneously calls blk_mq_free_request(rq), actively destroying the target request that is still waiting for dispatch instead of just dropping the BPF reference.
block/ufq-iosched.c line 497
Quoted 8 lines
[ ... ]
block/ufq-iosched.c new file +6
-0+static enum elv_merge ufq_try_insert_merge (struct request_queue *q, +struct request **new) +{ + ops =ufq_bpfops_tryget (); +if (ops && ops->merge_req) { + target = ops->merge_req (q, rq, &merge_type);
[Severity: Critical]
Can this overflow the merge_type stack variable?
This points to the stack variable merge_type which is passed to the BPF program via PTR_TO_BUF without proper bounds checking, leading to local privilege escalation.
block/ufq-iosched.c line 502
Quoted 5 lines
block/ufq-iosched.c new file +5
-0+ type = (enum elv_merge )merge_type; + } + +if (target &&WARN_ON_ONCE (req_ref_put_and_test (target))) { +__blk_mq_free_request (target);
[Severity: High]
Does this introduce a Time-of-Check to Time-of-Use race?
The BPF-owned reference on the target request is dropped via req_ref_put_and_test() before taking target->mq_ctx->lock and validating the request. If the request completes concurrently during this window, the reference count drops to zero and it is freed, resulting in a Use-After-Free when dereferencing target->mq_ctx later in this function.
block/ufq-iosched.c line 514
Quoted 12 lines
block/ufq-iosched.c new file +12
-0+ufq_bpfops_put (); +return ELEVATOR_NO_MERGE ; + } + +if (type ==ELEVATOR_NO_MERGE || !target) { +if (ops) +ufq_bpfops_put (); +return ELEVATOR_NO_MERGE ; + }else if (type ==ELEVATOR_FRONT_MERGE ) { +if (rq->mq_ctx != target->mq_ctx || rq->mq_hctx != target->mq_hctx) + goto rollback; +spin_lock (&target->mq_ctx->lock);
[Severity: Critical]
Is there a missing state validation here?
The BPF merge_req callback blindly returns an arbitrary target request. There is no verification that the target request belongs to the correct queue, nor that its state is MQ_RQ_IDLE. Modifying an in-flight request concurrently with active DMA transfers corrupts data.
block/ufq-iosched.c line 604
Quoted 10 lines
[ ... ]
block/ufq-iosched.c new file +8
-0+static void ufq_insert_requests (struct blk_mq_hw_ctx *hctx, +struct list_head *list, +blk_insert_t flags) +{ +if (ops && rq && ops->insert_req) { + rq->elv.priv[0 ] = (void *)((uintptr_t )rq->elv.priv[0 ] + |UFQ_PRIV_IN_BPF ); + ret = ops->insert_req (q, rq, flags);
[Severity: High]
Does this cause double-insertion for requests that absorbed a back-merge?
If ufq_try_insert_merge() results in an ELEVATOR_BACK_MERGE, rq is updated to point to the target request. This function then unconditionally calls ops->insert_req() on this pre-existing target request, corrupting the BPF scheduler's internal tracking.
Quoted 9 lines
block/ufq-kfunc.c new file +2
-0@@ -0,0 +1,169 @@ +__bpf_kfunc bool bpf_request_bio_try_merge(struct request *rq, struct bio *bio, +unsigned int nr_segs)
block/ufq-kfunc.c line 56
Quoted 10 lines
block/ufq-kfunc.c new file +9
-0+{ +/* +* KF_SPINLOCK_SAFE callers (BPF merge_bio) often already hold a scheduler +* lock taken with irqsave (e.g. PFQ dd->lock). Blocking on ctx->lock +* nesting that order deadlocks / hard-locks under load. Trylock: skip +* the merge if ctx is busy; bio will be issued as a new request. +*/ +if (!spin_trylock (&ctx->lock)) + goto out;
[Severity: Medium]
Will this cause an Invalid wait context warning on PREEMPT_RT?
This kfunc is annotated with KF_SPINLOCK_SAFE, meaning it can execute with interrupts disabled or a raw_spinlock_t held. Calling spin_trylock() inside this context violates strict lock nesting rules, as it maps to an rt_mutex operation on PREEMPT_RT.
block/ufq-kfunc.c line 58
Quoted 2 lines
block/ufq-kfunc.c new file +2
-0+ + merged =blk_attempt_bio_merge (q, rq, bio, nr_segs, true) ==BIO_MERGE_OK ;
[Severity: Critical]
Is there missing state validation for the target request here?
The kfunc modifies the target request's internal structures without verifying that its state is MQ_RQ_IDLE, which can corrupt data if the request is already in-flight.
[Severity: High]
Can a BPF program trigger double-merging of bios here?
Because sector proximity checks will still pass and there is no safeguard against already-merged bios, calling this kfunc multiple times with the same bio will link it into the biotail of multiple requests, corrupting the bi_next pointers.
block/ufq-kfunc.c line 93
Quoted 5 lines
[ ... ]
block/ufq-kfunc.c new file +3
-0+__bpf_kfunc struct request *bpf_request_try_merge(struct request *rq, struct request *next) +{ + free =bpf_attempt_merge (q, rq, next);
[Severity: High]
Can this code crash by dereferencing a NULL pointer?
If bpf_request_try_merge() successfully absorbs a request, the block layer sets next->bio = NULL. If the BPF program erroneously calls this kfunc again on the already-absorbed request, attempt_merge() will unconditionally dereference next->bio->bi_write_hint.
block/ufq-kfunc.c line 133
Quoted 6 lines
[ ... ]
block/ufq-kfunc.c new file +5
-0+BTF_KFUNCS_START(ufq_kfunc_set_ops) +BTF_ID_FLAGS(func, bpf_request_acquire, KF_ACQUIRE | KF_RET_NULL) +BTF_ID_FLAGS(func, bpf_request_release, KF_RELEASE) +BTF_ID_FLAGS(func, bpf_request_bio_try_merge, KF_SPINLOCK_SAFE) +BTF_ID_FLAGS(func, bpf_request_try_merge, KF_SPINLOCK_SAFE)
[Severity: High]
Does this code permanently leak the absorbed request?
bpf_request_try_merge() returns the redundant absorbed request, but without the KF_ACQUIRE flag, the BPF verifier treats it as an unreferenced pointer. The BPF program cannot legally free it via bpf_request_release(), and the kernel omits freeing it, resulting in a permanent leak and eventual exhaustion of block tags.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
RFC v3 2/3 tools/ufq_iosched: add BPF example scheduler and build scaffolding
In reply to Kaitao ChengFrom: Kaitao Cheng <[email protected]>
Add ufq_iosched as a simple example for the UFQ block I/O scheduler, In the ufq_simple example, we implement the eBPF struct_ops hooks the kernel exposes so we can exercise and validate the behavior and stability of the kernel UFQ scheduling framework. The Makefile and directory layout are modeled after sched_ext.
This mirrors the sched_ext examples pattern so developers can experiment with user-defined queueing policies on top of IOSCHED_UFQ.
--- tools/ufq_iosched/.gitignore | 2 + tools/ufq_iosched/Makefile | 262 ++++++++ tools/ufq_iosched/README.md | 145 +++++ .../include/bpf-compat/gnu/stubs.h | 7 + tools/ufq_iosched/include/ufq/common.bpf.h | 83 +++ tools/ufq_iosched/include/ufq/common.h | 87 +++ tools/ufq_iosched/include/ufq/simple_stat.h | 23 + tools/ufq_iosched/ufq_simple.bpf.c | 604 ++++++++++++++++++ tools/ufq_iosched/ufq_simple.c | 120 ++++ 9 files changed, 1333 insertions(+) create mode 100644 tools/ufq_iosched/.gitignore create mode 100644 tools/ufq_iosched/Makefile create mode 100644 tools/ufq_iosched/README.md create mode 100644 tools/ufq_iosched/include/bpf-compat/gnu/stubs.h create mode 100644 tools/ufq_iosched/include/ufq/common.bpf.h create mode 100644 tools/ufq_iosched/include/ufq/common.h create mode 100644 tools/ufq_iosched/include/ufq/simple_stat.h create mode 100644 tools/ufq_iosched/ufq_simple.bpf.c create mode 100644 tools/ufq_iosched/ufq_simple.c
tools/ufq_iosched/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +tools/ +build/
tools/ufq_iosched/Makefile new file +262 -0
262 lines not on this page · raw message
tools/ufq_iosched/README.md new file +145 -0
145 lines not on this page · raw message
tools/ufq_iosched/include/bpf-compat/gnu/stubs.h new file +7 -0
@@ -0,0 +1,7 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* BPF builds can reach glibc headers through Clang's host include paths. +* On x86, the BPF target leaves __x86_64__ undefined, causing gnu/stubs.h +* to include stubs-32.h, which may be absent without 32-bit glibc headers. +* Put this empty substitute before the system headers in BPF include paths. +*/
tools/ufq_iosched/include/ufq/common.bpf.h new file +83 -0
83 lines not on this page · raw message
tools/ufq_iosched/include/ufq/common.h new file +87 -0
87 lines not on this page · raw message
tools/ufq_iosched/include/ufq/simple_stat.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2026 KylinSoft Corporation. +* Copyright (c) 2026 Kaitao Cheng <[email protected]> +*/ +#ifndef __UFQ_SIMPLE_STAT_H +#define __UFQ_SIMPLE_STAT_H + +enum ufq_simp_stat_index { +UFQ_SIMP_INSERT_CNT , +UFQ_SIMP_INSERT_SIZE , +UFQ_SIMP_DISPATCH_CNT , +UFQ_SIMP_DISPATCH_SIZE , +UFQ_SIMP_RQMERGE_CNT , +UFQ_SIMP_RQMERGE_SIZE , +UFQ_SIMP_BIOMERGE_CNT , +UFQ_SIMP_BIOMERGE_SIZE , +UFQ_SIMP_FINISH_CNT , +UFQ_SIMP_FINISH_SIZE , +UFQ_SIMP_STAT_MAX , +}; + +#endif /* __UFQ_SIMPLE_STAT_H */
tools/ufq_iosched/ufq_simple.bpf.c new file +604 -0
604 lines not on this page · raw message
tools/ufq_iosched/ufq_simple.c new file +120 -0
120 lines not on this page · raw message
Signature · 1 line
2.53.0
[email protected]
AI reviewRe: [RFC v3 2/3] tools/ufq_iosched: add BPF example scheduler and build scaffolding
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] ufq_iosched: bpf_rbtree_left() returns structural child missing logical predecessor --
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] ufq_iosched: bpf_rbtree_left() returns structural child missing logical predecessor --
commit 64af8341d2a8ec597c3320deffd60d7e970c5a0d
Author: Kaitao Cheng <[email protected]>
Subject: tools/ufq_iosched: add BPF example scheduler and build scaffolding
Add ufq_iosched as a simple example for the UFQ block I/O scheduler. In the ufq_simple example, we implement the eBPF struct_ops hooks the kernel exposes so we can exercise and validate the behavior and stability of the kernel UFQ scheduling framework.
tools/ufq_iosched/ufq_simple.bpf.c new file +0 -0
[ ... ]
Quoted 7 lines
(quoted diff) +7
-0+static struct request *merge_bio_left_unlock(struct ufq_simple_data *ufq_sd, + struct bpf_rb_root *tree, + struct sort_tree_node *snode, + struct request *cand) +{ + struct sort_tree_node *left_node = NULL, *owned; + sector_t cand_start, left_start, left_end;
Review
Quoted 10 lines
(quoted diff) +10
-0+ struct bpf_rb_node *tmp, *removed = NULL; + struct request *left_rq = NULL; + bool merged = false; + + cand_start = cand->__sector; + tmp = bpf_rbtree_left(tree, &snode->rb_node); + if (!tmp) + goto end; + + left_node = container_of(tmp, struct sort_tree_node, rb_node);
[Severity: Medium]
Will bpf_rbtree_left() return the structural left child of the RB-tree node instead of the logically adjacent predecessor in the sorted order?
If the logical predecessor is an ancestor or the rightmost node of the left subtree, will this structural check test the wrong node and miss valid double merge opportunities for I/O requests?
[ ... ]
Quoted 8 lines
(quoted diff) +8
-0+static struct request *merge_bio_right_unlock(struct ufq_simple_data *ufq_sd, + struct bpf_rb_root *tree, + struct sort_tree_node *snode, + struct request *cand) +{ + struct bpf_rb_node *right_rb, *removed = NULL; + struct sort_tree_node *right_node = NULL; + struct request *right_rq = NULL;
Review
Quoted 10 lines
(quoted diff) +10
-0+ sector_t cand_end, right_start; + bool merged = false; + + cand_end = cand->__sector + (cand->__data_len >> SECTOR_SHIFT); + + right_rb = bpf_rbtree_right(tree, &snode->rb_node); + if (!right_rb) + goto end; + + right_node = container_of(right_rb, struct sort_tree_node, rb_node);
[Severity: Medium]
Does bpf_rbtree_right() return the structural right child instead of the logically adjacent successor?
Similar to the left check above, will this structural check bypass valid double merge opportunities when the logical successor is not the direct right child?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
RFC v3 3/3 tools/ufq_iosched: add PFQ eBPF I/O scheduler
In reply to Kaitao ChengFrom: Kaitao Cheng <[email protected]>
Add a Priority Fair Queue (PFQ) eBPF I/O scheduler to the UFQ framework, providing weighted fair scheduling and preferential service for configured interactive threads.
Organize requests into some logical queues per disk by priority class, priority level and I/O type. Select queues by virtual time and charge service according to request size and queue weight, with bounded dispatch batches. Within each queue, serve expired FIFO requests first, otherwise prefer metadata and shorter seek distances. Dispatch requests inserted with BLK_MQ_INSERT_AT_HEAD before the fair queues.
Support adjacent request and bio merging through sector-ordered indexes. Give interactive read queues additional weight and allow empty queues to briefly retain their service slot, with idle expiry checked by subsequent scheduler callbacks.
Add a userspace loader to initialize scheduling tunables, configure interactive threads by exact task comm using repeated -i options, and report throughput, IOPS, queue state and scheduler event counters.
This is an intermediate version under active development and continued iteration. It has not yet been used in production.
--- tools/ufq_iosched/Makefile | 2 +- tools/ufq_iosched/README.md | 55 +- tools/ufq_iosched/include/ufq/pfq.bpf.h | 125 + tools/ufq_iosched/include/ufq/pfq_disk.h | 38 + tools/ufq_iosched/include/ufq/pfq_stat.h | 44 + tools/ufq_iosched/include/ufq/pfq_tunable.h | 23 + tools/ufq_iosched/pfq.bpf.c | 2736 +++++++++++++++++++ tools/ufq_iosched/pfq.c | 329 +++ 8 files changed, 3350 insertions(+), 2 deletions(-) create mode 100644 tools/ufq_iosched/include/ufq/pfq.bpf.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_disk.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_stat.h create mode 100644 tools/ufq_iosched/include/ufq/pfq_tunable.h create mode 100644 tools/ufq_iosched/pfq.bpf.c create mode 100644 tools/ufq_iosched/pfq.c
tools/ufq_iosched/Makefile +1 -1
@@ -192,7 +192,7 @@ $(INCLUDE_DIR)/%.bpf.skel.h: $(UFQOBJ_DIR)/%.bpf.o $(INCLUDE_DIR)/vmlinux.h $(BP UFQ_COMMON_DEPS := include/ufq/common.h include/ufq/simple_stat.h | $(BINDIR) -c-sched-targets = ufq_simple +c-sched-targets = ufq_simple pfq $(addprefix $(BINDIR)/,$(c-sched-targets)): \ $(BINDIR)/%: \
tools/ufq_iosched/README.md +54 -1
61 lines not on this page · raw message
tools/ufq_iosched/include/ufq/pfq.bpf.h new file +125 -0
125 lines not on this page · raw message
tools/ufq_iosched/include/ufq/pfq_disk.h new file +38 -0
@@ -0,0 +1,38 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2026 KylinSoft Corporation. +* Copyright (c) 2026 Kaitao Cheng <[email protected]> +* Copyright (c) 2026 Li Youhong <[email protected]> +* +* Userspace prefix of struct pfq_disk_data through nr_queued_total. +* Keep field types and order in sync with pfq.bpf.c. +* +* Lookup must use a buffer of bpf_map__value_size(); this prefix is safe +* to interpret when the map value is at least sizeof(*this). +*/ +#ifndef __PFQ_DISK_H +#define __PFQ_DISK_H + +#include <linux/bpf.h> +#include <stdint.h> +#include <ufq/pfq.bpf.h> + +typedef int32_t s32 ; +typedef uint32_t u32 ; +typedef uint64_t u64 ; + +struct pfq_disk_data_user { +struct bpf_spin_lock lock; +struct bpf_list_head dispatch; +struct bpf_rb_root service_tree; +struct bpf_rb_root rq_trees[PFQ_RQ_TREES ]; +struct bpf_rb_root fifo_trees[PFQ_RQ_TREES ]; +s32 disk_id; +u64 vtime; +u64 min_vtime; +u64 last_sector; +u32 nr_active; +u32 nr_queued_total; +}; + +#endif /* __PFQ_DISK_H */
tools/ufq_iosched/include/ufq/pfq_stat.h new file +44 -0
44 lines not on this page · raw message
tools/ufq_iosched/include/ufq/pfq_tunable.h new file +23 -0
@@ -0,0 +1,23 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (c) 2026 KylinSoft Corporation. +* Copyright (c) 2026 Kaitao Cheng <[email protected]> +* Copyright (c) 2026 Li Youhong <[email protected]> +*/ +#ifndef __PFQ_TUNABLE_H +#define __PFQ_TUNABLE_H + +#include <ufq/pfq.bpf.h> + +#define PFQ_TUNABLE_KEY 0 + +struct pfq_tunables { +__u32 weight_base; +__u32 idle_delay_min_ms; +__u32 idle_delay_max_ms; +__u32 batch_read; +__u32 batch_sync_write; +__u32 batch_write; +}; + +#endif /* __PFQ_TUNABLE_H */
tools/ufq_iosched/pfq.bpf.c new file +2736 -0
2,701 lines not on this page · raw message
tools/ufq_iosched/pfq.c new file +329 -0
329 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.53.0
Part of the diff is not shown here. View the raw message.
[email protected]
AI reviewRe: [RFC v3 3/3] tools/ufq_iosched: add PFQ eBPF I/O scheduler
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider: - [Critical] bpf: load failure due to unsupported special BTF fields in PERCPU_ARRAY - [Critical] bpf…
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
- [Critical] bpf: load failure due to unsupported special BTF fields in PERCPU_ARRAY
- [Critical] bpf: verifier rejection due to direct BTF field writes and PTR_UNTRUSTED usage
- [High] bpf: RB-tree corruption via in-place sorting key modification
- [High] block: permanent I/O stall when waiting for SPECIAL+READ queues
- [High] bpf: lock inversion and PREEMPT_RT violation in insert error path --
commit b7bd634a597878034765fedd606831b034490328
Author: Kaitao Cheng <[email protected]>
tools/ufq_iosched: add PFQ eBPF I/O scheduler
Add a Priority Fair Queue (PFQ) eBPF I/O scheduler to the UFQ framework. It supports weighted fair scheduling, request merging, and preferential service for configured interactive threads.
Quoted 5 lines
tools/ufq_iosched/pfq.bpf.c new file +0
-0
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 185
Quoted 6 lines
tools/ufq_iosched/pfq.bpf.c new file +6
-0+struct { + __uint(type, BPF_MAP_TYPE_PERCPU_ARRAY); + __uint(max_entries, 1); + __type(key, u32); + __type(value, struct pfq_disk_data); +} pfq_disk_scratch SEC(".maps");
[Severity: Critical]
Can the verifier load this program?
The pfq_disk_scratch map is a BPF_MAP_TYPE_PERCPU_ARRAY, but its value type struct pfq_disk_data contains a bpf_spin_lock, bpf_list_head, and bpf_rb_root.
The verifier natively rejects special BTF fields in per-CPU arrays via map_check_btf(), returning -EOPNOTSUPP.
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 950
Quoted 5 lines
tools/ufq_iosched/pfq.bpf.c new file +5
-0+static void pfq_disk_scratch_reset (struct pfq_disk_data *d) +{ +u32 i; + + d->lock = (struct bpf_spin_lock ){};
[Severity: Critical]
Is it valid to write directly to opaque special BTF fields?
The verifier strictly forbids direct assignments to bpf_spin_lock and graph nodes.
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1516
Quoted 6 lines
tools/ufq_iosched/pfq.bpf.c new file +6
-0+static void pfq_finish_front_bio_merge (struct pfq_disk_data *dd, +struct pfq_queue_data *queue, +struct pfq_rq_core *rn, +u64 new_sector) +{ + rn->sector = new_sector;
[Severity: High]
Does this corrupt the fifo_trees RB-tree?
This modifies rn->sector while rn is still linked in the FIFO tree. The sector field is used as a tie-breaker sorting key in fifo_less().
[ ... ]
Quoted 14 lines
tools/ufq_iosched/pfq.bpf.c new file +14
-0+static __noinline int +pfq_insert_core_locked (struct pfq_disk_data *dd, +struct pfq_queue_data *queue, +struct pfq_rq_core *core, +struct request *rq, +struct pfq_insert_cleanup *cleanup) +{ +struct pfq_rq_core *list_ref, *list_n, *tree_n, *held =NULL ; +struct bpf_rb_root *rq_root =pfq_rq_tree (dd, queue->qid); +struct bpf_rb_root *fifo_root =pfq_fifo_tree (dd, queue->qid); +struct request *old; + + list_ref =bpf_refcount_acquire (core); +if (!list_ref) {
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1670
Quoted 1 line
tools/ufq_iosched/pfq.bpf.c new file +1
-0+if (!rq_root ||bpf_rbtree_add (rq_root, &core->rb_node, rq_less)) {
[Severity: High]
Does this error path introduce a lock inversion and panic on PREEMPT_RT kernels?
If bpf_rbtree_add() fails, the BPF core synchronously drops the consumed node, triggering the destructor bpf_request_release() for its inner kptr.
Because dd->lock is held (a bpf_spin_lock mapping to a raw spinlock), and bpf_request_release() calls __blk_mq_free_request() which acquires a sleepable spinlock on PREEMPT_RT systems, this violates atomic context rules.
This also applies to pfq_dispatch_push_dn() in pfq_insert_req().
[ ... ]
Quoted 2 lines
tools/ufq_iosched/pfq.bpf.c new file +2
-0+if (!fifo_root || +bpf_rbtree_add (fifo_root, &list_ref->fifo_rb_node, fifo_less)) {
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1697
Quoted 5 lines
tools/ufq_iosched/pfq.bpf.c new file +5
-0+/* +* Keep an owning reference for activation rollback or final cleanup. +* Successful insertion retains both tree references independently. +*/ + held =bpf_refcount_acquire (core);
[Severity: Critical]
Can core be acquired here after it was passed to bpf_rbtree_add() earlier in this function?
The tree insertion consumes the owning reference, making this a use-after-consume that the verifier will reject.
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1748
Quoted 13 lines
tools/ufq_iosched/pfq.bpf.c new file +13
-0+static void pfq_update_queue_vtime (struct pfq_disk_data *dd, +struct pfq_queue_data *queue, +u32 sectors) +{ +u64 delta; + +if (queue->vtime < dd->vtime) + queue->vtime = dd->vtime; + delta = ((u64 )sectors <<PFQ_VTIME_SHIFT ) / queue->weight; +/* Integer truncation must not give small requests free service. */ +if (sectors && !delta) + delta =1 ; + queue->vtime += delta;
[Severity: High]
Does this corrupt the service_tree RB-tree?
This modifies queue->vtime while queue remains actively linked in the tree, altering its sorting key in place.
[ ... ]
Quoted 4 lines
tools/ufq_iosched/pfq.bpf.c new file +4
-0+static void pfq_start_idle_hold (struct pfq_disk_data *dd, +struct pfq_queue_data *queue,u64 now,u32 random, +struct pfq_stats *stats) +{
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1780
Quoted 2 lines
tools/ufq_iosched/pfq.bpf.c new file +2
-0+WRITE_ONCE (dd->idle_queue_qid, queue->qid); + dd->waiting_idle = true;
[Severity: High]
When an empty SPECIAL read queue is selected, pfq_start_idle_hold() sets dd->waiting_idle = true, causing the dispatcher to return NULL below.
Does this permanently stall the block layer queue?
Returning NULL instructs the block layer that no requests are available. Since the scheduler does not explicitly arm a block layer timer or delayed workqueue to resume dispatching when the idle deadline passes, the system will never wake up to check the deadline unless another I/O request is coincidentally inserted.
[ ... ]
tools/ufq_iosched/pfq.bpf.c line 1847
Quoted 8 lines
tools/ufq_iosched/pfq.bpf.c new file +8
-0+static int pfq_init_queue_fields (struct pfq_disk_data *dd,u32 idx) +{ +struct pfq_queue_data *queue =pfq_queue_scalar (dd, idx); + +if (!queue) +return -ENOENT ; + + queue->qid = idx;
[Severity: Critical]
Can we write to queue here?
pfq_queue_scalar() returns an unacquired pointer (PTR_UNTRUSTED) from a map lookup. The verifier forbids writing to untrusted kptrs.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
Quoted 4 lines · Kaitao Cheng
PFQ gives us a concrete policy to explore how well the UFQ interface supports more involved scheduling decisions and to guide further work on the framework. It has not yet been used in production, and further testing and workload evaluation are needed.
Third version in six months and still not a single number. v2 got replies from the bots only.
Without a solid use case there is no point in polishing this.
Quoted 3 lines
In particular, I would appreciate suggestions on the boundary between the UFQ framework and BPF policies, the
struct_opsinterface, and request ownership and fallback handling.
One global ufq_ops for all disks is not the best shape. I'd do it like bpf_qdisc.
The ownership is the bigger problem.
The request sits in ctx->rq_lists and in a bpf map at the same time and the kernel relies on the prog to keep the two in sync. The prog holds rq->ref. rq holds q_usage_counter until __blk_mq_free_request(). One request that the prog didn't return from dispatch_req or left in a map and blk_mq_freeze_queue() waits forever.sched_ext has a watchdog that kicks the bpf scheduler out. Something like that is necessary here too.
pw-bot: cr
Quoted 9 lines · Alexei Starovoitov
Quoted 4 lines · Kaitao Cheng
PFQ gives us a concrete policy to explore how well the UFQ interface supports more involved scheduling decisions and to guide further work on the framework. It has not yet been used in production, and further testing and workload evaluation are needed.
Third version in six months and still not a single number. v2 got replies from the bots only.
Without a solid use case there is no point in polishing this.
Thank you very much for your review. This is a fairly large patch series, and I have gone through several iterations because I was concerned that my approach might not align with the community's expectations. I wanted to get feedback early so that any architectural issues could be corrected promptly. I am not seeking inclusion at this stage; I posted the series for discussion. When I started developing this project, I wasn't entirely sure it would work either, so I have been writing and testing as I go, haha!
I have actually run some fio tests locally. Initially, moving the I/O scheduling policy into BPF caused a substantial performance regression. After three iterations, however, the current implementation can match the performance of native schedulers such as mq-deadline.
It also performs comparably to the none scheduler on slower SSDs, but there is still a substantial performance gap on fast NVMe devices. My analysis suggests that this is because the none scheduler can frequently bypass ordering in the ctx queues and issue requests directly to the driver (see blk_mq_try_issue_directly). I'll try to optimize it further.
I am also exploring and testing real-world use cases, which is why I developed PFQ in the third patch. Next, I plan to evaluate PFQ with foreground/background applications and with co-located containerized online services and batch workloads. I may be able to share the results in the next iteration.
Quoted 6 lines
Quoted 3 lines
In particular, I would appreciate suggestions on the boundary between the UFQ framework and BPF policies, the
struct_opsinterface, and request ownership and fallback handling.One global
ufq_opsfor all disks is not the best shape. I'd do it likebpf_qdisc.
Good suggestion. I'll give it a try. Thanks!
Quoted 9 lines
The ownership is the bigger problem.
The request sits inctx->rq_listsand in a bpf map at the same time and the kernel relies on the prog to keep the two in sync. The prog holdsrq->ref. rq holdsq_usage_counteruntil__blk_mq_free_request(). One request that the prog didn't return fromdispatch_reqor left in a map andblk_mq_freeze_queue()waits forever.sched_exthas a watchdog that kicks the bpf scheduler out. Something like that is necessary here too.
When the BPF scheduler leaks an rq reference, system I/O does indeed stall. However, because the requests are also kept in ctx->rq_lists, everything returns to normal once the BPF scheduler exits. A watchdog that kicks the BPF scheduler out is necessary, and it's also something I was planning to implement. Thank you very much!
Signature · 2 lines
Thanks Kaitao Cheng