History

bpf: Convert bpf_prog refcnt to atomic64_t

Similarly to bpf_map's refcnt/usercnt, convert bpf_prog's refcnt to atomic64 and remove artificial 32k limit. This allows to make bpf_prog's refcounting non-failing, simplifying logic of users of bpf_prog_add/bpf_prog_inc. Validated compilation by running allyesconfig kernel build.

Andrii Nakryiko committed 6 years ago

Commit 85192db1 parent 1e0bd5a11 files · +40 −97Browse files

Showing the changes to include/linux (1 of 11 files). Show all

Unified · Split

include/linux/bpf.h+5−8
@@ -485,7 +485,7 @@ struct bpf_func_info_aux { · 484 unmodified lines
485485 };
486486
487487 struct bpf_prog_aux {
488− atomic_t refcnt;
488+ atomic64_t refcnt;
489489 u32 used_map_cnt;
490490 u32 max_ctx_offset;
491491 u32 max_pkt_offset;
@@ -770,9 +770,9 @@ extern const struct bpf_verifier_ops xdp_analyzer_ops; · 278 unmodified lines
770770 struct bpf_prog *bpf_prog_get(u32 ufd);
771771 struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type,
772772 bool attach_drv);
773−struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog, int i);
773+void bpf_prog_add(struct bpf_prog *prog, int i);
774774 void bpf_prog_sub(struct bpf_prog *prog, int i);
775−struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog);
775+void bpf_prog_inc(struct bpf_prog *prog);
776776 struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog);
777777 void bpf_prog_put(struct bpf_prog *prog);
778778 int __bpf_prog_charge(struct user_struct *user, u32 pages);
@@ -912,10 +912,8 @@ static inline struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, · 133 unmodified lines
912912 return ERR_PTR(-EOPNOTSUPP);
913913 }
914914
915−static inline struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog,
916− int i)
915+static inline void bpf_prog_add(struct bpf_prog *prog, int i)
917916 {
918− return ERR_PTR(-EOPNOTSUPP);
919917 }
920918
921919 static inline void bpf_prog_sub(struct bpf_prog *prog, int i)
@@ -926,9 +924,8 @@ static inline void bpf_prog_put(struct bpf_prog *prog) · 4 unmodified lines
926924 {
927925 }
928926
929−static inline struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog)
927+static inline void bpf_prog_inc(struct bpf_prog *prog)
930928 {
931− return ERR_PTR(-EOPNOTSUPP);
932929 }
933930
934931 static inline struct bpf_prog *__must_check

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