Skip to contentSkip to conversation

Save some bytes in mm_struct by filling holes on 64bit

PATCH In review Andi Kleen 3 participants 4 messages Mar 12, 2008 – Mar 13, 2008 MM core

lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 Save some bytes in mm_struct by filling holes on 64bit

Save some bytes in mm_struct by filling holes

Putting int values together for better packing on 64bit shrinks sizeof(struct mm_struct) from 776 bytes to 760 bytes.

include/linux/mm_types.h +2 -2
Index: linux-2.6.25-rc5/include/linux/mm_types.h
===================================================================
@@ -172,6 +172,7 @@ struct mm_struct {
 	atomic_t mm_users;			/* How many users with user space? */
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
 	int map_count;				/* number of VMAs */
+	rwlock_t		ioctx_list_lock;	/* aio lock */
 	struct rw_semaphore mmap_sem;
 	spinlock_t page_table_lock;		/* Protects page tables and some counters */
 
@@ -213,14 +214,13 @@ struct mm_struct {
 	unsigned int token_priority;
 	unsigned int last_interval;
 
+	int core_waiters;
 	unsigned long flags; /* Must use atomic bitops to access the bits */
 
 	/* coredumping support */
-	int core_waiters;
 	struct completion *core_startup_done, core_done;
 
 	/* aio bits */
-	rwlock_t		ioctx_list_lock;
 	struct kioctx		*ioctx_list;
 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
 	struct mem_cgroup *mem_cgroup;
maintainer
#1 lore raw
Quoted 26 lines · On Wed, 12 Mar 2008 15:28:07 +0100 Andi Kleen <[email protected]> wrote:

Save some bytes in mm_struct by filling holes

Putting int values together for better packing on 64bit shrinks sizeof(struct mm_struct) from 776 bytes to 760 bytes.

Index: linux-2.6.25-rc5/include/linux/mm_types.h
===================================================================

include/linux/mm_types.h +2 -0
@@ -172,6 +172,7 @@ struct mm_struct {
 	atomic_t mm_users;			/* How many users with user space? */
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
 	int map_count;				/* number of VMAs */
+	rwlock_t		ioctx_list_lock;	/* aio lock */
 	struct rw_semaphore mmap_sem;
 	spinlock_t page_table_lock;		/* Protects page tables and some counters */
 
@@ -213,14 +214,13 @@ struct mm_struct {
 	unsigned int token_priority;
 	unsigned int last_interval;
 
+	int core_waiters;
 	unsigned long flags; /* Must use atomic bitops to access the bits */

include/linux/mm_types.h struct mm_struct { · line 226

Quoted 10 lines
include/linux/mm_types.h +0 -2
 
 	/* coredumping support */
-	int core_waiters;
 	struct completion *core_startup_done, core_done;
 
 	/* aio bits */
-	rwlock_t		ioctx_list_lock;
 	struct kioctx		*ioctx_list;
 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
 	struct mem_cgroup *mem_cgroup;

The current ioctx_list_lock position is better from a cache layout POV?

author
#2 lore raw
Quoted 2 lines

The current ioctx_list_lock position is better from a cache layout POV?

Hmm ok you're right perhaps it's better to move core_waiters up instead. Updated patch
Save some bytes in mm_struct by filling holes v2

Putting int values together for better packing on 64bit shrinks sizeof(struct mm_struct) from 776 bytes to 760 bytes.

include/linux/mm_types.h +0 -0
Index: linux-2.6.25-rc5/include/linux/mm_types.h
===================================================================
@@ -172,6 +172,7 @@ struct mm_struct {
 	atomic_t mm_users;			/* How many users with user space? */
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users 

count as 1) */
int map_count; /* number of VMAs */
+ int core_waiters;
struct rw_semaphore mmap_sem;
spinlock_t page_table_lock; /* Protects page tables and some counters */

@@ -216,11 +217,10 @@ struct mm_struct {
unsigned long flags; /* Must use atomic bitops to access the bits */

/* coredumping support */
- int core_waiters;
struct completion *core_startup_done, core_done;

/* aio bits */
- rwlock_t ioctx_list_lock;
+ rwlock_t ioctx_list_lock; /* aio lock */
struct kioctx *ioctx_list;
#ifdef CONFIG_CGROUP_MEM_RES_CTLR
struct mem_cgroup *mem_cgroup;

#3 lore raw
In reply to Andi Kleen
Quoted 5 lines · Andi Kleen

Save some bytes in mm_struct by filling holes

Putting int values together for better packing on 64bit shrinks sizeof(struct mm_struct) from 776 bytes to 760 bytes.

Are you going to fix the nice comments that mentioned what feature they were part of now that things are all mixed together? I wonder if a few bytes aren't worth paying for readable code.

After all now some 'aio bits' things are not in the 'aio bits' labeled section.

Quoted 21 lines

Index: linux-2.6.25-rc5/include/linux/mm_types.h
===================================================================

include/linux/mm_types.h +2 -0
@@ -172,6 +172,7 @@ struct mm_struct {
 	atomic_t mm_users;			/* How many users with user space? */
 	atomic_t mm_count;			/* How many references to "struct mm_struct" (users count as 1) */
 	int map_count;				/* number of VMAs */
+	rwlock_t		ioctx_list_lock;	/* aio lock */
 	struct rw_semaphore mmap_sem;
 	spinlock_t page_table_lock;		/* Protects page tables and some counters */
 
@@ -213,14 +214,13 @@ struct mm_struct {
 	unsigned int token_priority;
 	unsigned int last_interval;
 
+	int core_waiters;
 	unsigned long flags; /* Must use atomic bitops to access the bits */
 

include/linux/mm_types.h struct mm_struct {

Quoted 10 lines
include/linux/mm_types.h +0 -3
 	/* coredumping support */
-	int core_waiters;
 	struct completion *core_startup_done, core_done;
 
 	/* aio bits */
-	rwlock_t		ioctx_list_lock;
 	struct kioctx		*ioctx_list;
 #ifdef CONFIG_CGROUP_MEM_RES_CTLR
 	struct mem_cgroup *mem_cgroup;
--

--
Len Sorensen