History

bpf: notify offload JITs about optimizations

Let offload JITs know when instructions are replaced and optimized out, so they can update their state appropriately. The optimizations are best effort, if JIT returns an error from any callback verifier will stop notifying it as state may now be out of sync, but the verifier continues making progress.

Jakub Kicinski committed 7 years ago

Commit 08ca90a1 parent 9e4c24e4 files · +53 −0Browse files

Showing the changes to include/linux (2 of 4 files). Show all

Unified · Split

2 files
  1. include/linux/bpf.h +7 −0
  2. include/linux/bpf_verifier.h +5 −0
include/linux/bpf.h+7−0
@@ -268,9 +268,15 @@ struct bpf_verifier_ops { · 267 unmodified lines
268268 };
269269
270270 struct bpf_prog_offload_ops {
271+ /* verifier basic callbacks */
271272 int (*insn_hook)(struct bpf_verifier_env *env,
272273 int insn_idx, int prev_insn_idx);
273274 int (*finalize)(struct bpf_verifier_env *env);
275+ /* verifier optimization callbacks (called after .finalize) */
276+ int (*replace_insn)(struct bpf_verifier_env *env, u32 off,
277+ struct bpf_insn *insn);
278+ int (*remove_insns)(struct bpf_verifier_env *env, u32 off, u32 cnt);
279+ /* program management callbacks */
274280 int (*prepare)(struct bpf_prog *prog);
275281 int (*translate)(struct bpf_prog *prog);
276282 void (*destroy)(struct bpf_prog *prog);
@@ -283,6 +289,7 @@ struct bpf_prog_offload { · 6 unmodified lines
283289 void *dev_priv;
284290 struct list_head offloads;
285291 bool dev_state;
292+ bool opt_failed;
286293 void *jited_image;
287294 u32 jited_len;
288295 };
include/linux/bpf_verifier.h+5−0
@@ -266,5 +266,10 @@ int bpf_prog_offload_verifier_prep(struct bpf_prog *prog); · 265 unmodified lines
266266 int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
267267 int insn_idx, int prev_insn_idx);
268268 int bpf_prog_offload_finalize(struct bpf_verifier_env *env);
269+void
270+bpf_prog_offload_replace_insn(struct bpf_verifier_env *env, u32 off,
271+ struct bpf_insn *insn);
272+void
273+bpf_prog_offload_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt);
269274
270275 #endif /* _LINUX_BPF_VERIFIER_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t