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.
Showing the changes to include/linux (1 of 11 files). Show all
Unified · Split
| @@ -485,7 +485,7 @@ struct bpf_func_info_aux { · 484 unmodified lines | |||
| 485 | }; | 485 | }; |
| 486 | 486 | ||
| 487 | struct bpf_prog_aux { | 487 | struct 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 | |||
| 770 | struct bpf_prog *bpf_prog_get(u32 ufd); | 770 | struct bpf_prog *bpf_prog_get(u32 ufd); |
| 771 | struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type, | 771 | struct bpf_prog *bpf_prog_get_type_dev(u32 ufd, enum bpf_prog_type type, |
| 772 | bool attach_drv); | 772 | 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); |
| 774 | void bpf_prog_sub(struct bpf_prog *prog, int i); | 774 | 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); |
| 776 | struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog); | 776 | struct bpf_prog * __must_check bpf_prog_inc_not_zero(struct bpf_prog *prog); |
| 777 | void bpf_prog_put(struct bpf_prog *prog); | 777 | void bpf_prog_put(struct bpf_prog *prog); |
| 778 | int __bpf_prog_charge(struct user_struct *user, u32 pages); | 778 | 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 | |||
| 912 | return ERR_PTR(-EOPNOTSUPP); | 912 | return ERR_PTR(-EOPNOTSUPP); |
| 913 | } | 913 | } |
| 914 | 914 | ||
| 915 | static inline struct bpf_prog * __must_check bpf_prog_add(struct bpf_prog *prog, | 915 | static 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 | ||
| 921 | static inline void bpf_prog_sub(struct bpf_prog *prog, int i) | 919 | 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 | |||
| 926 | { | 924 | { |
| 927 | } | 925 | } |
| 928 | 926 | ||
| 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) |
| 930 | { | 928 | { |
| 931 | return ERR_PTR(-EOPNOTSUPP); | ||
| 932 | } | 929 | } |
| 933 | 930 | ||
| 934 | static inline struct bpf_prog *__must_check | 931 | static inline struct bpf_prog *__must_check |