Skip to content

Commit 302e5b4

Browse files
yangflkuba-moo
authored andcommitted
be2net: fix data race in be_get_new_eqd
In be_get_new_eqd(), statistics of pkts, protected by u64_stats_sync, are read and accumulated in ignorance of possible u64_stats_fetch_retry() events. Before the commit in question, these statistics were retrieved one by one directly from queues. Fix this by reading them into temporary variables first. Fixes: 2094777 ("be2net: set interrupt moderation for Skyhawk-R using EQ-DB") Signed-off-by: David Yang <mmyangfl@gmail.com> Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev> Link: https://patch.msgid.link/20260119153440.1440578-1-mmyangfl@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 5fbe395 commit 302e5b4

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

drivers/net/ethernet/emulex/benet/be_main.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ static int be_get_new_eqd(struct be_eq_obj *eqo)
21412141
struct be_aic_obj *aic;
21422142
struct be_rx_obj *rxo;
21432143
struct be_tx_obj *txo;
2144-
u64 rx_pkts = 0, tx_pkts = 0;
2144+
u64 rx_pkts = 0, tx_pkts = 0, pkts;
21452145
ulong now;
21462146
u32 pps, delta;
21472147
int i;
@@ -2157,15 +2157,17 @@ static int be_get_new_eqd(struct be_eq_obj *eqo)
21572157
for_all_rx_queues_on_eq(adapter, eqo, rxo, i) {
21582158
do {
21592159
start = u64_stats_fetch_begin(&rxo->stats.sync);
2160-
rx_pkts += rxo->stats.rx_pkts;
2160+
pkts = rxo->stats.rx_pkts;
21612161
} while (u64_stats_fetch_retry(&rxo->stats.sync, start));
2162+
rx_pkts += pkts;
21622163
}
21632164

21642165
for_all_tx_queues_on_eq(adapter, eqo, txo, i) {
21652166
do {
21662167
start = u64_stats_fetch_begin(&txo->stats.sync);
2167-
tx_pkts += txo->stats.tx_reqs;
2168+
pkts = txo->stats.tx_reqs;
21682169
} while (u64_stats_fetch_retry(&txo->stats.sync, start));
2170+
tx_pkts += pkts;
21692171
}
21702172

21712173
/* Skip, if wrapped around or first calculation */

0 commit comments

Comments
 (0)