Commit b07df4d
bpf,x86: do RSB balance for trampoline
In origin call case, we skip the "rip" directly before we return, which
break the RSB, as we have twice "call", but only once "ret".
Do the RSB balance by pseudo a "ret". Instead of skipping the "rip", we
modify it to the address of a "ret" insn that we generate.
The performance of "fexit" increases from 76M/s to 84M/s. Before this
optimize, the bench resulting of fexit is:
fexit : 76.494 ± 0.216M/s
fexit : 76.319 ± 0.097M/s
fexit : 70.680 ± 0.060M/s
fexit : 75.509 ± 0.039M/s
fexit : 76.392 ± 0.049M/s
After this optimize:
fexit : 86.023 ± 0.518M/s
fexit : 83.388 ± 0.021M/s
fexit : 85.146 ± 0.058M/s
fexit : 85.646 ± 0.136M/s
fexit : 84.040 ± 0.045M/s
Things become a little more complex, not sure if the benefits worth it :/
Signed-off-by: Menglong Dong <[email protected]>1 parent fe98223 commit b07df4d
1 file changed
+29
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3185 | 3185 | | |
3186 | 3186 | | |
3187 | 3187 | | |
| 3188 | + | |
3188 | 3189 | | |
3189 | 3190 | | |
3190 | 3191 | | |
| |||
3431 | 3432 | | |
3432 | 3433 | | |
3433 | 3434 | | |
| 3435 | + | |
| 3436 | + | |
| 3437 | + | |
| 3438 | + | |
| 3439 | + | |
| 3440 | + | |
| 3441 | + | |
| 3442 | + | |
| 3443 | + | |
| 3444 | + | |
| 3445 | + | |
| 3446 | + | |
| 3447 | + | |
| 3448 | + | |
| 3449 | + | |
| 3450 | + | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
3434 | 3456 | | |
3435 | 3457 | | |
3436 | 3458 | | |
3437 | 3459 | | |
3438 | 3460 | | |
3439 | 3461 | | |
| 3462 | + | |
3440 | 3463 | | |
3441 | | - | |
3442 | | - | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
3443 | 3470 | | |
3444 | | - | |
3445 | 3471 | | |
3446 | 3472 | | |
3447 | 3473 | | |
| |||
0 commit comments