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
268};268};
269 269
270struct bpf_prog_offload_ops {270struct bpf_prog_offload_ops {
271 /* verifier basic callbacks */
271 int (*insn_hook)(struct bpf_verifier_env *env,272 int (*insn_hook)(struct bpf_verifier_env *env,
272 int insn_idx, int prev_insn_idx);273 int insn_idx, int prev_insn_idx);
273 int (*finalize)(struct bpf_verifier_env *env);274 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 */
274 int (*prepare)(struct bpf_prog *prog);280 int (*prepare)(struct bpf_prog *prog);
275 int (*translate)(struct bpf_prog *prog);281 int (*translate)(struct bpf_prog *prog);
276 void (*destroy)(struct bpf_prog *prog);282 void (*destroy)(struct bpf_prog *prog);
@@ -283,6 +289,7 @@ struct bpf_prog_offload { · 6 unmodified lines
283 void *dev_priv;289 void *dev_priv;
284 struct list_head offloads;290 struct list_head offloads;
285 bool dev_state;291 bool dev_state;
292 bool opt_failed;
286 void *jited_image;293 void *jited_image;
287 u32 jited_len;294 u32 jited_len;
288};295};
include/linux/bpf_verifier.h+5−0
@@ -266,5 +266,10 @@ int bpf_prog_offload_verifier_prep(struct bpf_prog *prog); · 265 unmodified lines
266int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,266int bpf_prog_offload_verify_insn(struct bpf_verifier_env *env,
267 int insn_idx, int prev_insn_idx);267 int insn_idx, int prev_insn_idx);
268int bpf_prog_offload_finalize(struct bpf_verifier_env *env);268int bpf_prog_offload_finalize(struct bpf_verifier_env *env);
269void
270bpf_prog_offload_replace_insn(struct bpf_verifier_env *env, u32 off,
271 struct bpf_insn *insn);
272void
273bpf_prog_offload_remove_insns(struct bpf_verifier_env *env, u32 off, u32 cnt);
269 274
270#endif /* _LINUX_BPF_VERIFIER_H */275#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