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: <550B44A9.5020402@cumulusnetworks.com>
Date:	Thu, 19 Mar 2015 17:50:33 -0400
From:	Jonathan Toppins <jtoppins@...ulusnetworks.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
CC:	"David S. Miller" <davem@...emloft.net>, netdev@...r.kernel.org,
	Curt Brune <curt@...ulusnetworks.com>
Subject: Re: [PATCH v1 net-next] tuntap: convert to 64-bit interface statistics

On 3/19/15 5:38 PM, Eric Dumazet wrote:
> On Thu, 2015-03-19 at 12:51 -0700, Jonathan Toppins wrote:
>> Signed-off-by: Curt Brune <curt@...ulusnetworks.com>
>> Signed-off-by: Jonathan Toppins <jtoppins@...ulusnetworks.com>
>> ---
>>   drivers/net/tun.c |   54 ++++++++++++++++++++++++++++++++++++++++++-----------
>>   1 file changed, 43 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
>> index b96b94c..be8941a 100644
>> --- a/drivers/net/tun.c
>> +++ b/drivers/net/tun.c
>> @@ -65,6 +65,7 @@
>>   #include <linux/nsproxy.h>
>>   #include <linux/virtio_net.h>
>>   #include <linux/rcupdate.h>
>> +#include <linux/u64_stats_sync.h>
>>   #include <net/net_namespace.h>
>>   #include <net/netns/generic.h>
>>   #include <net/rtnetlink.h>
>> @@ -204,6 +205,9 @@ struct tun_struct {
>>   	struct list_head disabled;
>>   	void *security;
>>   	u32 flow_count;
>> +	spinlock_t			stat_lock;
>> +	struct u64_stats_sync		stat_sync;
>> +	struct rtnl_link_stats64	stats64;
>>   };
>>
>>   static inline u16 tun16_to_cpu(struct tun_struct *tun, __virtio16 val)
>> @@ -751,6 +755,16 @@ static int tun_net_close(struct net_device *dev)
>>   	return 0;
>>   }
>>
>> +static __always_inline void tun_stat64_inc(struct tun_struct *tun, u64 *stat,
>> +					   size_t val)
>> +{
>> +	spin_lock_bh(&tun->stat_lock);
>> +	u64_stats_update_begin(&tun->stat_sync);
>> +	(*stat) += val;
>> +	u64_stats_update_end(&tun->stat_sync);
>> +	spin_unlock_bh(&tun->stat_lock);
>> +}
>
> Ouch, one spin_lock_bh() ? Really ?
>
>> -	tun->dev->stats.tx_packets++;
>> -	tun->dev->stats.tx_bytes += skb->len + vlan_hlen;
>> +	tun_stat64_inc(tun, &tun->stats64.tx_packets, 1);
>> +	tun_stat64_inc(tun, &tun->stats64.tx_bytes, skb->len + vlan_hlen);
>
>
> So you take this spinlock twice ?
>
> Sorry, this is not good.
>
Hi Eric, thanks for the review.
Would something like the following be preferable?

	spin_lock_bh(&tun->stat_lock);
	u64_stats_update_begin(&tun->stat_sync);
	&tun->stats64.tx_packets++;
	&tun->stats64.tx_bytes += skb->len + vlan_hlen;
	u64_stats_update_end(&tun->stat_sync);
	spin_unlock_bh(&tun->stat_lock);

-Jon
--
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