Skip to content

Commit df133e8

Browse files
committed
Merge branch 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 mm updates from Ingo Molnar: "This tree includes the following changes: - fix memory hotplug - fix hibernation bootup memory layout assumptions - fix hyperv numa guest kernel messages - remove dead code - update documentation" * 'x86-mm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/mm: Update memory map description to list hypervisor-reserved area x86/mm, hibernate: Do not assume the first e820 area to be RAM x86/mm/numa: Drop dead code and rename setup_node_data() to setup_alloc_data() x86/mm/hotplug: Modify PGD entry when removing memory x86/mm/hotplug: Pass sync_global_pgds() a correct argument in remove_pagetable() x86: Remove set_pmd_pfn
2 parents e343833 + beb9147 commit df133e8

10 files changed

Lines changed: 47 additions & 78 deletions

File tree

‎Documentation/x86/x86_64/mm.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Virtual memory map with 4 level page tables:
55

66
0000000000000000 - 00007fffffffffff (=47 bits) user space, different per mm
77
hole caused by [48:63] sign extension
8-
ffff800000000000 - ffff80ffffffffff (=40 bits) guard hole
8+
ffff800000000000 - ffff87ffffffffff (=43 bits) guard hole, reserved for hypervisor
99
ffff880000000000 - ffffc7ffffffffff (=64 TB) direct mapping of all phys. memory
1010
ffffc80000000000 - ffffc8ffffffffff (=40 bits) hole
1111
ffffc90000000000 - ffffe8ffffffffff (=45 bits) vmalloc/ioremap space

‎arch/x86/include/asm/numa.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifdef CONFIG_NUMA
1010

1111
#define NR_NODE_MEMBLKS (MAX_NUMNODES*2)
12-
#define ZONE_ALIGN (1UL << (MAX_ORDER+PAGE_SHIFT))
1312

