Message ID | 20201106220757.3950302-1-kafai@fb.com |
---|---|
State | Not Applicable |
Delegated to: | BPF Maintainers |
Headers | show |
Series | bpf: Enable bpf_sk_storage for FENTRY/FEXIT/RAW_TP | expand |
Context | Check | Description |
---|---|---|
jkicinski/cover_letter | success | Link |
jkicinski/fixes_present | success | Link |
jkicinski/patch_count | success | Link |
jkicinski/tree_selection | success | Clearly marked for bpf-next |
jkicinski/subject_prefix | success | Link |
jkicinski/source_inline | success | Was 0 now: 0 |
jkicinski/verify_signedoff | success | Link |
jkicinski/module_param | success | Was 0 now: 0 |
jkicinski/build_32bit | fail | Errors and warnings before: 8 this patch: 8 |
jkicinski/kdoc | success | Errors and warnings before: 0 this patch: 0 |
jkicinski/verify_fixes | success | Link |
jkicinski/checkpatch | fail | Link |
jkicinski/build_allmodconfig_warn | success | Errors and warnings before: 4 this patch: 4 |
jkicinski/header_inline | success | Link |
jkicinski/stable | success | Stable not CCed |
> On Nov 6, 2020, at 2:07 PM, Martin KaFai Lau <kafai@fb.com> wrote: > > sk_storage_charge() is the only user of omem_charge(). > This patch simplifies it by folding omem_charge() into > sk_storage_charge(). > > Signed-off-by: Martin KaFai Lau <kafai@fb.com> Acked-by: Song Liu <songliubraving@fb.com> > --- > net/core/bpf_sk_storage.c | 23 ++++++++++------------- > 1 file changed, 10 insertions(+), 13 deletions(-) > > diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c > index c907f0dc7f87..001eac65e40f 100644 > --- a/net/core/bpf_sk_storage.c > +++ b/net/core/bpf_sk_storage.c > @@ -15,18 +15,6 @@ > > DEFINE_BPF_STORAGE_CACHE(sk_cache); > > -static int omem_charge(struct sock *sk, unsigned int size) > -{ > - /* same check as in sock_kmalloc() */ > - if (size <= sysctl_optmem_max && > - atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { > - atomic_add(size, &sk->sk_omem_alloc); > - return 0; > - } > - > - return -ENOMEM; > -} > - > static struct bpf_local_storage_data * > sk_storage_lookup(struct sock *sk, struct bpf_map *map, bool cacheit_lockit) > { > @@ -316,7 +304,16 @@ BPF_CALL_2(bpf_sk_storage_delete, struct bpf_map *, map, struct sock *, sk) > static int sk_storage_charge(struct bpf_local_storage_map *smap, > void *owner, u32 size) > { > - return omem_charge(owner, size); > + struct sock *sk = (struct sock *)owner; > + > + /* same check as in sock_kmalloc() */ > + if (size <= sysctl_optmem_max && > + atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { > + atomic_add(size, &sk->sk_omem_alloc); > + return 0; > + } > + > + return -ENOMEM; > } > > static void sk_storage_uncharge(struct bpf_local_storage_map *smap, > -- > 2.24.1 >
diff --git a/net/core/bpf_sk_storage.c b/net/core/bpf_sk_storage.c index c907f0dc7f87..001eac65e40f 100644 --- a/net/core/bpf_sk_storage.c +++ b/net/core/bpf_sk_storage.c @@ -15,18 +15,6 @@ DEFINE_BPF_STORAGE_CACHE(sk_cache); -static int omem_charge(struct sock *sk, unsigned int size) -{ - /* same check as in sock_kmalloc() */ - if (size <= sysctl_optmem_max && - atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { - atomic_add(size, &sk->sk_omem_alloc); - return 0; - } - - return -ENOMEM; -} - static struct bpf_local_storage_data * sk_storage_lookup(struct sock *sk, struct bpf_map *map, bool cacheit_lockit) { @@ -316,7 +304,16 @@ BPF_CALL_2(bpf_sk_storage_delete, struct bpf_map *, map, struct sock *, sk) static int sk_storage_charge(struct bpf_local_storage_map *smap, void *owner, u32 size) { - return omem_charge(owner, size); + struct sock *sk = (struct sock *)owner; + + /* same check as in sock_kmalloc() */ + if (size <= sysctl_optmem_max && + atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { + atomic_add(size, &sk->sk_omem_alloc); + return 0; + } + + return -ENOMEM; } static void sk_storage_uncharge(struct bpf_local_storage_map *smap,
sk_storage_charge() is the only user of omem_charge(). This patch simplifies it by folding omem_charge() into sk_storage_charge(). Signed-off-by: Martin KaFai Lau <kafai@fb.com> --- net/core/bpf_sk_storage.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-)