From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: Regression, bisected: reference leak with IPSec since ~2.6.31 Date: Tue, 21 Sep 2010 12:07:37 +0200 Message-ID: <1285063657.2617.226.camel@edumazet-laptop> References: <20100921091248.GA8424@ff.dom.local> <1285060860.2617.158.camel@edumazet-laptop> <20100921093853.GA8664@ff.dom.local> <1285062948.2617.204.camel@edumazet-laptop> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Nick Bowler , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" To: Jarek Poplawski Return-path: In-Reply-To: <1285062948.2617.204.camel@edumazet-laptop> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Le mardi 21 septembre 2010 =C3=A0 11:55 +0200, Eric Dumazet a =C3=A9cri= t : > Le mardi 21 septembre 2010 =C3=A0 09:38 +0000, Jarek Poplawski a =C3=A9= crit : > > On Tue, Sep 21, 2010 at 11:21:00AM +0200, Eric Dumazet wrote: >=20 > > I hope you're right with this. > >=20 > > >=20 > > > I liked the : > > >=20 > > > > > > if something wrong > > > goto slow_path > > > else > > > > > >=20 > >=20 > > But it's an optimization of the "unlikely" case btw. ;-) > >=20 >=20 > This is a bug fix, in a complex function. >=20 > in -next branch, we can try to be smart, adding more code in slow_pat= h > to revert what was done in the hope fast path would be taken. > And pray we dont add another bug :) >=20 My initial patch was somehing like : compute truesizes =3D sum (frag->truesize) not modifying frag->sk/frag->destructor if problem -> goto slow_path else { skb->truesize -=3D truesizes; send(skb) for each frag set frag->sk =3D original_sk set frag->destructor =3D sock_wfree send(frag) Problem was if we got an error while sending skb or one frag : It was leaking some truesize accounting. (an extra loop was needed to set frag->sk/frag->destructor for remainin= g frags before freeing them) So I added the extra loop to : for each frag { set frag->sk =3D skb->sk set frag->destructor =3D sock_wfree skb->truesize -=3D frag->truesize } It removed the need to compute sum(frag->truesize) in a temp variable (truesizes)