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
485};485};
486 486
487struct bpf_prog_aux {487struct bpf_prog_aux {
488 atomic_t refcnt;488 atomic64_t refcnt;
489 u32 used_map_cnt;489 u32 used_map_cnt;
490 u32 max_ctx_offset;490 u32 max_ctx_offset;
491 u32 max_pkt_offset;491 u32 max_pkt_offset;
@@ -770,9 +770,9 @@ extern const struct bpf_verifier_ops xdp_analyzer_ops; · 278 unmodified lines
770struct bpf_prog *bpf_prog_get(u32 ufd);770struct bpf_prog *bpf_prog_get(u32 ufd);
771struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type,771struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type,
772 bool attach_drv);772 bool attach_drv);
773struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog, int i);773void bpf_prog_add(struct bpf_prog *prog, int i);
774void bpf_prog_sub(struct bpf_prog *prog, int i);774void bpf_prog_sub(struct bpf_prog *prog, int i);
775struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog);775void bpf_prog_inc(struct bpf_prog *prog);
776struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog);776struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog);
777void bpf_prog_put(struct bpf_prog *prog);777void bpf_prog_put(struct bpf_prog *prog);
778int __bpf_prog_charge(struct user_struct *user, u32 pages);778int __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
912 return ERR_PTR(-EOPNOTSUPP);912 return ERR_PTR(-EOPNOTSUPP);
913}913}
914 914
915static inline struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog,915static inline void bpf_prog_add(struct bpf_prog *prog, int i)
916 int i)
917{916{
918 return ERR_PTR(-EOPNOTSUPP);
919}917}
920 918
921static inline void bpf_prog_sub(struct bpf_prog *prog, int i)919static 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
926{924{
927}925}
928 926
929static inline struct bpf_prog * __must_check bpf_prog_inc(struct bpf_prog *prog)927static inline void bpf_prog_inc(struct bpf_prog *prog)
930{928{
931 return ERR_PTR(-EOPNOTSUPP);
932}929}
933 930
934static inline struct bpf_prog *__must_check931static 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