OSDN Git Service

mm: fix crash when using XFS on loopback
[uclinux-h8/linux.git] / mm / util.c
index eaf63fc..808f375 100644 (file)
--- a/mm/util.c
+++ b/mm/util.c
@@ -7,6 +7,9 @@
 #include <linux/security.h>
 #include <linux/swap.h>
 #include <linux/swapops.h>
+#include <linux/mman.h>
+#include <linux/hugetlb.h>
+
 #include <asm/uaccess.h>
 
 #include "internal.h"
@@ -387,7 +390,10 @@ struct address_space *page_mapping(struct page *page)
 {
        struct address_space *mapping = page->mapping;
 
-       VM_BUG_ON(PageSlab(page));
+       /* This happens if someone calls flush_dcache_page on slab page */
+       if (unlikely(PageSlab(page)))
+               return NULL;
+
        if (unlikely(PageSwapCache(page))) {
                swp_entry_t entry;
 
@@ -398,6 +404,16 @@ struct address_space *page_mapping(struct page *page)
        return mapping;
 }
 
+/*
+ * Committed memory limit enforced when OVERCOMMIT_NEVER policy is used
+ */
+unsigned long vm_commit_limit(void)
+{
+       return ((totalram_pages - hugetlb_total_pages())
+               * sysctl_overcommit_ratio / 100) + total_swap_pages;
+}
+
+
 /* Tracepoints definitions. */
 EXPORT_TRACEPOINT_SYMBOL(kmalloc);
 EXPORT_TRACEPOINT_SYMBOL(kmem_cache_alloc);