1413
/*
1514
* Too small node sizes may confuse the VM badly. Usually they

‎arch/x86/include/asm/pgtable_32.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ static inline void pgtable_cache_init(void) { }
3232
static inline void check_pgt_cache(void) { }
3333
void paging_init(void);
3434

35-
extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
36-
37-
3835
/*
3936
* Define this if things work differently on an i386 and an i486:
4037
* it will (on an i486) warn about kernel memory accesses that are

‎arch/x86/include/asm/pgtable_64.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ static inline void native_pgd_clear(pgd_t *pgd)
116116
native_set_pgd(pgd, native_make_pgd(0));
117117
}
118118

119-
extern void sync_global_pgds(unsigned long start, unsigned long end);
119+
extern void sync_global_pgds(unsigned long start, unsigned long end,
120+
int removed);
120121

121122
/*
122123
* Conversion functions: convert a page and protection to a page entry,

‎arch/x86/kernel/e820.c‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -682,15 +682,14 @@ void __init parse_e820_ext(u64 phys_addr, u32 data_len)
682682
* hibernation (32 bit) or software suspend and suspend to RAM (64 bit).
683683
*
684684
* This function requires the e820 map to be sorted and without any
685-
* overlapping entries and assumes the first e820 area to be RAM.
685+
* overlapping entries.
686686
*/
687687
void __init e820_mark_nosave_regions(unsigned long limit_pfn)
688688
{
689689
int i;
690-
unsigned long pfn;
690+
unsigned long pfn = 0;
691691

692-
pfn = PFN_DOWN(e820.map[0].addr + e820.map[0].size);
693-
for (i = 1; i < e820.nr_map; i++) {
692+
for (i = 0; i < e820.nr_map; i++) {
694693
struct e820entry *ei = &e820.map[i];
695694

696695
if (pfn < PFN_UP(ei->addr))

‎arch/x86/mm/fault.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static void dump_pagetable(unsigned long address)
349349

350350
void vmalloc_sync_all(void)
351351
{
352-
sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END);
352+
sync_global_pgds(VMALLOC_START & PGDIR_MASK, VMALLOC_END, 0);
353353
}
354354

355355
/*

‎arch/x86/mm/init_64.c‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,20 @@ __setup("noexec32=", nonx32_setup);
178178
* When memory was added/removed make sure all the processes MM have
179179
* suitable PGD entries in the local PGD level page.
180180
*/
181-
void sync_global_pgds(unsigned long start, unsigned long end)
181+
void sync_global_pgds(unsigned long start, unsigned long end, int removed)
182182
{
183183
unsigned long address;
184184

185185
for (address = start; address <= end; address += PGDIR_SIZE) {
186186
const pgd_t *pgd_ref = pgd_offset_k(address);
187187
struct page *page;
188188

189-
if (pgd_none(*pgd_ref))
189+
/*
190+
* When it is called after memory hot remove, pgd_none()
191+
* returns true. In this case (removed == 1), we must clear
192+
* the PGD entries in the local PGD level page.
193+
*/
194+
if (pgd_none(*pgd_ref) && !removed)
190195
continue;
191196

192197
spin_lock(&pgd_lock);
@@ -199,12 +204,18 @@ void sync_global_pgds(unsigned long start, unsigned long end)
199204
pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
200205
spin_lock(pgt_lock);
201206

202-
if (pgd_none(*pgd))
203-
set_pgd(pgd, *pgd_ref);
204-
else
207+
if (!pgd_none(*pgd_ref) && !pgd_none(*pgd))
205208
BUG_ON(pgd_page_vaddr(*pgd)
206209
!= pgd_page_vaddr(*pgd_ref));
207210

211+
if (removed) {
212+
if (pgd_none(*pgd_ref) && !pgd_none(*pgd))
213+
pgd_clear(pgd);
214+
} else {
215+
if (pgd_none(*pgd))
216+
set_pgd(pgd, *pgd_ref);
217+
}
218+
208219
spin_unlock(pgt_lock);
209220
}
210221
spin_unlock(&pgd_lock);
@@ -633,7 +644,7 @@ kernel_physical_mapping_init(unsigned long start,
633644
}
634645

635646
if (pgd_changed)
636-
sync_global_pgds(addr, end - 1);
647+
sync_global_pgds(addr, end - 1, 0);
637648

638649
__flush_tlb_all();
639650

@@ -976,25 +987,26 @@ static void __meminit
976987
remove_pagetable(unsigned long start, unsigned long end, bool direct)
977988
{
978989
unsigned long next;
990+
unsigned long addr;
979991
pgd_t *pgd;
980992
pud_t *pud;
981993
bool pgd_changed = false;
982994

983-
for (; start < end; start = next) {
984-
next = pgd_addr_end(start, end);
995+
for (addr = start; addr < end; addr = next) {
996+
next = pgd_addr_end(addr, end);
985997

986-
pgd = pgd_offset_k(start);
998+
pgd = pgd_offset_k(addr);
987999
if (!pgd_present(*pgd))
9881000
continue;
9891001

9901002
pud = (pud_t *)pgd_page_vaddr(*pgd);
991-
remove_pud_table(pud, start, next, direct);
1003+
remove_pud_table(pud, addr, next, direct);
9921004
if (free_pud_table(pud, pgd))
9931005
pgd_changed = true;
9941006
}
9951007

9961008
if (pgd_changed)
997-
sync_global_pgds(start, end - 1);
1009+
sync_global_pgds(start, end - 1, 1);
9981010

9991011
flush_tlb_all();
10001012
}
@@ -1341,7 +1353,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node)
13411353
else
13421354
err = vmemmap_populate_basepages(start, end, node);
13431355
if (!err)
1344-
sync_global_pgds(start, end - 1);
1356+
sync_global_pgds(start, end - 1, 0);
13451357
return err;
13461358
}
13471359

‎arch/x86/mm/numa.c‎

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -185,26 +185,14 @@ int __init numa_add_memblk(int nid, u64 start, u64 end)
185185
return numa_add_memblk_to(nid, start, end, &numa_meminfo);
186186
}
187187

188-
/* Initialize NODE_DATA for a node on the local memory */
189-
static void __init setup_node_data(int nid, u64 start, u64 end)
188+
/* Allocate NODE_DATA for a node on the local memory */
189+
static void __init alloc_node_data(int nid)
190190
{
191191
const size_t nd_size = roundup(sizeof(pg_data_t), PAGE_SIZE);
192192
u64 nd_pa;
193193
void *nd;
194194
int tnid;
195195

196-
/*
197-
* Don't confuse VM with a node that doesn't have the
198-
* minimum amount of memory:
199-
*/
200-
if (end && (end - start) < NODE_MIN_SIZE)
201-
return;
202-
203-
start = roundup(start, ZONE_ALIGN);
204-
205-
printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n",
206-
nid, start, end - 1);
207-
208196
/*
209197
* Allocate node data. Try node-local memory and then any node.
210198
* Never allocate in DMA zone.
@@ -222,17 +210,14 @@ static void __init setup_node_data(int nid, u64 start, u64 end)
222210
nd = __va(nd_pa);
223211

224212
/* report and initialize */
225-
printk(KERN_INFO " NODE_DATA [mem %#010Lx-%#010Lx]\n",
213+
printk(KERN_INFO "NODE_DATA(%d) allocated [mem %#010Lx-%#010Lx]\n", nid,
226214
nd_pa, nd_pa + nd_size - 1);
227215
tnid = early_pfn_to_nid(nd_pa >> PAGE_SHIFT);
228216
if (tnid != nid)
229217
printk(KERN_INFO " NODE_DATA(%d) on node %d\n", nid, tnid);
230218

231219
node_data[nid] = nd;
232220
memset(NODE_DATA(nid), 0, sizeof(pg_data_t));
233-
NODE_DATA(nid)->node_id = nid;
234-
NODE_DATA(nid)->node_start_pfn = start >> PAGE_SHIFT;
235-
NODE_DATA(nid)->node_spanned_pages = (end - start) >> PAGE_SHIFT;
236221

237222
node_set_online(nid);
238223
}
@@ -523,8 +508,17 @@ static int __init numa_register_memblks(struct numa_meminfo *mi)
523508
end = max(mi->blk[i].end, end);
524509
}
525510

