lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4A2F6F39.8060107@gmail.com>
Date:	Wed, 10 Jun 2009 10:30:49 +0200
From:	Eric Dumazet <eric.dumazet@...il.com>
To:	David Miller <davem@...emloft.net>
CC:	rusty@...tcorp.com.au, netdev@...r.kernel.org
Subject: Re: [PATCH] net: No more expensive sock_hold()/sock_put() on each
 tx

David Miller a écrit :
> From: Eric Dumazet <eric.dumazet@...il.com>
> Date: Thu, 04 Jun 2009 11:18:35 +0200
> 
>> @@ -1172,12 +1186,18 @@ void __init sk_init(void)
>>  void sock_wfree(struct sk_buff *skb)
>>  {
>>  	struct sock *sk = skb->sk;
>> +	int res;
>>  
>>  	/* In case it might be waiting for more memory. */
>> -	atomic_sub(skb->truesize, &sk->sk_wmem_alloc);
>> +	res = atomic_sub_return(skb->truesize, &sk->sk_wmem_alloc);
>>  	if (!sock_flag(sk, SOCK_USE_WRITE_QUEUE))
>>  		sk->sk_write_space(sk);
>> -	sock_put(sk);
>> +	/*
>> +	 * if sk_wmem_alloc reached 0, we are last user and should
>> +	 * free this sock, as sk_free() call could not do it.
>> +	 */
>> +	if (res == 0)
>> +		__sk_free(sk);
>>  }
>>  EXPORT_SYMBOL(sock_wfree);
>>  
> 
> Eric, I don't understand this part, please enlighten me :-)
> 
> Just because we've liberated all of the write buffer space, that does
> not mean that it's time to kill off the socket completely.
> 
> Right?

Remember we initialize this field to one.

If we freed all write buffer space, final value is one, not zero.

res == 0 only if we both freed all write buffer space, *and* socket was
also refcounted to 0 (sk_free() then realized it could not yet call __sk_free())

So we cheat a litle bit, because of this offset of one, we might block a sender a litle bit earlier :)

Thank you
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