Skip to content

get rid of GCC __attribute__((optimize)) for BPF

Ard Biesheuvel bpf linux-toolchains lkml netdev 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 13 repliesIn review
  2. v11 patch 11 repliesSuperseded

Changes in v2 from the cover letter

- only use -fno-gcse when CONFIG_BPF_JIT_ALWAYS_ON=y and CONFIG_CC_IS_GCC=y (but ignore CONFIG_RETPOLINE since we want to avoid GCSE in all cases)
- to avoid potential impact of disabling GCSE on other code, put the interpreter in a separate file (patch #2)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: don't rely on GCC __attribute__((optimize)) to disable GCSEinclude/linux/compiler-gcc.h include/linux/compiler_types.h kernel/bpf/Makefile +1 more+6 -813 replies
2/2bpf: move interpreter into separate source fileinclude/linux/filter.h kernel/bpf/Makefile kernel/bpf/core.c +1 more+605 -5710 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by.

PatchGeert UytterhoevenNick Desaulniers
1/2T-b R-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] get rid of GCC __attribute__((optimize)) for BPF

This is a followup to [0]:
[PATCH] bpf: don't rely on GCC __attribute__((optimize)) to disable GCSE[0]

Changes since v1:
- only use -fno-gcse when CONFIG_BPF_JIT_ALWAYS_ON=y and CONFIG_CC_IS_GCC=y (but ignore CONFIG_RETPOLINE since we want to avoid GCSE in all cases)
- to avoid potential impact of disabling GCSE on other code, put the interpreter in a separate file (patch #2)

Note that patch #1 is intended for backporting, as function scope GCC optimization attributes are really quite broken.

I don't have a strong opinion on whether the interpreter code should be split off or not, but it looks like it can be done fairly painlessly, so it is probably a good idea to do it anyway.

[0] https://lore.kernel.org/bpf/[email protected]/

Cc Nick Desaulniers <[email protected]>
Cc Arvind Sankar <[email protected]>
Cc Randy Dunlap <[email protected]>
Cc Josh Poimboeuf <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Alexei Starovoitov <[email protected]>
Cc Daniel Borkmann <[email protected]>
Cc Peter Zijlstra (Intel) <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Kees Cook <[email protected]>

Ard Biesheuvel (2):
bpf: don't rely on GCC __attribute__((optimize)) to disable GCSE
bpf: move interpreter into separate source file

 include/linux/compiler-gcc.h   |   2 -
 include/linux/compiler_types.h |   4 -
 include/linux/filter.h         |   1 +
 kernel/bpf/Makefile            |   7 +-
 kernel/bpf/core.c              | 567 ------------------
 kernel/bpf/interp.c            | 601 ++++++++++++++++++++
 6 files changed, 607 insertions(+), 575 deletions(-)
 create mode 100644 kernel/bpf/interp.c
Signature · 1 line
2.17.1