From: Jonathan Toppins <jtoppins@cumulusnetworks.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
netdev@vger.kernel.org, Curt Brune <curt@cumulusnetworks.com>
Subject: Re: [PATCH v1 net-next] tuntap: convert to 64-bit interface statistics
Date: Thu, 19 Mar 2015 17:56:41 -0400 [thread overview]
Message-ID: <550B4619.6020203@cumulusnetworks.com> (raw)
In-Reply-To: <1426801109.25985.8.camel@edumazet-glaptop2.roam.corp.google.com>
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@cumulusnetworks.com>
>> Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.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 ?
Or are you suggesting per-cpu counters would be preferred which would
possibly eliminate the need for this lock?
>
>> - 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.
>
>
>
next prev parent reply other threads:[~2015-03-19 21:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 19:51 [PATCH v1 net-next] tuntap: convert to 64-bit interface statistics Jonathan Toppins
2015-03-19 21:38 ` Eric Dumazet
2015-03-19 21:50 ` Jonathan Toppins
2015-03-19 21:56 ` Jonathan Toppins [this message]
2015-03-19 22:56 ` Eric Dumazet
2015-03-19 23:52 ` Jonathan Toppins
2015-03-20 1:04 ` Eric Dumazet
2015-03-19 23:57 ` Eric Dumazet
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550B4619.6020203@cumulusnetworks.com \
--to=jtoppins@cumulusnetworks.com \
--cc=curt@cumulusnetworks.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).