英文:
Do freplaced programs in XDP Dispatcher share the same instruction limit?
问题
我目前正在使用libxdp来多路复用执行XDP的BPF程序。
根据我的理解,libxdp会加载一个dispatcher程序,并使用freplace来更改与虚拟函数相关联的字节码。
在freplace完成后,替换的程序是否计入dispatcher程序的指令限制?
例如,假设dispatcher有500条指令,我有4个程序,每个程序包含300,000条指令。那么,我是否能够在dispatcher上用freplace替换所有4个程序,考虑到它们的总指令数为1,200,500条指令(4 * 300,000 + 500),而BPF程序的指令限制为1,000,000条指令?
英文:
I am currently working with libxdp to multiplex execution of BPF programs for XDP.
From my understanding libxdp will load a dispatcher program and use freplace to change the bytecode associated with dummy functions.
After freplace is done, does the replacing program count towards the instruction limit of the dispatcher program?
Example, say the dispatcher is 500 instructions, and I have 4 programs consisting of 300 000 instructions each. Will I be able to freplace all 4 programs on the dispatcher considering their combined instruction count is 1 200 500 instructions (4 * 300 000 + 500) whereas the instruction limit of a BPF programs is 1 000 000 instructions?
答案1
得分: 1
不,调度程序和被调用的程序是独立加载的。指令/复杂性限制在加载时对每个程序进行强制执行,不是动态计算的内容。
此外,对于freplace进行了小的修正。它被称为f-replace,因为它替换了一个全局函数。由于任何eBPF程序本质上都是一个函数,接受一个上下文并返回一个返回值,我们也可以将其他程序用作这样的函数。请不要与BPF到BPF函数调用混淆,这是一种略有不同的机制。因此,这两个程序都是单独加载的,然后我们将调度程序中的函数指针替换为JIT编译的子程序的内存地址。因此,只有指针值会被修补。
英文:
No, the dispatcher and the called program are loaded independently. The instruction/complexity limit is enforced per program at load time and is not something that is dynamically accounted for.
Also small correction on freplace. Its call this f-replace since it replaces a global function. Since any eBPF program is essentially a function, taking a context and returning a return value, we can also use other programs as such. Not to be confused with BPF-to-BPF function calls which is a slightly different mechanism. So both programs are loaded separately, then we replace the function pointer in the dispatcher with the memory address of the JIT-ed sub program. So its only a pointer value that gets patched.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论