From: Rongqing Li <rongqing.li@windriver.com>
To: David Miller <davem@davemloft.net>
Cc: <roy.qing.li@gmail.com>, <netdev@vger.kernel.org>, <edumazet@google.com>
Subject: Re: [PATCH net-next] ipv6: fix the use of pcpu_tstats in ip6_tunnel
Date: Thu, 2 Jan 2014 12:41:02 +0800 [thread overview]
Message-ID: <52C4EDDE.9000303@windriver.com> (raw)
In-Reply-To: <20140101.225033.1351962333260167430.davem@davemloft.net>
On 01/02/2014 11:50 AM, David Miller wrote:
> From: roy.qing.li@gmail.com
> Date: Thu, 2 Jan 2014 08:49:40 +0800
>
>> Eric Dumazet <edumazet@google.com>
>
> What is this?
Sorry, it should CC to Eric Dumazet
>
>> Signed-off-by: Li RongQing <roy.qing.li@gmail.com>
> ...
>> {
>> - struct pcpu_tstats sum = { 0 };
>> + struct pcpu_tstats tmp, sum = { 0 };
>> int i;
>>
>> - for_each_possible_cpu(i) {
>> - const struct pcpu_tstats *tstats = per_cpu_ptr(dev->tstats, i);
>> + BUILD_BUG_ON(offsetof(typeof(tmp), syncp) !=
>> + sizeof(tmp) - sizeof(tmp.syncp));
>>
>> - sum.rx_packets += tstats->rx_packets;
>> - sum.rx_bytes += tstats->rx_bytes;
>> - sum.tx_packets += tstats->tx_packets;
>> - sum.tx_bytes += tstats->tx_bytes;
>> + for_each_possible_cpu(i) {
>> + unsigned int start;
>> + const struct pcpu_tstats *stat = per_cpu_ptr(dev->tstats, i);
>> +
>> + do {
>> + start = u64_stats_fetch_begin_bh(&stat->syncp);
>> + memcpy(&tmp, stat, sizeof(tmp) - sizeof(stat->syncp));
>> + } while (u64_stats_fetch_retry_bh(&stat->syncp, start));
>
> It's entirely wasteful and non-canonical to use an on-stack copy for this,
> just surround the entire set of statistic increments within the u64 stats
> updata sequence. Then you don't need the on-stack thing.
>
Ok, I see.
Thanks
-Roy
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
--
Best Reagrds,
Roy | RongQing Li
next prev parent reply other threads:[~2014-01-02 4:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-02 0:49 [PATCH net-next] ipv6: fix the use of pcpu_tstats in ip6_tunnel roy.qing.li
2014-01-02 3:50 ` David Miller
2014-01-02 4:41 ` Rongqing Li [this message]
2014-01-02 14:53 ` Ben Hutchings
2014-01-02 3:56 ` 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=52C4EDDE.9000303@windriver.com \
--to=rongqing.li@windriver.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=netdev@vger.kernel.org \
--cc=roy.qing.li@gmail.com \
/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).