Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 203194
b: refs/heads/master
c: 33d91f0
h: refs/heads/master
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 29, 2010
1 parent dc87d12 commit 18e0fe4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 16 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7a9b2d59507d85569b8a456688ef40cf2ac73e48
refs/heads/master: 33d91f00c73ba0012bce18c1690cb8313ca7adaa
59 changes: 44 additions & 15 deletions trunk/include/linux/u64_stats_sync.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
* (On UP, there is no seqcount_t protection, a reader allowing interrupts could
* read partial values)
*
* 7) For softirq uses, readers can use u64_stats_fetch_begin_bh() and
* u64_stats_fetch_retry_bh() helpers
*
* Usage :
*
* Stats producer (writer) should use following template granted it already got
Expand Down Expand Up @@ -58,54 +61,80 @@
*/
#include <linux/seqlock.h>

#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
struct u64_stats_sync {
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
seqcount_t seq;
#endif
};

static void inline u64_stats_update_begin(struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
write_seqcount_begin(&syncp->seq);
#endif
}

static void inline u64_stats_update_end(struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
write_seqcount_end(&syncp->seq);
#endif
}

static unsigned int inline u64_stats_fetch_begin(const struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
return read_seqcount_begin(&syncp->seq);
#else
#if BITS_PER_LONG==32
preempt_disable();
#endif
return 0;
#endif
}

static bool inline u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
unsigned int start)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
return read_seqcount_retry(&syncp->seq, start);
}

#else
struct u64_stats_sync {
};

static void inline u64_stats_update_begin(struct u64_stats_sync *syncp)
{
}

static void inline u64_stats_update_end(struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG==32
preempt_enable();
#endif
return false;
#endif
}

static unsigned int inline u64_stats_fetch_begin(const struct u64_stats_sync *syncp)
/*
* In case softirq handlers can update u64 counters, readers can use following helpers
* - SMP 32bit arches use seqcount protection, irq safe.
* - UP 32bit must disable BH.
* - 64bit have no problem atomically reading u64 values, irq safe.
*/
static unsigned int inline u64_stats_fetch_begin_bh(const struct u64_stats_sync *syncp)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
return read_seqcount_begin(&syncp->seq);
#else
#if BITS_PER_LONG==32
local_bh_disable();
#endif
return 0;
#endif
}

static bool inline u64_stats_fetch_retry(const struct u64_stats_sync *syncp,
static bool inline u64_stats_fetch_retry_bh(const struct u64_stats_sync *syncp,
unsigned int start)
{
#if BITS_PER_LONG==32 && defined(CONFIG_SMP)
return read_seqcount_retry(&syncp->seq, start);
#else
#if BITS_PER_LONG==32
local_bh_enable();
#endif
return false;
}
#endif
}

#endif /* _LINUX_U64_STATS_SYNC_H */

0 comments on commit 18e0fe4

Please sign in to comment.