linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [rfc] increase struct page size?!
@ 2007-05-18  4:08 Nick Piggin
  2007-05-18  4:47 ` David Miller, Nick Piggin
                   ` (6 more replies)
  0 siblings, 7 replies; 54+ messages in thread
From: Nick Piggin @ 2007-05-18  4:08 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Linux Memory Management List, linux-arch

Hi,

I'd like to be the first to propose an increase to the size of struct page
just for the sake of increasing it!

If we add 8 bytes to struct page on 64-bit machines, it becomes 64 bytes,
which is quite a nice number for cache purposes.

However we don't have to let those 8 bytes go to waste: we can use them
to store the virtual address of the page, which kind of makes sense for
64-bit, because they can likely to use complicated memory models.

I'd say all up this is going to decrease overall cache footprint in 
fastpaths, both by reducing text and data footprint of page_address and
related operations, and by reducing cacheline footprint of most batched
operations on struct pages.

Flame away :)

--

Many batch operations on struct page are completely random, and as such, I
think it is better if each struct page fits completely into a single
cacheline even if it means being slightly larger.

Don't let this space go to waste though, we can use page->virtual in order
to optimise page_address operations.

Interestingly, the irony of 32-bit architectures setting WANT_PAGE_VIRTUAL
because they have slow multiplications is that without WANT_PAGE_VIRTUAL, the
struct is 32-bytes and so page_address can usually be calculated with a shift.
So WANT_PAGE_VIRTUAL just bloats up the size of struct page for those guys!


Index: linux-2.6/include/linux/mm_types.h
===================================================================
--- linux-2.6.orig/include/linux/mm_types.h
+++ linux-2.6/include/linux/mm_types.h
@@ -9,6 +9,14 @@
 struct address_space;
 
 /*
+ * WANT_PAGE_VIRTUAL on 64-bit machines gives a nice 64 byte alignment,
+ * so a struct page will fit entirely into a cacheline on modern CPUs.
+ */
+#if BITS_PER_LONG == 64
+# define WANT_PAGE_VIRTUAL
+#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
  * moment. Note that we have no way to track which tasks are using
Index: linux-2.6/include/linux/bootmem.h
===================================================================
--- linux-2.6.orig/include/linux/bootmem.h
+++ linux-2.6/include/linux/bootmem.h
@@ -91,7 +91,7 @@ extern void free_bootmem_node(pg_data_t 
 
 #ifndef CONFIG_HAVE_ARCH_BOOTMEM_NODE
 #define alloc_bootmem_node(pgdat, x) \
-	__alloc_bootmem_node(pgdat, x, SMP_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
+	__alloc_bootmem_node(pgdat, x, L1_CACHE_BYTES, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_pages_node(pgdat, x) \
 	__alloc_bootmem_node(pgdat, x, PAGE_SIZE, __pa(MAX_DMA_ADDRESS))
 #define alloc_bootmem_low_pages_node(pgdat, x) \
Index: linux-2.6/mm/page_alloc.c
===================================================================
--- linux-2.6.orig/mm/page_alloc.c
+++ linux-2.6/mm/page_alloc.c
@@ -2717,6 +2717,9 @@ static void __meminit alloc_node_mem_map
 	}
 #endif
 #endif /* CONFIG_FLAT_NODE_MEM_MAP */
+
+	if ((unsigned long)pgdat->node_mem_map & (L1_CACHE_BYTES - 1))
+		printk(KERN_WARNING "node_mem_map is not cacheline aligned!\n");
 }
 
 void __meminit free_area_init_node(int nid, struct pglist_data *pgdat,

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 54+ messages in thread

end of thread, other threads:[~2007-05-22 10:59 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-18  4:08 [rfc] increase struct page size?! Nick Piggin
2007-05-18  4:47 ` David Miller, Nick Piggin
2007-05-18  5:12   ` Nick Piggin
2007-05-18  5:22     ` David Miller, Nick Piggin
2007-05-18  5:31       ` Nick Piggin
2007-05-18 18:15     ` Christoph Lameter
2007-05-18  7:19 ` Andrew Morton
2007-05-18  7:32   ` Nick Piggin
2007-05-18  7:43     ` Andrew Morton
2007-05-18  7:59       ` Nick Piggin
2007-05-18  9:42 ` David Howells
2007-05-19  1:30   ` Nick Piggin
2007-05-18 12:06 ` Andi Kleen
2007-05-18 15:42 ` Hugh Dickins
2007-05-19  1:22   ` Nick Piggin
2007-05-19 17:53   ` William Lee Irwin III
2007-05-20 22:50     ` Matthew Wilcox
2007-05-18 18:14 ` Christoph Lameter
2007-05-18 20:37   ` Luck, Tony
2007-05-21  6:28     ` KAMEZAWA Hiroyuki
2007-05-19  1:25   ` Nick Piggin
2007-05-19  2:03     ` [rfc] increase struct page size?! (now sparsemem vmemmap) Christoph Lameter
2007-05-19 15:43       ` Andy Whitcroft
2007-05-19 18:15     ` [rfc] increase struct page size?! William Lee Irwin III
2007-05-19 18:25       ` Christoph Lameter
2007-05-20  4:10         ` Eric Dumazet
2007-05-20 12:56           ` Andi Kleen
2007-05-21 17:08             ` Christoph Lameter
2007-05-22  0:30               ` KAMEZAWA Hiroyuki
2007-05-22  0:38                 ` Christoph Lameter
2007-05-22  0:58                   ` KAMEZAWA Hiroyuki
2007-05-22  9:44                   ` Geert Uytterhoeven
2007-05-19 22:09       ` Andrew Morton
2007-05-20  7:26         ` William Lee Irwin III
2007-05-21  9:12         ` Helge Hafting
2007-05-21  9:45           ` Nick Piggin
2007-05-20  5:22       ` Nick Piggin
2007-05-20  8:46         ` William Lee Irwin III
2007-05-20  9:25           ` Nick Piggin
2007-05-21  8:08             ` William Lee Irwin III
2007-05-21  9:27               ` Nick Piggin
2007-05-21 11:26                 ` William Lee Irwin III
2007-05-22  0:52                   ` Nick Piggin
2007-05-21 22:43                 ` Matt Mackall
2007-05-22  1:08                   ` Nick Piggin
2007-05-22  1:13                     ` Christoph Lameter
2007-05-22  1:39                   ` William Lee Irwin III
2007-05-22  1:57                     ` Nick Piggin
2007-05-22  5:04                       ` William Lee Irwin III
2007-05-22  6:24                         ` Nick Piggin
2007-05-22 10:59                           ` William Lee Irwin III
2007-05-21  9:31               ` Eric Dumazet
2007-05-21 17:06             ` Christoph Lameter
2007-05-20 17:13 ` Andrea Arcangeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox