Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756772AbdCUKrJ convert rfc822-to-8bit (ORCPT ); Tue, 21 Mar 2017 06:47:09 -0400 Received: from mga05.intel.com ([192.55.52.43]:42392 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755005AbdCUKrI (ORCPT ); Tue, 21 Mar 2017 06:47:08 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,198,1486454400"; d="scan'208";a="63082745" From: "Reshetova, Elena" To: Daniel Borkmann CC: "ast@fb.com" , "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "netdev@vger.kernel.org" , Hans Liljestrand , Kees Cook , David Windsor Subject: RE: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t Thread-Topic: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t Thread-Index: AQHSoV2j9AEqVJ1YWEeMvOBRgr/WO6Gd99+AgAEknjA= Date: Tue, 21 Mar 2017 10:43:12 +0000 Message-ID: <2236FBA76BA1254E88B949DDB74E612B41C5C8D1@IRSMSX102.ger.corp.intel.com> References: <1490002641-10498-1-git-send-email-elena.reshetova@intel.com> <58D00DBD.5080702@iogearbox.net> In-Reply-To: <58D00DBD.5080702@iogearbox.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1819 Lines: 58 > 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(...) Ups, I guess I am getting too tired of all these patch sendings, so more and more mistakes slide in. Will try switching to smth else to get attention back in order. > > > { > > 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 > > Please make sure you add [PATCH net-next] in your subject in future > so that it's clear which tree this goes to. Thank you very much! Will do. Best Regards, Elena. > > Thanks, > Daniel