]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - mm/page_alloc.c
fs/stat.c: remove unnecessary new_valid_dev() check
[karo-tx-linux.git] / mm / page_alloc.c
index ac4ddef63771433ca4fda536aba767e385dcd12a..d0499fff8c7fb1ee2f33a34bd9e424420939a654 100644 (file)
@@ -229,13 +229,15 @@ static char * const zone_names[MAX_NR_ZONES] = {
 #endif
 };
 
-static void free_compound_page(struct page *page);
 compound_page_dtor * const compound_page_dtors[] = {
        NULL,
        free_compound_page,
 #ifdef CONFIG_HUGETLB_PAGE
        free_huge_page,
 #endif
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+       free_transhuge_page,
+#endif
 };
 
 int min_free_kbytes = 1024;
@@ -457,7 +459,7 @@ out:
  * This usage means that zero-order pages may not be compound.
  */
 
-static void free_compound_page(struct page *page)
+void free_compound_page(struct page *page)
 {
        __free_pages_ok(page, compound_order(page));
 }
@@ -476,6 +478,7 @@ void prep_compound_page(struct page *page, unsigned int order)
                p->mapping = TAIL_MAPPING;
                set_compound_head(p, page);
        }
+       atomic_set(compound_mapcount_ptr(page), -1);
 }
 
 #ifdef CONFIG_DEBUG_PAGEALLOC
@@ -740,7 +743,7 @@ static inline int free_pages_check(struct page *page)
        const char *bad_reason = NULL;
        unsigned long bad_flags = 0;
 
-       if (unlikely(page_mapcount(page)))
+       if (unlikely(atomic_read(&page->_mapcount) != -1))
                bad_reason = "nonzero mapcount";
        if (unlikely(page->mapping != NULL))
                bad_reason = "non-NULL mapping";
@@ -864,9 +867,26 @@ static int free_tail_pages_check(struct page *head_page, struct page *page)
                ret = 0;
                goto out;
        }
-       if (page->mapping != TAIL_MAPPING) {
-               bad_page(page, "corrupted mapping in tail page", 0);
-               goto out;
+       switch (page - head_page) {
+       case 1:
+               /* the first tail page: ->mapping is compound_mapcount() */
+               if (unlikely(compound_mapcount(page))) {
+                       bad_page(page, "nonzero compound_mapcount", 0);
+                       goto out;
+               }
+               break;
+       case 2:
+               /*
+                * the second tail page: ->mapping is
+                * page_deferred_list().next -- ignore value.
+                */
+               break;
+       default:
+               if (page->mapping != TAIL_MAPPING) {
+                       bad_page(page, "corrupted mapping in tail page", 0);
+                       goto out;
+               }
+               break;
        }
        if (unlikely(!PageTail(page))) {
                bad_page(page, "PageTail not set", 0);
@@ -1342,7 +1362,7 @@ static inline int check_new_page(struct page *page)
        const char *bad_reason = NULL;
        unsigned long bad_flags = 0;
 
-       if (unlikely(page_mapcount(page)))
+       if (unlikely(atomic_read(&page->_mapcount) != -1))
                bad_reason = "nonzero mapcount";
        if (unlikely(page->mapping != NULL))
                bad_reason = "non-NULL mapping";
@@ -2277,13 +2297,13 @@ failed:
 static struct {
        struct fault_attr attr;
 
-       u32 ignore_gfp_highmem;
-       u32 ignore_gfp_reclaim;
+       bool ignore_gfp_highmem;
+       bool ignore_gfp_reclaim;
        u32 min_order;
 } fail_page_alloc = {
        .attr = FAULT_ATTR_INITIALIZER,
-       .ignore_gfp_reclaim = 1,
-       .ignore_gfp_highmem = 1,
+       .ignore_gfp_reclaim = true,
+       .ignore_gfp_highmem = true,
        .min_order = 1,
 };