netdev
[Top] [All Lists]

Re: [PATCH]snmp6 64-bit counter support in proc.c

To: Krishna Kumar <kumarkr@xxxxxxxxxx>
Subject: Re: [PATCH]snmp6 64-bit counter support in proc.c
From: "David S. Miller" <davem@xxxxxxxxxx>
Date: Thu, 22 Jan 2004 14:10:26 -0800
Cc: kuznet@xxxxxxxxxxxxx, mashirle@xxxxxxxxxx, netdev@xxxxxxxxxxx, netdev-bounce@xxxxxxxxxxx, xma@xxxxxxxxxx
In-reply-to: <OFBED1B971.06995FF1-ON88256E23.006E3E55@us.ibm.com>
References: <OFBED1B971.06995FF1-ON88256E23.006E3E55@us.ibm.com>
Sender: netdev-bounce@xxxxxxxxxxx
The most portable and simple algorithm to solve this on the reader
side is (and I recommend we don't special case this on 64-bit platforms
just to get wider testing):

        u32 high, low1, low2;

        do {
                low1 = stat & 0xffffffff;
                rmb();
                high = stat >> 32;
                rmb();
                low2 = stat & 0xffffffff;
        } while (low2 < low1);

Something like that.  The idea is to sample the lower 32-bit twice
and if it overflows resample both high and low halfs.

<Prev in Thread] Current Thread [Next in Thread>