1 #include <linux/sched.h>
2 #include <linux/kernel.h>
3 #include <linux/errno.h>
6 #include <linux/swap.h>
8 #include <linux/highmem.h>
9 #include <linux/slab.h>
10 #include <linux/pagemap.h>
11 #include <linux/spinlock.h>
12 #include <linux/module.h>
13 #include <linux/quicklist.h>
15 #include <asm/system.h>
16 #include <asm/pgtable.h>
17 #include <asm/pgalloc.h>
18 #include <asm/fixmap.h>
21 #include <asm/tlbflush.h>
25 int total = 0, reserved = 0;
26 int shared = 0, cached = 0;
33 printk(KERN_INFO "Mem-info:\n");
35 for_each_online_pgdat(pgdat) {
36 pgdat_resize_lock(pgdat, &flags);
37 for (i = 0; i < pgdat->node_spanned_pages; ++i) {
38 if (unlikely(i % MAX_ORDER_NR_PAGES == 0))
40 page = pgdat_page_nr(pgdat, i);
42 if (PageHighMem(page))
44 if (PageReserved(page))
46 else if (PageSwapCache(page))
48 else if (page_count(page))
49 shared += page_count(page) - 1;
51 pgdat_resize_unlock(pgdat, &flags);
53 printk(KERN_INFO "%d pages of RAM\n", total);
54 printk(KERN_INFO "%d pages of HIGHMEM\n", highmem);
55 printk(KERN_INFO "%d reserved pages\n", reserved);
56 printk(KERN_INFO "%d pages shared\n", shared);
57 printk(KERN_INFO "%d pages swap cached\n", cached);
59 printk(KERN_INFO "%lu pages dirty\n", global_page_state(NR_FILE_DIRTY));
60 printk(KERN_INFO "%lu pages writeback\n",
61 global_page_state(NR_WRITEBACK));
62 printk(KERN_INFO "%lu pages mapped\n", global_page_state(NR_FILE_MAPPED));
63 printk(KERN_INFO "%lu pages slab\n",
64 global_page_state(NR_SLAB_RECLAIMABLE) +
65 global_page_state(NR_SLAB_UNRECLAIMABLE));
66 printk(KERN_INFO "%lu pages pagetables\n",
67 global_page_state(NR_PAGETABLE));
71 * Associate a virtual page frame with a given physical page frame
72 * and protection flags for that frame.
74 void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
81 pgd = swapper_pg_dir + pgd_index(vaddr);
86 pud = pud_offset(pgd, vaddr);
91 pmd = pmd_offset(pud, vaddr);
96 pte = pte_offset_kernel(pmd, vaddr);
98 set_pte_present(&init_mm, vaddr, pte, pteval);
100 pte_clear(&init_mm, vaddr, pte);
103 * It's enough to flush this one mapping.
104 * (PGE mappings get flushed as well)
106 __flush_tlb_one(vaddr);
110 * Associate a large virtual page frame with a given physical page frame
111 * and protection flags for that frame. pfn is for the base of the page,
112 * vaddr is what the page gets mapped to - both must be properly aligned.
113 * The pmd must already be instantiated. Assumes PAE mode.
115 void set_pmd_pfn(unsigned long vaddr, unsigned long pfn, pgprot_t flags)
121 if (vaddr & (PMD_SIZE-1)) { /* vaddr is misaligned */
122 printk(KERN_WARNING "set_pmd_pfn: vaddr misaligned\n");
125 if (pfn & (PTRS_PER_PTE-1)) { /* pfn is misaligned */
126 printk(KERN_WARNING "set_pmd_pfn: pfn misaligned\n");
129 pgd = swapper_pg_dir + pgd_index(vaddr);
130 if (pgd_none(*pgd)) {
131 printk(KERN_WARNING "set_pmd_pfn: pgd_none\n");
134 pud = pud_offset(pgd, vaddr);
135 pmd = pmd_offset(pud, vaddr);
136 set_pmd(pmd, pfn_pmd(pfn, flags));
138 * It's enough to flush this one mapping.
139 * (PGE mappings get flushed as well)
141 __flush_tlb_one(vaddr);
144 unsigned long __FIXADDR_TOP = 0xfffff000;
145 EXPORT_SYMBOL(__FIXADDR_TOP);
148 * reserve_top_address - reserves a hole in the top of kernel address space
149 * @reserve - size of hole to reserve
151 * Can be used to relocate the fixmap area and poke a hole in the top
152 * of kernel address space to make room for a hypervisor.
154 void __init reserve_top_address(unsigned long reserve)
156 BUG_ON(fixmaps_set > 0);
157 printk(KERN_INFO "Reserving virtual address space above 0x%08x\n",
159 __FIXADDR_TOP = -reserve - PAGE_SIZE;
160 __VMALLOC_RESERVE += reserve;
164 * vmalloc=size forces the vmalloc area to be exactly 'size'
165 * bytes. This can be used to increase (or decrease) the
166 * vmalloc area - the default is 128m.
168 static int __init parse_vmalloc(char *arg)
173 __VMALLOC_RESERVE = memparse(arg, &arg);
176 early_param("vmalloc", parse_vmalloc);
179 * reservetop=size reserves a hole at the top of the kernel address space which
180 * a hypervisor can load into later. Needed for dynamically loaded hypervisors,
181 * so relocating the fixmap can be done before paging initialization.
183 static int __init parse_reservetop(char *arg)
185 unsigned long address;
190 address = memparse(arg, &arg);
191 reserve_top_address(address);
194 early_param("reservetop", parse_reservetop);