mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 16:44:58 +02:00
wifi: mac80211: use u64_stats_t with u64_stats_sync properly
On 64bit arches, struct u64_stats_sync is empty and provides no help against load/store tearing. Convert to u64_stats_t to ensure atomic operations. Signed-off-by: David Yang <mmyangfl@gmail.com> Link: https://patch.msgid.link/20260123203845.2915525-1-mmyangfl@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
parent
9b50d9c06c
commit
95110e5736
|
|
@ -1880,7 +1880,7 @@ ieee80211_rx_h_sta_process(struct ieee80211_rx_data *rx)
|
|||
link_sta->rx_stats.fragments++;
|
||||
|
||||
u64_stats_update_begin(&link_sta->rx_stats.syncp);
|
||||
link_sta->rx_stats.bytes += rx->skb->len;
|
||||
u64_stats_add(&link_sta->rx_stats.bytes, rx->skb->len);
|
||||
u64_stats_update_end(&link_sta->rx_stats.syncp);
|
||||
|
||||
if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) {
|
||||
|
|
@ -2785,7 +2785,7 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx)
|
|||
* frame, so count MSDUs.
|
||||
*/
|
||||
u64_stats_update_begin(&rx->link_sta->rx_stats.syncp);
|
||||
rx->link_sta->rx_stats.msdu[rx->seqno_idx]++;
|
||||
u64_stats_inc(&rx->link_sta->rx_stats.msdu[rx->seqno_idx]);
|
||||
u64_stats_update_end(&rx->link_sta->rx_stats.syncp);
|
||||
}
|
||||
|
||||
|
|
@ -4878,8 +4878,8 @@ static void ieee80211_rx_8023(struct ieee80211_rx_data *rx,
|
|||
* frame, so count MSDUs.
|
||||
*/
|
||||
u64_stats_update_begin(&stats->syncp);
|
||||
stats->msdu[rx->seqno_idx]++;
|
||||
stats->bytes += orig_len;
|
||||
u64_stats_inc(&stats->msdu[rx->seqno_idx]);
|
||||
u64_stats_add(&stats->bytes, orig_len);
|
||||
u64_stats_update_end(&stats->syncp);
|
||||
|
||||
if (fast_rx->internal_forward) {
|
||||
|
|
|
|||
|
|
@ -360,7 +360,9 @@ static void sta_accumulate_removed_link_stats(struct sta_info *sta, int link_id)
|
|||
struct link_sta_info *link_sta = wiphy_dereference(sta->local->hw.wiphy,
|
||||
sta->link[link_id]);
|
||||
struct ieee80211_link_data *link;
|
||||
unsigned int start;
|
||||
int ac, tid;
|
||||
u64 value;
|
||||
u32 thr;
|
||||
|
||||
for (ac = 0; ac < IEEE80211_NUM_ACS; ac++) {
|
||||
|
|
@ -369,8 +371,13 @@ static void sta_accumulate_removed_link_stats(struct sta_info *sta, int link_id)
|
|||
sta->rem_link_stats.tx_bytes += link_sta->tx_stats.bytes[ac];
|
||||
}
|
||||
|
||||
do {
|
||||
start = u64_stats_fetch_begin(&link_sta->rx_stats.syncp);
|
||||
value = u64_stats_read(&link_sta->rx_stats.bytes);
|
||||
} while (u64_stats_fetch_retry(&link_sta->rx_stats.syncp, start));
|
||||
|
||||
sta->rem_link_stats.rx_packets += link_sta->rx_stats.packets;
|
||||
sta->rem_link_stats.rx_bytes += link_sta->rx_stats.bytes;
|
||||
sta->rem_link_stats.rx_bytes += value;
|
||||
sta->rem_link_stats.tx_retries += link_sta->status_stats.retry_count;
|
||||
sta->rem_link_stats.tx_failed += link_sta->status_stats.retry_failed;
|
||||
sta->rem_link_stats.rx_dropped_misc += link_sta->rx_stats.dropped;
|
||||
|
|
@ -380,8 +387,13 @@ static void sta_accumulate_removed_link_stats(struct sta_info *sta, int link_id)
|
|||
sta->rem_link_stats.expected_throughput += thr;
|
||||
|
||||
for (tid = 0; tid < IEEE80211_NUM_TIDS; tid++) {
|
||||
sta->rem_link_stats.pertid_stats.rx_msdu +=
|
||||
link_sta->rx_stats.msdu[tid];
|
||||
do {
|
||||
start = u64_stats_fetch_begin(&link_sta->rx_stats.syncp);
|
||||
value = u64_stats_read(&link_sta->rx_stats.msdu[tid]);
|
||||
} while (u64_stats_fetch_retry(&link_sta->rx_stats.syncp,
|
||||
start));
|
||||
|
||||
sta->rem_link_stats.pertid_stats.rx_msdu += value;
|
||||
sta->rem_link_stats.pertid_stats.tx_msdu +=
|
||||
link_sta->tx_stats.msdu[tid];
|
||||
sta->rem_link_stats.pertid_stats.tx_msdu_retries +=
|
||||
|
|
@ -2578,7 +2590,7 @@ static inline u64 sta_get_tidstats_msdu(struct ieee80211_sta_rx_stats *rxstats,
|
|||
|
||||
do {
|
||||
start = u64_stats_fetch_begin(&rxstats->syncp);
|
||||
value = rxstats->msdu[tid];
|
||||
value = u64_stats_read(&rxstats->msdu[tid]);
|
||||
} while (u64_stats_fetch_retry(&rxstats->syncp, start));
|
||||
|
||||
return value;
|
||||
|
|
@ -2654,7 +2666,7 @@ static inline u64 sta_get_stats_bytes(struct ieee80211_sta_rx_stats *rxstats)
|
|||
|
||||
do {
|
||||
start = u64_stats_fetch_begin(&rxstats->syncp);
|
||||
value = rxstats->bytes;
|
||||
value = u64_stats_read(&rxstats->bytes);
|
||||
} while (u64_stats_fetch_retry(&rxstats->syncp, start));
|
||||
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -434,8 +434,8 @@ struct ieee80211_sta_rx_stats {
|
|||
s8 chain_signal_last[IEEE80211_MAX_CHAINS];
|
||||
u32 last_rate;
|
||||
struct u64_stats_sync syncp;
|
||||
u64 bytes;
|
||||
u64 msdu[IEEE80211_NUM_TIDS + 1];
|
||||
u64_stats_t bytes;
|
||||
u64_stats_t msdu[IEEE80211_NUM_TIDS + 1];
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user