Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356204
b: refs/heads/master
c: 5c51bdb
h: refs/heads/master
v: v3
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Nov 17, 2012
1 parent eb758bf commit 980b974
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 868bf4d6b94c980d3ad87f892a5e528b8ee2c320
refs/heads/master: 5c51bdbe4c74dce7996d0bbfa39974775cc3f13c
34 changes: 34 additions & 0 deletions trunk/arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,44 @@
#include <asm/proto.h>
#include <asm/dma.h> /* for MAX_DMA_PFN */

#include "mm_internal.h"

unsigned long __initdata pgt_buf_start;
unsigned long __meminitdata pgt_buf_end;
unsigned long __meminitdata pgt_buf_top;

__ref void *alloc_low_page(void)
{
unsigned long pfn;
void *adr;

#ifdef CONFIG_X86_64
if (after_bootmem) {
adr = (void *)get_zeroed_page(GFP_ATOMIC | __GFP_NOTRACK);

return adr;
}
#endif

if ((pgt_buf_end + 1) >= pgt_buf_top) {
unsigned long ret;
if (min_pfn_mapped >= max_pfn_mapped)
panic("alloc_low_page: ran out of memory");
ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
max_pfn_mapped << PAGE_SHIFT,
PAGE_SIZE, PAGE_SIZE);
if (!ret)
panic("alloc_low_page: can not alloc memory");
memblock_reserve(ret, PAGE_SIZE);
pfn = ret >> PAGE_SHIFT;
} else
pfn = pgt_buf_end++;

adr = __va(pfn * PAGE_SIZE);
clear_page(adr);
return adr;
}

/* need 4 4k for initial PMD_SIZE, 4k for 0-ISA_END_ADDRESS */
#define INIT_PGT_BUF_SIZE (5 * PAGE_SIZE)
RESERVE_BRK(early_pgt_alloc, INIT_PGT_BUF_SIZE);
Expand Down
26 changes: 2 additions & 24 deletions trunk/arch/x86/mm/init_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,36 +53,14 @@
#include <asm/page_types.h>
#include <asm/init.h>

#include "mm_internal.h"

unsigned long highstart_pfn, highend_pfn;

static noinline int do_test_wp_bit(void);

bool __read_mostly __vmalloc_start_set = false;

static __init void *alloc_low_page(void)
{
unsigned long pfn;
void *adr;

if ((pgt_buf_end + 1) >= pgt_buf_top) {
unsigned long ret;
if (min_pfn_mapped >= max_pfn_mapped)
panic("alloc_low_page: ran out of memory");
ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
max_pfn_mapped << PAGE_SHIFT,
PAGE_SIZE, PAGE_SIZE);
if (!ret)
panic("alloc_low_page: can not alloc memory");
memblock_reserve(ret, PAGE_SIZE);
pfn = ret >> PAGE_SHIFT;
} else
pfn = pgt_buf_end++;

adr = __va(pfn * PAGE_SIZE);
clear_page(adr);
return adr;
}

/*
* Creates a middle page table and puts a pointer to it in the
* given global directory entry. This only returns the gd entry
Expand Down
32 changes: 2 additions & 30 deletions trunk/arch/x86/mm/init_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
#include <asm/uv/uv.h>
#include <asm/setup.h>

#include "mm_internal.h"

static int __init parse_direct_gbpages_off(char *arg)
{
direct_gbpages = 0;
Expand Down Expand Up @@ -314,36 +316,6 @@ void __init cleanup_highmap(void)
}
}

static __ref void *alloc_low_page(void)
{
unsigned long pfn;
void *adr;

if (after_bootmem) {
adr = (void *)get_zeroed_page(GFP_ATOMIC | __GFP_NOTRACK);

return adr;
}

if ((pgt_buf_end + 1) >= pgt_buf_top) {
unsigned long ret;
if (min_pfn_mapped >= max_pfn_mapped)
panic("alloc_low_page: ran out of memory");
ret = memblock_find_in_range(min_pfn_mapped << PAGE_SHIFT,
max_pfn_mapped << PAGE_SHIFT,
PAGE_SIZE, PAGE_SIZE);
if (!ret)
panic("alloc_low_page: can not alloc memory");
memblock_reserve(ret, PAGE_SIZE);
pfn = ret >> PAGE_SHIFT;
} else
pfn = pgt_buf_end++;

adr = __va(pfn * PAGE_SIZE);
clear_page(adr);
return adr;
}

static unsigned long __meminit
phys_pte_init(pte_t *pte_page, unsigned long addr, unsigned long end,
pgprot_t prot)
Expand Down
6 changes: 6 additions & 0 deletions trunk/arch/x86/mm/mm_internal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __X86_MM_INTERNAL_H
#define __X86_MM_INTERNAL_H

void *alloc_low_page(void);

#endif /* __X86_MM_INTERNAL_H */

0 comments on commit 980b974

Please sign in to comment.