[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <AE90C24D6B3A694183C094C60CF0A2F6026B6F5D@saturn3.aculab.com>
Date: Thu, 21 Jun 2012 16:18:12 +0100
From: "David Laight" <David.Laight@...LAB.COM>
To: "Tom Parkin" <tparkin@...alix.com>, <netdev@...r.kernel.org>
Cc: "James Chapman" <jchapman@...alix.com>
Subject: RE: [PATCH] l2tp: synchronise u64 stats writer callsites
> Subject: [PATCH] l2tp: synchronise u64 stats writer callsites
>
> Fix statistics update race in l2tp_core. As described in
> include/linux/u64_stats_sync.h, it is necessary for the writers of
> u64 statistics to ensure mutual exclusion to the seqcount for
> statistics synchronisation. Failure to do so may result in a
> missed seqcount update, leaving readers blocking forever.
...
> + spin_lock_bh(&sstats->writelock);
> u64_stats_update_begin(&sstats->syncp);
> sstats->rx_oos_packets++;
> u64_stats_update_end(&sstats->syncp);
> + spin_unlock_bh(&sstats->writelock);
The purpose of the u64_stats_update_begin/end is to
perform lockless writes of the stats.
If you need to lock them (because multiple threads can
be writing to stats covered by the same 'syncp' at the
same time) then the reader might as well use the same lock.
Otherwise split the 'syncp' such that only one update
can be happening (for each sync).
David
--
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