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

drop_monitor: adopt u64_stats_t

As explained in commit 316580b69d0a ("u64_stats: provide u64_stats_t type")
we should use u64_stats_t and related accessors to avoid load/store tearing.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eric Dumazet and committed by
Jakub Kicinski
c6cce71e 958751e0

+9 -9
+9 -9
net/core/drop_monitor.c
··· 55 55 static DEFINE_MUTEX(net_dm_mutex); 56 56 57 57 struct net_dm_stats { 58 - u64 dropped; 58 + u64_stats_t dropped; 59 59 struct u64_stats_sync syncp; 60 60 }; 61 61 ··· 530 530 unlock_free: 531 531 spin_unlock_irqrestore(&data->drop_queue.lock, flags); 532 532 u64_stats_update_begin(&data->stats.syncp); 533 - data->stats.dropped++; 533 + u64_stats_inc(&data->stats.dropped); 534 534 u64_stats_update_end(&data->stats.syncp); 535 535 consume_skb(nskb); 536 536 } ··· 986 986 unlock_free: 987 987 spin_unlock_irqrestore(&hw_data->drop_queue.lock, flags); 988 988 u64_stats_update_begin(&hw_data->stats.syncp); 989 - hw_data->stats.dropped++; 989 + u64_stats_inc(&hw_data->stats.dropped); 990 990 u64_stats_update_end(&hw_data->stats.syncp); 991 991 net_dm_hw_metadata_free(n_hw_metadata); 992 992 free: ··· 1433 1433 1434 1434 do { 1435 1435 start = u64_stats_fetch_begin_irq(&cpu_stats->syncp); 1436 - dropped = cpu_stats->dropped; 1436 + dropped = u64_stats_read(&cpu_stats->dropped); 1437 1437 } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, start)); 1438 1438 1439 - stats->dropped += dropped; 1439 + u64_stats_add(&stats->dropped, dropped); 1440 1440 } 1441 1441 } 1442 1442 ··· 1452 1452 return -EMSGSIZE; 1453 1453 1454 1454 if (nla_put_u64_64bit(msg, NET_DM_ATTR_STATS_DROPPED, 1455 - stats.dropped, NET_DM_ATTR_PAD)) 1455 + u64_stats_read(&stats.dropped), NET_DM_ATTR_PAD)) 1456 1456 goto nla_put_failure; 1457 1457 1458 1458 nla_nest_end(msg, attr); ··· 1477 1477 1478 1478 do { 1479 1479 start = u64_stats_fetch_begin_irq(&cpu_stats->syncp); 1480 - dropped = cpu_stats->dropped; 1480 + dropped = u64_stats_read(&cpu_stats->dropped); 1481 1481 } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, start)); 1482 1482 1483 - stats->dropped += dropped; 1483 + u64_stats_add(&stats->dropped, dropped); 1484 1484 } 1485 1485 } 1486 1486 ··· 1496 1496 return -EMSGSIZE; 1497 1497 1498 1498 if (nla_put_u64_64bit(msg, NET_DM_ATTR_STATS_DROPPED, 1499 - stats.dropped, NET_DM_ATTR_PAD)) 1499 + u64_stats_read(&stats.dropped), NET_DM_ATTR_PAD)) 1500 1500 goto nla_put_failure; 1501 1501 1502 1502 nla_nest_end(msg, attr);