Skip to content

Commit 5fbe395

Browse files
yangflkuba-moo
authored andcommitted
idpf: Fix data race in idpf_net_dim
In idpf_net_dim(), some statistics protected by u64_stats_sync, are read and accumulated in ignorance of possible u64_stats_fetch_retry() events. The correct way to copy statistics is already illustrated by idpf_add_queue_stats(). Fix this by reading them into temporary variables first. Fixes: c2d548c ("idpf: add TX splitq napi poll support") Fixes: 3a8845a ("idpf: add RX splitq napi poll support") Signed-off-by: David Yang <mmyangfl@gmail.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20260119162720.1463859-1-mmyangfl@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 748a81c commit 5fbe395

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

drivers/net/ethernet/intel/idpf/idpf_txrx.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,7 +3941,7 @@ static void idpf_update_dim_sample(struct idpf_q_vector *q_vector,
39413941
static void idpf_net_dim(struct idpf_q_vector *q_vector)
39423942
{
39433943
struct dim_sample dim_sample = { };
3944-
u64 packets, bytes;
3944+
u64 packets, bytes, pkts, bts;
39453945
u32 i;
39463946

39473947
if (!IDPF_ITR_IS_DYNAMIC(q_vector->tx_intr_mode))
@@ -3953,9 +3953,12 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)
39533953

39543954
do {
39553955
start = u64_stats_fetch_begin(&txq->stats_sync);
3956-
packets += u64_stats_read(&txq->q_stats.packets);
3957-
bytes += u64_stats_read(&txq->q_stats.bytes);
3956+
pkts = u64_stats_read(&txq->q_stats.packets);
3957+
bts = u64_stats_read(&txq->q_stats.bytes);
39583958
} while (u64_stats_fetch_retry(&txq->stats_sync, start));
3959+
3960+
packets += pkts;
3961+
bytes += bts;
39593962
}
39603963

39613964
idpf_update_dim_sample(q_vector, &dim_sample, &q_vector->tx_dim,
@@ -3972,9 +3975,12 @@ static void idpf_net_dim(struct idpf_q_vector *q_vector)
39723975

39733976
do {
39743977
start = u64_stats_fetch_begin(&rxq->stats_sync);
3975-
packets += u64_stats_read(&rxq->q_stats.packets);
3976-
bytes += u64_stats_read(&rxq->q_stats.bytes);
3978+
pkts = u64_stats_read(&rxq->q_stats.packets);
3979+
bts = u64_stats_read(&rxq->q_stats.bytes);
39773980
} while (u64_stats_fetch_retry(&rxq->stats_sync, start));
3981+
3982+
packets += pkts;
3983+
bytes += bts;
39783984
}
39793985

39803986
idpf_update_dim_sample(q_vector, &dim_sample, &q_vector->rx_dim,

0 commit comments

Comments
 (0)