Skip to contentSkip to conversation

netdevice.h: Align struct netdevices members

PATCH In review Joe Perches 3 participants 7 messages May 10, 2011 – May 13, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netdevice.h: Align struct netdevices members

Save a bit of space.

---
 include/linux/netdevice.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
include/linux/netdevice.h +4 -4
index d5de66a..0fcb86b 100644
@@ -1020,9 +1020,6 @@ struct net_device {
 	 *	part of the usual set specified in Space.c.
 	 */
 
-	unsigned char		if_port;	/* Selectable AUI, TP,..*/
-	unsigned char		dma;		/* DMA channel		*/
-
 	unsigned long		state;
 
 	struct list_head	dev_list;
@@ -1141,13 +1138,16 @@ struct net_device {
 	const struct header_ops *header_ops;
 
 	unsigned int		flags;	/* interface flags (a la BSD)	*/
+	unsigned int		priv_flags; /* Like 'flags' but invisible to userspace. */
 	unsigned short		gflags;
-        unsigned int            priv_flags; /* Like 'flags' but invisible to userspace. */
 	unsigned short		padded;	/* How much padding added by alloc_netdev() */
 
 	unsigned char		operstate; /* RFC2863 operstate */
 	unsigned char		link_mode; /* mapping policy to operstate */
 
+	unsigned char		if_port;	/* Selectable AUI, TP,..*/
+	unsigned char		dma;		/* DMA channel		*/
+
 	unsigned int		mtu;	/* interface MTU value		*/
 	unsigned short		type;	/* interface hardware type	*/
 	unsigned short		hard_header_len;	/* hardware hdr length	*/
#1 lore raw
Quoted 7 lines · Joe Perches

Save a bit of space.

---
 include/linux/netdevice.h |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Hmm... correct alignements are far more important for this structure.

Did you run benchmarks on 32bit and 64bit platforms ?

BTW we have ____cacheline_aligned_in_smp markers, I am not even sure this patch saves space.

Quoted 33 lines
include/linux/netdevice.h +4 -4
index d5de66a..0fcb86b 100644
@@ -1020,9 +1020,6 @@ struct net_device {
 	 *	part of the usual set specified in Space.c.
 	 */
 
-	unsigned char		if_port;	/* Selectable AUI, TP,..*/
-	unsigned char		dma;		/* DMA channel		*/
-
 	unsigned long		state;
 
 	struct list_head	dev_list;
@@ -1141,13 +1138,16 @@ struct net_device {
 	const struct header_ops *header_ops;
 
 	unsigned int		flags;	/* interface flags (a la BSD)	*/
+	unsigned int		priv_flags; /* Like 'flags' but invisible to userspace. */
 	unsigned short		gflags;
-        unsigned int            priv_flags; /* Like 'flags' but invisible to userspace. */
 	unsigned short		padded;	/* How much padding added by alloc_netdev() */
 
 	unsigned char		operstate; /* RFC2863 operstate */
 	unsigned char		link_mode; /* mapping policy to operstate */
 
+	unsigned char		if_port;	/* Selectable AUI, TP,..*/
+	unsigned char		dma;		/* DMA channel		*/
+
 	unsigned int		mtu;	/* interface MTU value		*/
 	unsigned short		type;	/* interface hardware type	*/
 	unsigned short		hard_header_len;	/* hardware hdr length	*/
#2 lore raw
Quoted 3 lines · Eric Dumazet
Quoted 1 line · Joe Perches

Save a bit of space.

Hmm... correct alignements are far more important for this structure.

I agree. I aligned these members on "natural" boundaries. 4 consecutive chars rather than 2 chars, unsigned long.

Quoted 1 line

Did you run benchmarks on 32bit and 64bit platforms ?

Nope.

Quoted 2 lines

BTW we have ____cacheline_aligned_in_smp markers, I am not even sure this patch saves space.

That depends on whether or not CONFIG_SMP is defined and all of the changes are before any ____cacheline_aligned markers.

maintainer
#3 lore raw

From: Joe Perches <[email protected]>
Date: Mon, 09 May 2011 21:22:05 -0700

Quoted 10 lines · Eric Dumazet
Quoted 3 lines · Joe Perches
Quoted 1 line

Save a bit of space.

Hmm... correct alignements are far more important for this structure.

I agree. I aligned these members on "natural" boundaries. 4 consecutive chars rather than 2 chars, unsigned long.

Quoted 1 line

Did you run benchmarks on 32bit and 64bit platforms ?

Quoted 7 lines

Nope.

Quoted 2 lines

BTW we have ____cacheline_aligned_in_smp markers, I am not even sure this patch saves space.

That depends on whether or not CONFIG_SMP is defined and all of the changes are before any ____cacheline_aligned markers.

I think this is sane, Eric do you still have objections?

#4 lore raw
Quoted 1 line · David Miller

I think this is sane, Eric do you still have objections?

Hey David.

If you apply this, can you please correct the
subject line typo from netdevices to net_device?

Thanks, Joe