On 11/13/24 08:21, Ming Lei wrote:
On Mon, Nov 11, 2024 at 01:50:45AM +0000, Pavel Begunkov wrote:
Let the user to register a BPF_PROG_TYPE_IOURING BPF program to a ring.
The progrma will be run in the waiting loop every time something
happens, i.e. the task was woken up by a task_work / signal / etc.
Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx>
---
...
do {
unsigned long check_cq;
@@ -2879,6 +2886,13 @@ static int io_cqring_wait(struct io_ring_ctx *ctx, int min_events, u32 flags,
if (ret < 0)
break;
+ if (io_bpf_enabled(ctx)) {
+ ret = io_run_bpf(ctx);
+ if (ret == IOU_BPF_RET_STOP)
+ break;
+ continue;
+ }
I believe 'struct_ops' is much simpler to run the prog and return the result.
Then you needn't any bpf core change and the bpf register code.
Right, that's one of the things I need to look into, I have it in my
todo list, but I'm not sure at all I'd want to get rid of the register
opcode. It's a good idea to have stronger registration locking, i.e.
under ->ring_lock, but again I need to check it out.
--
Pavel Begunkov