Skip to content

Commit 2b97690

Browse files
Matt TolentinoLinus Torvalds
authored andcommitted
[PATCH] reorganize x86-64 NUMA and DISCONTIGMEM config options
In order to use the alternative sparsemem implmentation for NUMA kernels, we need to reorganize the config options. This patch effectively abstracts out the CONFIG_DISCONTIGMEM options to CONFIG_NUMA in most cases. Thus, the discontigmem implementation may be employed as always, but the sparsemem implementation may be used alternatively. Signed-off-by: Matt Tolentino <matthew.e.tolentino@intel.com> Signed-off-by: Dave Hansen <haveblue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 1035faf commit 2b97690

9 files changed

Lines changed: 25 additions & 24 deletions

File tree

‎arch/x86_64/kernel/head64.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void __init x86_64_start_kernel(char * real_mode_data)
9494
s = strstr(saved_command_line, "earlyprintk=");
9595
if (s != NULL)
9696
setup_early_printk(s);
97-
#ifdef CONFIG_DISCONTIGMEM
97+
#ifdef CONFIG_NUMA
9898
s = strstr(saved_command_line, "numa=");
9999
if (s != NULL)
100100
numa_setup(s+5);

‎arch/x86_64/kernel/setup.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
348348
if (!memcmp(from, "mem=", 4))
349349
parse_memopt(from+4, &from);
350350

351-
#ifdef CONFIG_DISCONTIGMEM
351+
#ifdef CONFIG_NUMA
352352
if (!memcmp(from, "numa=", 5))
353353
numa_setup(from+5);
354354
#endif
@@ -377,7 +377,7 @@ static __init void parse_cmdline_early (char ** cmdline_p)
377377
*cmdline_p = command_line;
378378
}
379379

380-
#ifndef CONFIG_DISCONTIGMEM
380+
#ifndef CONFIG_NUMA
381381
static void __init contig_initmem_init(void)
382382
{
383383
unsigned long bootmap_size, bootmap;
@@ -554,7 +554,7 @@ void __init setup_arch(char **cmdline_p)
554554
acpi_numa_init();
555555
#endif
556556

557-
#ifdef CONFIG_DISCONTIGMEM
557+
#ifdef CONFIG_NUMA
558558
numa_initmem_init(0, end_pfn);
559559
#else
560560
contig_initmem_init();

‎arch/x86_64/mm/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
obj-y := init.o fault.o ioremap.o extable.o pageattr.o
66
obj-$(CONFIG_HUGETLB_PAGE) += hugetlbpage.o
7-
obj-$(CONFIG_DISCONTIGMEM) += numa.o
7+
obj-$(CONFIG_NUMA) += numa.o
88
obj-$(CONFIG_K8_NUMA) += k8topology.o
99
obj-$(CONFIG_ACPI_NUMA) += srat.o
1010

‎arch/x86_64/mm/init.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void zap_low_mappings(void)
318318
flush_tlb_all();
319319
}
320320

