-
Notifications
You must be signed in to change notification settings - Fork 5
libbpf: Make optimized uprobes backward compatible #6373
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libbpf: Make optimized uprobes backward compatible #6373
Conversation
|
Upstream branch: 4722981 |
86f62c3 to
c8a7e22
Compare
|
Upstream branch: 7dc211c |
5644ccd to
555c33b
Compare
c8a7e22 to
c919396
Compare
|
Upstream branch: ec12ab2 |
555c33b to
415c798
Compare
c919396 to
73c6b0b
Compare
|
Upstream branch: d6ec090 |
415c798 to
ec8f32b
Compare
73c6b0b to
0bdd2b9
Compare
|
Upstream branch: d6ec090 |
ec8f32b to
2776594
Compare
0bdd2b9 to
729c7ba
Compare
|
Upstream branch: d088da9 |
2776594 to
a7162ad
Compare
729c7ba to
623bab9
Compare
|
Upstream branch: e0940c6 |
a7162ad to
e414ab8
Compare
623bab9 to
fe03c14
Compare
|
Upstream branch: 792f258 |
e414ab8 to
c17b872
Compare
fe03c14 to
65bfb85
Compare
|
Upstream branch: 878ee3c |
c17b872 to
826c3fb
Compare
65bfb85 to
b1f8b58
Compare
|
Upstream branch: ae24fc8 |
826c3fb to
504d927
Compare
b1f8b58 to
8f7081b
Compare
|
Upstream branch: b7f7d76 |
504d927 to
12281b4
Compare
8f7081b to
c347688
Compare
|
Upstream branch: 4dd3a48 |
12281b4 to
951cc8b
Compare
c347688 to
fb42a92
Compare
|
Upstream branch: 8f7cf30 |
951cc8b to
f8d916c
Compare
fb42a92 to
3282beb
Compare
We can currently optimize uprobes on top of nop5 instructions, so application can define USDT_NOP to nop5 and use USDT macro to define optimized usdt probes. This works fine on new kernels, but could have performance penalty on older kernels, that do not have the support to optimize and to emulate nop5 instruction. execution of the usdt probe on top of nop: - nop -> trigger usdt -> emulate nop -> continue execution of the usdt probe on top of nop5: - nop5 -> trigger usdt -> single step nop5 -> continue Note the 'single step nop5' as the source of performance regression. To workaround that we change the USDT macro to emit nop,nop5 for the probe (instead of default nop) and make record of that in USDT record (more on that below). This can be detected by application (libbpf) and it can place the uprobe either on nop or nop5 based on the optimization support in the kernel. We make record of using the nop,nop5 instructions in the USDT ELF note data. Current elf note format is as follows: namesz (4B) | descsz (4B) | type (4B) | name | desc And current usdt record (with "stapsdt" name) placed in the note's desc data look like: loc_addr | 8 bytes base_addr | 8 bytes sema_addr | 8 bytes provider | zero terminated string name | zero terminated string args | zero terminated string None of the tested parsers (bpftrace-bcc, libbpf) checked that the args zero terminated byte is the actual end of the 'desc' data. As Andrii suggested we could use this and place extra zero byte right there as an indication for the parser we use the nop,nop5 instructions. It's bit tricky, but the other way would be to introduce new elf note type or note name and change all existing parsers to recognize it. With the change above the existing parsers would still recognize such usdt probes. Note we do not emit this extra byte if app defined its own nop through USDT_NOP macro. Suggested-by: Andrii Nakryiko <[email protected]> Signed-off-by: Jiri Olsa <[email protected]>
Adding uprobe syscall feature detection that will be used in following changes. Signed-off-by: Jiri Olsa <[email protected]>
|
Upstream branch: c427320 |
Adding support to parse extra info in usdt note record that indicates there's nop,nop5 emitted for probe. We detect this by checking extra zero byte placed in between args zero termination byte and desc data end. Please see [1] for more details. Together with uprobe syscall feature detection we can decide if we want to place the probe on top of nop or nop5. [1] https://github.com/libbpf/usdt Signed-off-by: Jiri Olsa <[email protected]>
Adding test that attaches bpf program on usdt probe in 2 scenarios; - attach program on top of usdt_1 which is standard nop probe incidentally followed by nop5. The usdt probe does not have extra data in elf note record, so we expect the probe to land on the first nop without being optimized. - attach program on top of usdt_2 which is probe defined on top of nop,nop5 combo. The extra data in the elf note record and presence of upeobe syscall ensures that the probe is placed on top of nop5 and optimized. Signed-off-by: Jiri Olsa <[email protected]>
f8d916c to
0a64ca4
Compare
|
At least one diff in series https://patchwork.kernel.org/project/netdevbpf/list/?series=1024135 expired. Closing PR. |
Pull request for series with
subject: libbpf: Make optimized uprobes backward compatible
version: 1
url: https://patchwork.kernel.org/project/netdevbpf/list/?series=1024135