Commit 15a3b79
Alexei Starovoitov
Merge branch 'bpf-use-vrealloc-in-bpf_patch_insn_data'
Eduard Zingerman says:
====================
bpf: use vrealloc() in bpf_patch_insn_data()
Function bpf_patch_insn_data() uses vzalloc/vfree pair to allocate
memory for updated insn_aux_data. These operations are expensive for
big programs where a lot of rewrites happen, e.g. for pyperf180 test
case. The pair can be replaced with a call to vrealloc in order to
reduce the number of actual memory allocations.
Perf stat w/o this patch:
$ perf stat -B --all-kernel -r10 -- ./veristat -q pyperf180.bpf.o
...
2201.25 msec task-clock # 0.973 CPUs utilized ( +- 2.20% )
188 context-switches # 85.406 /sec ( +- 9.29% )
15 cpu-migrations # 6.814 /sec ( +- 5.64% )
5 page-faults # 2.271 /sec ( +- 3.27% )
4315057974 instructions # 1.28 insn per cycle
# 0.33 stalled cycles per insn ( +- 0.03% )
3366141387 cycles # 1.529 GHz ( +- 0.21% )
1420810964 stalled-cycles-frontend # 42.21% frontend cycles idle ( +- 0.23% )
1049956791 branches # 476.981 M/sec ( +- 0.03% )
60591781 branch-misses # 5.77% of all branches ( +- 0.07% )
2.2632 +- 0.0527 seconds time elapsed ( +- 2.33% )
Perf stat with this patch:
1227.15 msec task-clock # 0.963 CPUs utilized ( +- 2.27% )
170 context-switches # 138.532 /sec ( +- 5.62% )
2 cpu-migrations # 1.630 /sec ( +- 33.37% )
5 page-faults # 4.074 /sec ( +- 4.47% )
3312254304 instructions # 2.17 insn per cycle
# 0.15 stalled cycles per insn ( +- 0.03% )
1528944717 cycles # 1.246 GHz ( +- 0.31% )
501475146 stalled-cycles-frontend # 32.80% frontend cycles idle ( +- 0.50% )
730426891 branches # 595.222 M/sec ( +- 0.03% )
17372363 branch-misses # 2.38% of all branches ( +- 0.16% )
1.2744 +- 0.0301 seconds time elapsed ( +- 2.36% )
Changelog:
v1: https://lore.kernel.org/bpf/[email protected]/T/#t
v1 -> v2:
- added missing memset(0) in adjust_insn_aux_data(),
this fixes CI failure reported in [1].
[1] https://github.com/kernel-patches/bpf/actions/runs/16787563163/job/47542309875
====================
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Alexei Starovoitov <[email protected]>1 file changed
+20
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3663 | 3663 | | |
3664 | 3664 | | |
3665 | 3665 | | |
3666 | | - | |
| 3666 | + | |
3667 | 3667 | | |
3668 | 3668 | | |
3669 | 3669 | | |
| |||
3774 | 3774 | | |
3775 | 3775 | | |
3776 | 3776 | | |
3777 | | - | |
| 3777 | + | |
3778 | 3778 | | |
3779 | 3779 | | |
3780 | 3780 | | |
3781 | 3781 | | |
3782 | 3782 | | |
3783 | 3783 | | |
3784 | | - | |
| 3784 | + | |
3785 | 3785 | | |
3786 | 3786 | | |
3787 | 3787 | | |
| |||
3812 | 3812 | | |
3813 | 3813 | | |
3814 | 3814 | | |
3815 | | - | |
| 3815 | + | |
3816 | 3816 | | |
3817 | 3817 | | |
3818 | 3818 | | |
| |||
20699 | 20699 | | |
20700 | 20700 | | |
20701 | 20701 | | |
20702 | | - | |
20703 | 20702 | | |
20704 | 20703 | | |
20705 | | - | |
| 20704 | + | |
20706 | 20705 | | |
20707 | | - | |
| 20706 | + | |
20708 | 20707 | | |
20709 | 20708 | | |
20710 | 20709 | | |
20711 | 20710 | | |
20712 | 20711 | | |
20713 | 20712 | | |
20714 | 20713 | | |
20715 | | - | |
| 20714 | + | |
20716 | 20715 | | |
20717 | 20716 | | |
20718 | 20717 | | |
20719 | 20718 | | |
20720 | 20719 | | |
20721 | | - | |
20722 | | - | |
20723 | | - | |
| 20720 | + | |
| 20721 | + | |
| 20722 | + | |
20724 | 20723 | | |
20725 | 20724 | | |
20726 | | - | |
20727 | | - | |
| 20725 | + | |
| 20726 | + | |
20728 | 20727 | | |
20729 | | - | |
20730 | | - | |
20731 | 20728 | | |
20732 | 20729 | | |
20733 | 20730 | | |
| |||
20765 | 20762 | | |
20766 | 20763 | | |
20767 | 20764 | | |
20768 | | - | |
20769 | | - | |
| 20765 | + | |
| 20766 | + | |
| 20767 | + | |
| 20768 | + | |
20770 | 20769 | | |
20771 | 20770 | | |
| 20771 | + | |
| 20772 | + | |
20772 | 20773 | | |
20773 | 20774 | | |
20774 | 20775 | | |
| |||
20780 | 20781 | | |
20781 | 20782 | | |
20782 | 20783 | | |
20783 | | - | |
| 20784 | + | |
20784 | 20785 | | |
20785 | 20786 | | |
20786 | 20787 | | |
| |||
21131 | 21132 | | |
21132 | 21133 | | |
21133 | 21134 | | |
21134 | | - | |
| 21135 | + | |
21135 | 21136 | | |
21136 | 21137 | | |
21137 | 21138 | | |
| |||
0 commit comments