Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: ifb: 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/20260121082348.2388314-1-mmyangfl@gmail.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

David Yang and committed by
Paolo Abeni
cbe38d2e 40cb4cb7

+9 -9
+9 -9
drivers/net/ifb.c
··· 39 39 #define TX_Q_LIMIT 32 40 40 41 41 struct ifb_q_stats { 42 - u64 packets; 43 - u64 bytes; 42 + u64_stats_t packets; 43 + u64_stats_t bytes; 44 44 struct u64_stats_sync sync; 45 45 }; 46 46 ··· 81 81 static void ifb_update_q_stats(struct ifb_q_stats *stats, int len) 82 82 { 83 83 u64_stats_update_begin(&stats->sync); 84 - stats->packets++; 85 - stats->bytes += len; 84 + u64_stats_inc(&stats->packets); 85 + u64_stats_add(&stats->bytes, len); 86 86 u64_stats_update_end(&stats->sync); 87 87 } 88 88 ··· 163 163 for (i = 0; i < dev->num_tx_queues; i++,txp++) { 164 164 do { 165 165 start = u64_stats_fetch_begin(&txp->rx_stats.sync); 166 - packets = txp->rx_stats.packets; 167 - bytes = txp->rx_stats.bytes; 166 + packets = u64_stats_read(&txp->rx_stats.packets); 167 + bytes = u64_stats_read(&txp->rx_stats.bytes); 168 168 } while (u64_stats_fetch_retry(&txp->rx_stats.sync, start)); 169 169 stats->rx_packets += packets; 170 170 stats->rx_bytes += bytes; 171 171 172 172 do { 173 173 start = u64_stats_fetch_begin(&txp->tx_stats.sync); 174 - packets = txp->tx_stats.packets; 175 - bytes = txp->tx_stats.bytes; 174 + packets = u64_stats_read(&txp->tx_stats.packets); 175 + bytes = u64_stats_read(&txp->tx_stats.bytes); 176 176 } while (u64_stats_fetch_retry(&txp->tx_stats.sync, start)); 177 177 stats->tx_packets += packets; 178 178 stats->tx_bytes += bytes; ··· 248 248 start = u64_stats_fetch_begin(&q_stats->sync); 249 249 for (j = 0; j < IFB_Q_STATS_LEN; j++) { 250 250 offset = ifb_q_stats_desc[j].offset; 251 - (*data)[j] = *(u64 *)(stats_base + offset); 251 + (*data)[j] = u64_stats_read((u64_stats_t *)(stats_base + offset)); 252 252 } 253 253 } while (u64_stats_fetch_retry(&q_stats->sync, start)); 254 254