526-
if (start < end)
527-
setup_node_data(nid, start, end);
511+
if (start >= end)
512+
continue;
513+
514+
/*
515+
* Don't confuse VM with a node that doesn't have the
516+
* minimum amount of memory:
517+
*/
518+
if (end && (end - start) < NODE_MIN_SIZE)
519+
continue;
520+
521+
alloc_node_data(nid);
528522
}
529523

530524
/* Dump memblock with node info and return. */

‎arch/x86/mm/pgtable_32.c‎

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -59,41 +59,6 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
5959
__flush_tlb_one(vaddr);
6060
}
6161

62-
/*
63-
* Associate a large virtual page frame with a given physical page frame
64-
* and protection flags for that frame. pfn is for the base of the page,
65-
* vaddr is what the page gets mapped to - both must be properly aligned.
66-
* The pmd must already be instantiated. Assumes PAE mode.
67-
*/
68-
void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
69-
{
70-
pgd_t *pgd;
71-
pud_t *pud;
72-
pmd_t *pmd;
73-
74-
if (vaddr & (PMD_SIZE-1)) { /* vaddr is misaligned */
75-
printk(KERN_WARNING "set_pmd_pfn: vaddr misaligned\n");
76-
return; /* BUG(); */
77-
}
78-
if (pfn & (PTRS_PER_PTE-1)) { /* pfn is misaligned */
79-
printk(KERN_WARNING "set_pmd_pfn: pfn misaligned\n");
80-
return; /* BUG(); */
81-
}
82-
pgd = swapper_pg_dir + pgd_index(vaddr);
83-
if (pgd_none(*pgd)) {
84-
printk(KERN_WARNING "set_pmd_pfn: pgd_none\n");
85-
return; /* BUG(); */
86-
}
87-
pud = pud_offset(pgd, vaddr);
88-
pmd = pmd_offset(pud, vaddr);
89-
set_pmd(pmd, pfn_pmd(pfn, flags));
90-
/*
91-
* It's enough to flush this one mapping.
92-
* (PGE mappings get flushed as well)
93-
*/
94-
__flush_tlb_one(vaddr);
95-
}
96-
9762
unsigned long __FIXADDR_TOP = 0xfffff000;
9863
EXPORT_SYMBOL(__FIXADDR_TOP);
9964

‎mm/page_alloc.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4971,6 +4971,8 @@ void __paginginit free_area_init_node(int nid, unsigned long *zones_size,
49714971
pgdat->node_start_pfn = node_start_pfn;
49724972
#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
49734973
get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
4974+
printk(KERN_INFO "Initmem setup node %d [mem %#010Lx-%#010Lx]\n", nid,
4975+
(u64) start_pfn << PAGE_SHIFT, (u64) (end_pfn << PAGE_SHIFT) - 1);
49744976
#endif
49754977
calculate_node_totalpages(pgdat, start_pfn, end_pfn,
49764978
zones_size, zholes_size);

0 commit comments

Comments
 (0)