Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1604823

Re: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t

From Daniel Borkmann <daniel@iogearbox.net>
Newsgroups linux.kernel
Subject Re: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t
Date 2017-03-20 18:20 +0100
Message-ID <tn98m-7Ut-13@gated-at.bofh.it> (permalink)
References <tn1Xb-2Jd-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 03/20/2017 10:37 AM, Elena Reshetova wrote:
[...]
> diff --git a/net/core/filter.c b/net/core/filter.c
> index ebaeaf2..389cb8d 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -928,7 +928,7 @@ static void sk_filter_release_rcu(struct rcu_head *rcu)
>    */
>   static void sk_filter_release(struct sk_filter *fp)
>   {
> -	if (atomic_dec_and_test(&fp->refcnt))
> +	if (refcount_dec_and_test(&fp->refcnt))
>   		call_rcu(&fp->rcu, sk_filter_release_rcu);
>   }
>
> @@ -943,20 +943,27 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
>   /* try to charge the socket memory if there is space available
>    * return true on success
>    */
> -bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
> +bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)

And this then becomes: static bool __sk_filter_charge(...)

>   {
>   	u32 filter_size = bpf_prog_size(fp->prog->len);
>
>   	/* same check as in sock_kmalloc() */
>   	if (filter_size <= sysctl_optmem_max &&
>   	    atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
> -		atomic_inc(&fp->refcnt);
>   		atomic_add(filter_size, &sk->sk_omem_alloc);
>   		return true;
>   	}
>   	return false;
>   }

Since here is just all in slow-path, looks fine to me if the above
is addressed as well in v3:

Acked-by: Daniel Borkmann <daniel@iogearbox.net>

Please make sure you add [PATCH net-next] in your subject in future
so that it's clear which tree this goes to.

Thanks,
Daniel

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t Elena Reshetova <elena.reshetova@intel.com> - 2017-03-20 10:40 +0100
  Re: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t Daniel Borkmann <daniel@iogearbox.net> - 2017-03-20 18:20 +0100
    RE: [PATCH] net: convert sk_filter.refcnt from atomic_t to  refcount_t "Reshetova, Elena" <elena.reshetova@intel.com> - 2017-03-21 11:50 +0100

csiph-web