dmaengine: Reorder fields in 'struct dma_slave_config'
Commit Message
Group some variables based on their sizes to reduce hole and avoid padding.
On x86_64, this shrinks the size of 'struct dma_slave_config'
from 72 to 64 bytes.
This should save a few bytes of memory and a few cycles.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Using pahole
Before:
======
struct dma_slave_config {
enum dma_transfer_direction direction; /* 0 4 */
/* XXX 4 bytes hole, try to pack */
phys_addr_t src_addr; /* 8 8 */
phys_addr_t dst_addr; /* 16 8 */
enum dma_slave_buswidth src_addr_width; /* 24 4 */
enum dma_slave_buswidth dst_addr_width; /* 28 4 */
u32 src_maxburst; /* 32 4 */
u32 dst_maxburst; /* 36 4 */
u32 src_port_window_size; /* 40 4 */
u32 dst_port_window_size; /* 44 4 */
bool device_fc; /* 48 1 */
/* XXX 7 bytes hole, try to pack */
void * peripheral_config; /* 56 8 */
/* --- cacheline 1 boundary (64 bytes) --- */
size_t peripheral_size; /* 64 8 */
/* size: 72, cachelines: 2, members: 12 */
/* sum members: 61, holes: 2, sum holes: 11 */
/* last cacheline: 8 bytes */
};
After:
=====
struct dma_slave_config {
enum dma_transfer_direction direction; /* 0 4 */
bool device_fc; /* 4 1 */
/* XXX 3 bytes hole, try to pack */
phys_addr_t src_addr; /* 8 8 */
phys_addr_t dst_addr; /* 16 8 */
enum dma_slave_buswidth src_addr_width; /* 24 4 */
enum dma_slave_buswidth dst_addr_width; /* 28 4 */
u32 src_maxburst; /* 32 4 */
u32 dst_maxburst; /* 36 4 */
u32 src_port_window_size; /* 40 4 */
u32 dst_port_window_size; /* 44 4 */
void * peripheral_config; /* 48 8 */
size_t peripheral_size; /* 56 8 */
/* size: 64, cachelines: 1, members: 12 */
/* sum members: 61, holes: 1, sum holes: 3 */
};
---
include/linux/dmaengine.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
@@ -390,6 +390,9 @@ enum dma_slave_buswidth {
* legal values. DEPRECATED, drivers should use the direction argument
* to the device_prep_slave_sg and device_prep_dma_cyclic functions or
* the dir field in the dma_interleaved_template structure.
+ * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill
+ * with 'true' if peripheral should be flow controller. Direction will be
+ * selected at Runtime.
* @src_addr: this is the physical address where DMA slave data
* should be read (RX), if the source is memory this argument is
* ignored.
@@ -415,9 +418,6 @@ enum dma_slave_buswidth {
* loops in this area in order to transfer the data.
* @dst_port_window_size: same as src_port_window_size but for the destination
* port.
- * @device_fc: Flow Controller Settings. Only valid for slave channels. Fill
- * with 'true' if peripheral should be flow controller. Direction will be
- * selected at Runtime.
* @peripheral_config: peripheral configuration for programming peripheral
* for dmaengine transfer
* @peripheral_size: peripheral configuration buffer size
@@ -436,6 +436,7 @@ enum dma_slave_buswidth {
*/
struct dma_slave_config {
enum dma_transfer_direction direction;
+ bool device_fc;
phys_addr_t src_addr;
phys_addr_t dst_addr;
enum dma_slave_buswidth src_addr_width;
@@ -444,7 +445,6 @@ struct dma_slave_config {
u32 dst_maxburst;
u32 src_port_window_size;
u32 dst_port_window_size;
- bool device_fc;
void *peripheral_config;
size_t peripheral_size;
};