Skip to contentSkip to conversation

stats: remove useless memset's

PATCH In review [email protected] 4 participants 4 messages Jan 21, 2015 – Jan 27, 2015 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stats: remove useless memset's

From: Stephen Hemminger <[email protected]>

The rte_eth_stats_get is the only API that should call the device statistics function directly, and it already does a memset of the resulting structure. Therefore doing memset() in the driver is redundant and should be removed.

---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 2 --
 lib/librte_pmd_bond/rte_eth_bond_pmd.c       | 4 ----
 lib/librte_pmd_enic/enic_main.c              | 1 -
 lib/librte_pmd_i40e/i40e_ethdev_vf.c         | 1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c          | 1 -
 lib/librte_pmd_ring/rte_eth_ring.c           | 1 -
 6 files changed, 10 deletions(-)
lib/librte_pmd_af_packet/rte_eth_af_packet.c +0 -2
index 755780a..1ffe1cd 100644
@@ -285,8 +285,6 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
 	const struct pmd_internals *internal = dev->data->dev_private;
 
-	memset(igb_stats, 0, sizeof(*igb_stats));
-
 	imax = (internal->nb_queues < RTE_ETHDEV_QUEUE_STAT_CNTRS ?
 	        internal->nb_queues : RTE_ETHDEV_QUEUE_STAT_CNTRS);
 	for (i = 0; i < imax; i++) {
lib/librte_pmd_bond/rte_eth_bond_pmd.c +0 -4
index e9cec2a..8b80297 100644
@@ -1362,12 +1362,8 @@ bond_ethdev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
 	struct bond_dev_private *internals = dev->data->dev_private;
 	struct rte_eth_stats slave_stats;
-
 	int i;
 
-	/* clear bonded stats before populating from slaves */
-	memset(stats, 0, sizeof(*stats));
-
 	for (i = 0; i < internals->slave_count; i++) {
 		rte_eth_stats_get(internals->slaves[i].port_id, &slave_stats);
 
lib/librte_pmd_enic/enic_main.c +0 -1
index 8ab8e44..48fdca2 100644
@@ -211,7 +211,6 @@ void enic_dev_stats_get(struct enic *enic, struct rte_eth_stats *r_stats)
 {
 	struct vnic_stats *stats;
 
-	memset(r_stats, 0, sizeof(*r_stats));
 	if (vnic_dev_stats_dump(enic->vdev, &stats)) {
 		dev_err(enic, "Error in getting stats\n");
 		return;
lib/librte_pmd_i40e/i40e_ethdev_vf.c +0 -1
index fe46cf1..7d8d8ef 100644
@@ -1673,7 +1673,6 @@ i40evf_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 static void
 i40evf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 {
-	memset(stats, 0, sizeof(*stats));
 	if (i40evf_get_statics(dev, stats))
 		PMD_DRV_LOG(ERR, "Get statics failed");
 }
lib/librte_pmd_ixgbe/ixgbe_ethdev.c +0 -1
index b58ec45..e36cdf5 100644
@@ -1940,7 +1940,6 @@ ixgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
 	if (stats == NULL)
 		return;
 
-	memset(stats, 0, sizeof(*stats));
 	stats->ipackets = hw_stats->vfgprc;
 	stats->ibytes = hw_stats->vfgorc;
 	stats->opackets = hw_stats->vfgptc;
lib/librte_pmd_ring/rte_eth_ring.c +0 -1
index 4f1b6ed..f685f08 100644
@@ -165,7 +165,6 @@ eth_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *igb_stats)
 	unsigned long rx_total = 0, tx_total = 0, tx_err_total = 0;
 	const struct pmd_internals *internal = dev->data->dev_private;
 
-	memset(igb_stats, 0, sizeof(*igb_stats));
 	for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS &&
 			i < internal->nb_rx_queues; i++) {
 		igb_stats->q_ipackets[i] = internal->rx_ring_queues[i].rx_pkts.cnt;
Signature · 1 line
2.1.4
Acked-by
#2 lore raw
In reply to a message not in the archive
Quoted 8 lines · On Tue, Jan 20, 2015 at 08:16:58PM -0800…

From: Stephen Hemminger <[email protected]>

The rte_eth_stats_get is the only API that should call the device statistics function directly, and it already does a memset of the resulting structure. Therefore doing memset() in the driver is redundant and should be removed.

#3 lore raw
In reply to a message not in the archive

Hello Stephen,

Quoted 8 lines · On Wed, Jan 21, 2015 at 5:16 AM, <stephen-OTpzqLSitTUnbdJkjeBofR2eb7JE58TQ@publ…

From: Stephen Hemminger <[email protected]>

The rte_eth_stats_get is the only API that should call the device statistics function directly, and it already does a memset of the resulting structure. Therefore doing memset() in the driver is redundant and should be removed.

Quoted 9 lines
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 2 --
 lib/librte_pmd_bond/rte_eth_bond_pmd.c       | 4 ----
 lib/librte_pmd_enic/enic_main.c              | 1 -
 lib/librte_pmd_i40e/i40e_ethdev_vf.c         | 1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c          | 1 -
 lib/librte_pmd_ring/rte_eth_ring.c           | 1 -
 6 files changed, 10 deletions(-)

I think you missed some :
- lib/librte_pmd_e1000/igb_ethdev.c function eth_igbvf_stats_get()
- lib/librte_pmd_pcap/rte_eth_pcap.c function eth_stats_get()

With these fixed :

Signature · 1 line
David Marchand
#5 lore raw
In reply to a message not in the archive

2015-01-21 14:08, David Marchand:

Quoted 20 lines

Hello Stephen,

Quoted 8 lines

From: Stephen Hemminger <[email protected]>

The rte_eth_stats_get is the only API that should call the device statistics function directly, and it already does a memset of the resulting structure. Therefore doing memset() in the driver is redundant and should be removed.

Quoted 9 lines
---
 lib/librte_pmd_af_packet/rte_eth_af_packet.c | 2 --
 lib/librte_pmd_bond/rte_eth_bond_pmd.c       | 4 ----
 lib/librte_pmd_enic/enic_main.c              | 1 -
 lib/librte_pmd_i40e/i40e_ethdev_vf.c         | 1 -
 lib/librte_pmd_ixgbe/ixgbe_ethdev.c          | 1 -
 lib/librte_pmd_ring/rte_eth_ring.c           | 1 -
 6 files changed, 10 deletions(-)
Quoted 6 lines

I think you missed some :
- lib/librte_pmd_e1000/igb_ethdev.c function eth_igbvf_stats_get()
- lib/librte_pmd_pcap/rte_eth_pcap.c function eth_stats_get()

With these fixed :

Applied with above fixes.

Thanks

Signature · 1 line
Thomas