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

stmmac: review private structure fields

recently many new supports have been added in the stmmac driver w/o taking care
about where each new field had to be placed inside the private structure for
guaranteeing the best cache usage.
This is what I wanted in the beginning, so this patch reorganizes all the fields
in order to keep adjacent fields for cache effect.
I have also tried to optimize them by using pahole.

V2: do not abuse with ____cacheline_aligned_in_smp and keep fields that
potentially could stay in the same cache-line for better usage in SMP systems.

Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Giuseppe CAVALLARO and committed by
David S. Miller
1bb6dea8 ceb69499

+35 -35
+35 -35
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 35 35 36 36 struct stmmac_priv { 37 37 /* Frequently used values are kept adjacent for cache effect */ 38 - struct dma_desc *dma_tx ____cacheline_aligned; /* Basic TX desc */ 39 - struct dma_extended_desc *dma_etx; /* Extended TX descriptor */ 40 - dma_addr_t dma_tx_phy; 38 + struct dma_extended_desc *dma_etx ____cacheline_aligned_in_smp; 39 + struct dma_desc *dma_tx; 41 40 struct sk_buff **tx_skbuff; 42 - dma_addr_t *tx_skbuff_dma; 43 41 unsigned int cur_tx; 44 42 unsigned int dirty_tx; 45 43 unsigned int dma_tx_size; 44 + u32 tx_count_frames; 45 + u32 tx_coal_frames; 46 + u32 tx_coal_timer; 47 + dma_addr_t *tx_skbuff_dma; 48 + dma_addr_t dma_tx_phy; 46 49 int tx_coalesce; 50 + int hwts_tx_en; 51 + spinlock_t tx_lock; 52 + bool tx_path_in_lpi_mode; 53 + struct timer_list txtimer; 47 54 48 - struct dma_desc *dma_rx; /* Basic RX descriptor */ 49 - struct dma_extended_desc *dma_erx; /* Extended RX descriptor */ 55 + struct dma_desc *dma_rx ____cacheline_aligned_in_smp; 56 + struct dma_extended_desc *dma_erx; 57 + struct sk_buff **rx_skbuff; 50 58 unsigned int cur_rx; 51 59 unsigned int dirty_rx; 52 - struct sk_buff **rx_skbuff; 53 - dma_addr_t *rx_skbuff_dma; 54 - 55 - struct net_device *dev; 56 - dma_addr_t dma_rx_phy; 57 60 unsigned int dma_rx_size; 58 61 unsigned int dma_buf_sz; 62 + u32 rx_riwt; 63 + int hwts_rx_en; 64 + dma_addr_t *rx_skbuff_dma; 65 + dma_addr_t dma_rx_phy; 66 + 67 + struct napi_struct napi ____cacheline_aligned_in_smp; 68 + 69 + void __iomem *ioaddr; 70 + struct net_device *dev; 59 71 struct device *device; 60 72 struct mac_device_info *hw; 61 - void __iomem *ioaddr; 62 - 63 - struct stmmac_extra_stats xstats; 64 - struct napi_struct napi; 65 73 int no_csum_insertion; 74 + spinlock_t lock; 66 75 67 - struct phy_device *phydev; 76 + struct phy_device *phydev ____cacheline_aligned_in_smp; 68 77 int oldlink; 69 78 int speed; 70 79 int oldduplex; ··· 82 73 struct mii_bus *mii; 83 74 int mii_irq[PHY_MAX_ADDR]; 84 75 76 + struct stmmac_extra_stats xstats ____cacheline_aligned_in_smp; 77 + struct plat_stmmacenet_data *plat; 78 + struct dma_features dma_cap; 79 + struct stmmac_counters mmc; 80 + int hw_cap_support; 81 + int synopsys_id; 85 82 u32 msg_enable; 86 - spinlock_t lock; 87 - spinlock_t tx_lock; 88 83 int wolopts; 89 84 int wol_irq; 90 - struct plat_stmmacenet_data *plat; 91 - struct stmmac_counters mmc; 92 - struct dma_features dma_cap; 93 - int hw_cap_support; 94 85 struct clk *stmmac_clk; 95 86 int clk_csr; 96 - int synopsys_id; 97 87 struct timer_list eee_ctrl_timer; 98 - bool tx_path_in_lpi_mode; 99 88 int lpi_irq; 100 89 int eee_enabled; 101 90 int eee_active; 102 91 int tx_lpi_timer; 103 - struct timer_list txtimer; 104 - u32 tx_count_frames; 105 - u32 tx_coal_frames; 106 - u32 tx_coal_timer; 107 - int use_riwt; 108 - u32 rx_riwt; 92 + int pcs; 109 93 unsigned int mode; 110 94 int extend_desc; 111 - int pcs; 112 - int hwts_tx_en; 113 - int hwts_rx_en; 114 - unsigned int default_addend; 115 - u32 adv_ts; 116 95 struct ptp_clock *ptp_clock; 117 96 struct ptp_clock_info ptp_clock_ops; 97 + unsigned int default_addend; 98 + u32 adv_ts; 99 + int use_riwt; 118 100 spinlock_t ptp_lock; 119 101 }; 120 102