From: Eric Dumazet <eric.dumazet@gmail.com>
To: Kevin Groeneveld <kgroeneveld@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ppp: add 64 bit stats
Date: Mon, 23 Jul 2012 17:59:44 +0200 [thread overview]
Message-ID: <1343059184.2626.11027.camel@edumazet-glaptop> (raw)
In-Reply-To: <CABF+-6WHqzXhvv9etdAqsamZirbWxWJEsnU-CQ1H8tvynCTOZA@mail.gmail.com>
On Mon, 2012-07-23 at 11:25 -0400, Kevin Groeneveld wrote:
> I am curious if you can elaborate on what is racy about the patch, I
> am still trying to learn. I assumed (possibly incorrectly) that
> because I was using percpu variables that the stats updates didn't
> need any extra synchronization as any concurrent updates would be on
> different cpus.
>
ppp paths (xmit versus receive) are reentrant.
Therefore several cpus might do the
u64_stats_update_begin(&stats->syncp) at the same moment : one increment
could be lost forever, making all readers looping forever in
u64_stats_fetch_begin_bh()
include/linux/u64_stats_sync.h
* 3) Write side must ensure mutual exclusion or one seqcount update could
* be lost, thus blocking readers forever.
* If this synchronization point is not a mutex, but a spinlock or
* spinlock_bh() or disable_bh() :
> > I really doubt ppp is performance sensitive, it so doesnt need percpu
> > counter.
> >
> > If you really want 64bits stats on ppp, use proper synchronization
> > around u64 counters (but shared ones)
>
> I will work on an updated patch without the percpu variables. I
> didn't really think about servers with many cpus and many ppp sessions
> when I created the patch, I was mainly thinking about my Linksys
> router and other simple clients. Many of the other network drivers
> use percpu variables for their stats so I just followed along.
Because there is one loopback device only, not thousands ;)
>
> Would proper synchronization in this case just be wrapping the updates
> in a spin_lock/spin_unlock?
Would be fine (if the proper BH safe variant is used), or you could also
use atomic64_t.
next prev parent reply other threads:[~2012-07-23 15:59 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-22 20:19 [PATCH] ppp: add 64 bit stats Kevin Groeneveld
2012-07-22 21:54 ` David Miller
2012-07-23 0:32 ` Kevin Groeneveld
2012-07-23 0:40 ` David Miller
2012-07-23 5:16 ` Eric Dumazet
2012-07-23 15:25 ` Kevin Groeneveld
2012-07-23 15:59 ` Eric Dumazet [this message]
2012-07-24 1:53 ` Kevin Groeneveld
2012-07-24 6:22 ` Eric Dumazet
2012-07-25 2:27 ` Kevin Groeneveld
2012-07-25 4:04 ` Eric Dumazet
2012-07-25 14:43 ` Kevin Groeneveld
2012-07-25 14:50 ` 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=1343059184.2626.11027.camel@edumazet-glaptop \
--to=eric.dumazet@gmail.com \
--cc=kgroeneveld@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