321-
#ifndef CONFIG_DISCONTIGMEM
321+
#ifndef CONFIG_NUMA
322322
void __init paging_init(void)
323323
{
324324
{
@@ -427,13 +427,16 @@ void __init mem_init(void)
427427
reservedpages = 0;
428428

429429
/* this will put all low memory onto the freelists */
430-
#ifdef CONFIG_DISCONTIGMEM
430+
#ifdef CONFIG_NUMA
431431
totalram_pages += numa_free_all_bootmem();
432432
tmp = 0;
433433
/* should count reserved pages here for all nodes */
434434
#else
435+
436+
#ifdef CONFIG_FLATMEM
435437
max_mapnr = end_pfn;
436438
if (!mem_map) BUG();
439+
#endif
437440

438441
totalram_pages += free_all_bootmem();
439442

@@ -515,7 +518,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
515518
void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
516519
{
517520
/* Should check here against the e820 map to avoid double free */
518-
#ifdef CONFIG_DISCONTIGMEM
521+
#ifdef CONFIG_NUMA
519522
int nid = phys_to_nid(phys);
520523
reserve_bootmem_node(NODE_DATA(nid), phys, len);
521524
#else

‎arch/x86_64/mm/ioremap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
178178
if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
179179
return (__force void __iomem *)phys_to_virt(phys_addr);
180180

181-
#ifndef CONFIG_DISCONTIGMEM
181+
#ifdef CONFIG_FLATMEM
182182
/*
183183
* Don't allow anybody to remap normal RAM that we're using..
184184
*/

‎include/asm-x86_64/io.h‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ extern inline void * phys_to_virt(unsigned long address)
124124
/*
125125
* Change "struct page" to physical address.
126126
*/
127-
#ifdef CONFIG_DISCONTIGMEM
128-
#include <asm/mmzone.h>
129127
#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
130-
#else
131-
#define page_to_phys(page) ((page - mem_map) << PAGE_SHIFT)
132-
#endif
133128

134129
#include <asm-generic/iomap.h>
135130

‎include/asm-x86_64/mmzone.h‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <linux/config.h>
88

9-
#ifdef CONFIG_DISCONTIGMEM
9+
#ifdef CONFIG_NUMA
1010

1111
#define VIRTUAL_BUG_ON(x)
1212

@@ -30,17 +30,16 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
3030
return nid;
3131
}
3232

33-
#define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
34-
35-
#define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
3633
#define NODE_DATA(nid) (node_data[nid])
3734

3835
#define node_start_pfn(nid) (NODE_DATA(nid)->node_start_pfn)
3936
#define node_end_pfn(nid) (NODE_DATA(nid)->node_start_pfn + \
4037
NODE_DATA(nid)->node_spanned_pages)
4138

42-
#define local_mapnr(kvaddr) \
43-
( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) )
39+
#ifdef CONFIG_DISCONTIGMEM
40+
41+
#define pfn_to_nid(pfn) phys_to_nid((unsigned long)(pfn) << PAGE_SHIFT)
42+
#define kvaddr_to_nid(kaddr) phys_to_nid(__pa(kaddr))
4443

4544
/* AK: this currently doesn't deal with invalid addresses. We'll see
4645
if the 2.5 kernel doesn't pass them
@@ -57,4 +56,8 @@ static inline __attribute__((pure)) int phys_to_nid(unsigned long addr)
5756
({ u8 nid__ = pfn_to_nid(pfn); \
5857
nid__ != 0xff && (pfn) >= node_start_pfn(nid__) && (pfn) <= node_end_pfn(nid__); }))
5958
#endif
59+
60+
#define local_mapnr(kvaddr) \
61+
( (__pa(kvaddr) >> PAGE_SHIFT) - node_start_pfn(kvaddr_to_nid(kvaddr)) )
62+
#endif
6063
#endif

‎include/asm-x86_64/page.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ extern __inline__ int get_order(unsigned long size)
119119
__pa(v); })
120120

121121
#define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
122-
#ifndef CONFIG_DISCONTIGMEM
122+
#define __boot_va(x) __va(x)
123+
#define __boot_pa(x) __pa(x)
124+
#ifdef CONFIG_FLATMEM
123125
#define pfn_to_page(pfn) (mem_map + (pfn))
124126
#define page_to_pfn(page) ((unsigned long)((page) - mem_map))
125127
#define pfn_valid(pfn) ((pfn) < max_mapnr)

‎include/asm-x86_64/topology.h‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
#include <linux/config.h>
55

6-
#ifdef CONFIG_DISCONTIGMEM
6+
#ifdef CONFIG_NUMA
77

88
#include <asm/mpspec.h>
99
#include <asm/bitops.h>
@@ -37,7 +37,6 @@ static inline cpumask_t __pcibus_to_cpumask(int bus)
3737
}
3838
#define pcibus_to_cpumask(bus) __pcibus_to_cpumask(bus->number)
3939

40-
#ifdef CONFIG_NUMA
4140
/* sched_domains SD_NODE_INIT for x86_64 machines */
4241
#define SD_NODE_INIT (struct sched_domain) { \
4342
.span = CPU_MASK_NONE, \
@@ -59,7 +58,6 @@ static inline cpumask_t __pcibus_to_cpumask(int bus)
5958
.balance_interval = 1, \
6059
.nr_balance_failed = 0, \
6160
}
62-
#endif
6361

6462
#endif
6563

0 commit comments

Comments
 (0)