]> git.baikalelectronics.ru Git - kernel.git/commit
net: Introduce u64_stats_sync infrastructure
authorEric Dumazet <eric.dumazet@gmail.com>
Tue, 22 Jun 2010 17:22:17 +0000 (10:22 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 Jun 2010 19:59:47 +0000 (12:59 -0700)
commit94f13c982f4cfd1a7a5ba3051e836e0b04d74758
tree1721b297633a798beb166a4c8778edb1a8a474ad
parent033f89812ff447933cccc59d2da83706c28ac3ff
net: Introduce u64_stats_sync infrastructure

To properly implement 64bits network statistics on 32bit or 64bit hosts,
we provide one new type and four methods, to ease conversions.

Stats producer should use following template granted it already got an
exclusive access to counters (include/linux/u64_stats_sync.h contains
some documentation about details)

    u64_stats_update_begin(&stats->syncp);
    stats->bytes64 += len;
    stats->packets64++;
    u64_stats_update_end(&stats->syncp);

While a consumer should use following template to get consistent
snapshot :

    u64 tbytes, tpackets;
    unsigned int start;

    do {
        start = u64_stats_fetch_begin(&stats->syncp);
        tbytes = stats->bytes64;
        tpackets = stats->packets64;
    } while (u64_stats_fetch_retry(&stats->lock, syncp));

Suggested by David Miller, and comments courtesy of Nick Piggin.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/u64_stats_sync.h [new file with mode: 0644]