2013-02-05 09:56:25

by Johannes Berg

[permalink] [raw]
Subject: [PATCH] mac80211: provide 64-bit traffic counters

From: Johannes Berg <[email protected]>

"unsigned long" is already 64-bit on (most?) 64-bit
machines, use u64 and tell cfg80211 that we provide
64-bit counters now.

Signed-off-by: Johannes Berg <[email protected]>
---
net/mac80211/cfg.c | 4 ++--
net/mac80211/ieee80211_i.h | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index f4f7e76..fb06d13 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -449,8 +449,8 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
sinfo->generation = sdata->local->sta_generation;

sinfo->filled = STATION_INFO_INACTIVE_TIME |
- STATION_INFO_RX_BYTES |
- STATION_INFO_TX_BYTES |
+ STATION_INFO_RX_BYTES64 |
+ STATION_INFO_TX_BYTES64 |
STATION_INFO_RX_PACKETS |
STATION_INFO_TX_PACKETS |
STATION_INFO_TX_RETRIES |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
index 2b06ff1..4631de0 100644
--- a/net/mac80211/ieee80211_i.h
+++ b/net/mac80211/ieee80211_i.h
@@ -822,7 +822,7 @@ struct tpt_led_trigger {
unsigned int blink_table_len;
struct timer_list timer;
unsigned long prev_traffic;
- unsigned long tx_bytes, rx_bytes;
+ u64 tx_bytes, rx_bytes;
unsigned int active, want;
bool running;
};
--
1.8.0



2013-02-05 17:24:27

by Johannes Berg

[permalink] [raw]
Subject: Re: [PATCH] mac80211: provide 64-bit traffic counters

On Tue, 2013-02-05 at 09:21 -0800, Ben Greear wrote:
> On 02/05/2013 01:56 AM, Johannes Berg wrote:
> > From: Johannes Berg <[email protected]>
> >
> > "unsigned long" is already 64-bit on (most?) 64-bit
> > machines, use u64 and tell cfg80211 that we provide
> > 64-bit counters now.
>
> From what I can tell, these counters are modified using
> += operators. From what I recall, this is non-atomic on
> 32-bit systems when the variable is u64.
>
> Is there any other locking that keeps this from blowing up?

Funny you should ask this, we were discussing RX locking in another
thread :-)

In any case, it's *already* non-atomic since incrementing is always a
read-modify-write cycle, and I think that updates can indeed get lost
for the TX counter (and only it) if frames for multiple ACs are
processed at the same time. The proper way to solve that would probably
be having counters for all ACs and summing them only when needed.

johannes


2013-02-05 17:21:43

by Ben Greear

[permalink] [raw]
Subject: Re: [PATCH] mac80211: provide 64-bit traffic counters

On 02/05/2013 01:56 AM, Johannes Berg wrote:
> From: Johannes Berg <[email protected]>
>
> "unsigned long" is already 64-bit on (most?) 64-bit
> machines, use u64 and tell cfg80211 that we provide
> 64-bit counters now.

From what I can tell, these counters are modified using
+= operators. From what I recall, this is non-atomic on
32-bit systems when the variable is u64.

Is there any other locking that keeps this from blowing up?

Thanks,
Ben


--
Ben Greear <[email protected]>
Candela Technologies Inc http://www.candelatech.com