Merge branches 'x86/numa-fixes', 'x86/apic', 'x86/apm', 'x86/bitops', 'x86/build...
[safe/jmp/linux-2.6] / arch / x86 / mm / pageattr.c
index 60bcb5b..afd4005 100644 (file)
@@ -34,6 +34,41 @@ struct cpa_data {
        unsigned        force_split : 1;
 };
 
+#ifdef CONFIG_PROC_FS
+static unsigned long direct_pages_count[PG_LEVEL_NUM];
+
+void update_page_count(int level, unsigned long pages)
+{
+       unsigned long flags;
+
+       /* Protect against CPA */
+       spin_lock_irqsave(&pgd_lock, flags);
+       direct_pages_count[level] += pages;
+       spin_unlock_irqrestore(&pgd_lock, flags);
+}
+
+static void split_page_count(int level)
+{
+       direct_pages_count[level]--;
+       direct_pages_count[level - 1] += PTRS_PER_PTE;
+}
+
+int arch_report_meminfo(char *page)
+{
+       int n = sprintf(page, "DirectMap4k:  %8lu\n"
+                       "DirectMap2M:  %8lu\n",
+                       direct_pages_count[PG_LEVEL_4K],
+                       direct_pages_count[PG_LEVEL_2M]);
+#ifdef CONFIG_X86_64
+       n += sprintf(page + n, "DirectMap1G:  %8lu\n",
+                    direct_pages_count[PG_LEVEL_1G]);
+#endif
+       return n;
+}
+#else
+static inline void split_page_count(int level) { }
+#endif
+
 #ifdef CONFIG_X86_64
 
 static inline unsigned long highmap_start_pfn(void)
@@ -500,6 +535,10 @@ static int split_large_page(pte_t *kpte, unsigned long address)
        for (i = 0; i < PTRS_PER_PTE; i++, pfn += pfninc)
                set_pte(&pbase[i], pfn_pte(pfn, ref_prot));
 
+       if (address >= (unsigned long)__va(0) &&
+               address < (unsigned long)__va(max_pfn_mapped << PAGE_SHIFT))
+               split_page_count(level);
+
        /*
         * Install the new, split up pagetable. Important details here:
         *
@@ -805,7 +844,7 @@ int _set_memory_wc(unsigned long addr, int numpages)
 
 int set_memory_wc(unsigned long addr, int numpages)
 {
-       if (!pat_wc_enabled)
+       if (!pat_enabled)
                return set_memory_uc(addr, numpages);
 
        if (reserve_memtype(addr, addr + numpages * PAGE_SIZE,