Re: [patch 01/28] cpu alloc: The allocator

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Christoph Lameter
Date: Tuesday, November 13, 2007 - 3:20 pm

On Tue, 13 Nov 2007, David Miller wrote:


Other platforms do not have the 8MB restriction nor do they have so many 
processors.

Here is the draft of a virtual cpu area implementation for sparc64. Uses 
the VMEMMAP chunks:

---
 arch/sparc64/Kconfig          |   12 ++++++++++++
 arch/sparc64/mm/init.c        |   34 ++++++++++++++++++++++++++++++++++
 include/asm-sparc64/pgtable.h |    1 +
 3 files changed, 47 insertions(+)

Index: linux-2.6/arch/sparc64/mm/init.c
===================================================================
--- linux-2.6.orig/arch/sparc64/mm/init.c	2007-11-13 14:09:44.619500290 -0800
+++ linux-2.6/arch/sparc64/mm/init.c	2007-11-13 14:17:49.794860210 -0800
@@ -1697,6 +1697,40 @@ int __meminit vmemmap_populate(struct pa
 }
 #endif /* CONFIG_SPARSEMEM_VMEMMAP */
 
+int cpu_area_populate(void *start, unsigned long size, gfp_t flags, int node)
+{
+	unsigned long vstart = (unsigned long) start;
+	unsigned long vend = (unsigned long) (start + size);
+	unsigned long phys_start = (vstart - CPU_AREA_BASE);
+	unsigned long phys_end = (vend - CPU_AREA_BASE);
+	unsigned long addr = phys_start & VMEMMAP_CHUNK_MASK;
+	unsigned long end = VMEMMAP_ALIGN(phys_end);
+	unsigned long pte_base;
+
+	pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4U |
+		    _PAGE_CP_4U | _PAGE_CV_4U |
+		    _PAGE_P_4U | _PAGE_W_4U);
+	if (tlb_type == hypervisor)
+		pte_base = (_PAGE_VALID | _PAGE_SZ4MB_4V |
+			    _PAGE_CP_4V | _PAGE_CV_4V |
+			    _PAGE_P_4V | _PAGE_W_4V);
+
+	for (; addr < end; addr += VMEMMAP_CHUNK) {
+		unsigned long *vmem_pp =
+			vmemmap_table + (addr >> VMEMMAP_CHUNK_SHIFT);
+		void *block;
+
+		if (!(*vmem_pp & _PAGE_VALID)) {
+			block = vmemmap_alloc_block(1UL << 22, flags, node);
+			if (!block)
+				return -ENOMEM;
+
+			*vmem_pp = pte_base | __pa(block);
+		}
+	}
+	return 0;
+}
+
 static void prot_init_common(unsigned long page_none,
 			     unsigned long page_shared,
 			     unsigned long page_copy,
Index: linux-2.6/arch/sparc64/Kconfig
===================================================================
--- linux-2.6.orig/arch/sparc64/Kconfig	2007-11-13 14:12:28.895750307 -0800
+++ linux-2.6/arch/sparc64/Kconfig	2007-11-13 14:18:32.110750142 -0800
@@ -76,6 +76,18 @@ config GENERIC_HARDIRQS_NO__DO_IRQ
 	bool
 	def_bool y
 
+config CPU_AREA_VIRTUAL
+	bool
+	def_bool y
+
+config CPU_AREA_ORDER
+	int
+	default "10"
+
+config CPU_AREA_ALLOC_ORDER
+	int
+	default "0"
+
 choice
 	prompt "Kernel page size"
 	default SPARC64_PAGE_SIZE_8KB
Index: linux-2.6/include/asm-sparc64/pgtable.h
===================================================================
--- linux-2.6.orig/include/asm-sparc64/pgtable.h	2007-11-13 14:11:51.871000018 -0800
+++ linux-2.6/include/asm-sparc64/pgtable.h	2007-11-13 14:12:21.011750241 -0800
@@ -43,6 +43,7 @@
 #define VMALLOC_START		_AC(0x0000000100000000,UL)
 #define VMALLOC_END		_AC(0x0000000200000000,UL)
 #define VMEMMAP_BASE		_AC(0x0000000200000000,UL)
+#define CPU_AREA_BASE		_AC(0x0000000300000000,UL)
 
 #define vmemmap			((struct page *)VMEMMAP_BASE)
 
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 6, 12:51 pm)
Re: [patch 01/28] cpu alloc: The allocator, Peter Zijlstra, (Thu Nov 8, 5:34 am)
Re: [patch 01/28] cpu alloc: The allocator, Peter Zijlstra, (Thu Nov 8, 5:37 am)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 8, 11:33 am)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 8, 11:50 am)
Re: [patch 01/28] cpu alloc: The allocator, Peter Zijlstra, (Thu Nov 8, 1:19 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 4:15 am)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 2:40 pm)
Re: [patch 01/28] cpu alloc: The allocator, Eric Dumazet, (Tue Nov 13, 2:58 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 3:00 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 3:02 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 3:20 pm)
Re: [patch 01/28] cpu alloc: The allocator, Andi Kleen, (Tue Nov 13, 6:06 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 6:30 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 6:33 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 6:36 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 6:37 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 6:48 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 6:50 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 6:52 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 6:57 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 7:00 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 7:01 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 7:03 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 7:05 pm)
Re: [patch 01/28] cpu alloc: The allocator, Andi Kleen, (Tue Nov 13, 7:28 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 8:48 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 8:49 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 9:15 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 9:18 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 9:21 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Tue Nov 13, 9:26 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Tue Nov 13, 10:53 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 15, 11:49 am)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 15, 7:19 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Thu Nov 15, 7:50 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 15, 7:55 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 15, 8:10 pm)
Re: [patch 01/28] cpu alloc: The allocator, David Miller, (Thu Nov 15, 8:17 pm)
Re: [patch 01/28] cpu alloc: The allocator, Christoph Lameter, (Thu Nov 15, 8:19 pm)