From: Andi Kleen This patch saves 2MB of memory on a 1GB x86-64 machine, 20MB on a 10GB machine. It does this by eliminating 8 bytes of useless padding in struct page. This resurrects an older patch in a hopefully cleaner form. --- 25-akpm/include/asm-x86_64/bitops.h | 2 ++ 25-akpm/include/linux/mm.h | 10 ++++++++-- 25-akpm/include/linux/mmzone.h | 2 +- 25-akpm/include/linux/rmap-locking.h | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff -puN include/asm-x86_64/bitops.h~x86_64-mem_map-shrinkage include/asm-x86_64/bitops.h --- 25/include/asm-x86_64/bitops.h~x86_64-mem_map-shrinkage Fri Mar 12 11:21:15 2004 +++ 25-akpm/include/asm-x86_64/bitops.h Fri Mar 12 11:21:15 2004 @@ -503,6 +503,8 @@ static __inline__ int ffs(int x) /* find last set bit */ #define fls(x) generic_fls(x) +#define ARCH_HAS_ATOMIC_UNSIGNED 1 + #endif /* __KERNEL__ */ #endif /* _X86_64_BITOPS_H */ diff -puN include/linux/mm.h~x86_64-mem_map-shrinkage include/linux/mm.h --- 25/include/linux/mm.h~x86_64-mem_map-shrinkage Fri Mar 12 11:21:15 2004 +++ 25-akpm/include/linux/mm.h Fri Mar 12 11:21:15 2004 @@ -152,6 +152,12 @@ struct pte_chain; struct mmu_gather; struct inode; +#ifdef ARCH_HAS_ATOMIC_UNSIGNED +typedef unsigned page_flags_t; +#else +typedef unsigned long page_flags_t; +#endif + /* * Each physical page in the system has a struct page associated with * it to keep track of whatever it is we are using the page for at the @@ -168,7 +174,7 @@ struct inode; * TODO: make this structure smaller, it could be as small as 32 bytes. */ struct page { - unsigned long flags; /* atomic flags, some possibly + page_flags_t flags; /* atomic flags, some possibly updated asynchronously */ atomic_t count; /* Usage count, see below. */ struct list_head list; /* ->mapping has some page lists. */ @@ -333,7 +339,7 @@ static inline void put_page(struct page * We'll have up to (MAX_NUMNODES * MAX_NR_ZONES) zones total, * so we use (MAX_NODES_SHIFT + MAX_ZONES_SHIFT) here to get enough bits. */ -#define NODEZONE_SHIFT (BITS_PER_LONG - MAX_NODES_SHIFT - MAX_ZONES_SHIFT) +#define NODEZONE_SHIFT (sizeof(page_flags_t)*8 - MAX_NODES_SHIFT - MAX_ZONES_SHIFT) #define NODEZONE(node, zone) ((node << ZONES_SHIFT) | zone) static inline unsigned long page_zonenum(struct page *page) diff -puN include/linux/mmzone.h~x86_64-mem_map-shrinkage include/linux/mmzone.h --- 25/include/linux/mmzone.h~x86_64-mem_map-shrinkage Fri Mar 12 11:21:15 2004 +++ 25-akpm/include/linux/mmzone.h Fri Mar 12 11:21:15 2004 @@ -316,7 +316,7 @@ extern struct pglist_data contig_page_da #include -#if BITS_PER_LONG == 32 +#if BITS_PER_LONG == 32 || defined(ARCH_HAS_ATOMIC_UNSIGNED) /* * with 32 bit page->flags field, we reserve 8 bits for node/zone info. * there are 3 zones (2 bits) and this leaves 8-2=6 bits for nodes. diff -puN include/linux/rmap-locking.h~x86_64-mem_map-shrinkage include/linux/rmap-locking.h --- 25/include/linux/rmap-locking.h~x86_64-mem_map-shrinkage Fri Mar 12 11:21:15 2004 +++ 25-akpm/include/linux/rmap-locking.h Fri Mar 12 11:21:15 2004 @@ -10,8 +10,8 @@ struct pte_chain; extern kmem_cache_t *pte_chain_cache; -#define pte_chain_lock(page) bit_spin_lock(PG_chainlock, &page->flags) -#define pte_chain_unlock(page) bit_spin_unlock(PG_chainlock, &page->flags) +#define pte_chain_lock(page) bit_spin_lock(PG_chainlock, (unsigned long *)&page->flags) +#define pte_chain_unlock(page) bit_spin_unlock(PG_chainlock, (unsigned long *)&page->flags) struct pte_chain *pte_chain_alloc(int gfp_flags); void __pte_chain_free(struct pte_chain *pte_chain); _