[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: <>
References: <>
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;
                high = stat >> 32;
                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>