]> err.no Git - linux-2.6/blobdiff - mm/page_alloc.c
[PATCH] setup_per_zone_pages_min() overflow fix
[linux-2.6] / mm / page_alloc.c
index 97d6827c7d669529fb7e5607cad4ba838d1847bf..813b4ec1298a23ee10e0d091305bd8520ba6fad0 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/mempolicy.h>
 
 #include <asm/tlbflush.h>
+#include <asm/div64.h>
 #include "internal.h"
 
 /*
@@ -232,11 +233,13 @@ static inline void prep_zero_page(struct page *page, int order, gfp_t gfp_flags)
  * zone->lock is already acquired when we use these.
  * So, we don't need atomic page->flags operations here.
  */
-static inline unsigned long page_order(struct page *page) {
+static inline unsigned long page_order(struct page *page)
+{
        return page_private(page);
 }
 
-static inline void set_page_order(struct page *page, int order) {
+static inline void set_page_order(struct page *page, int order)
+{
        set_page_private(page, order);
        __SetPageBuddy(page);
 }
@@ -299,9 +302,9 @@ static inline int page_is_buddy(struct page *page, int order)
 
        if (PageBuddy(page) && page_order(page) == order) {
                BUG_ON(page_count(page) != 0);
-               return 1;
+               return 1;
        }
-       return 0;
+       return 0;
 }
 
 /*
@@ -1960,7 +1963,7 @@ static inline void free_zone_pagesets(int cpu)
        }
 }
 
-static int __cpuinit pageset_cpuup_callback(struct notifier_block *nfb,
+static int pageset_cpuup_callback(struct notifier_block *nfb,
                unsigned long action,
                void *hcpu)
 {
@@ -2564,9 +2567,11 @@ void setup_per_zone_pages_min(void)
        }
 
        for_each_zone(zone) {
-               unsigned long tmp;
+               u64 tmp;
+
                spin_lock_irqsave(&zone->lru_lock, flags);
-               tmp = (pages_min * zone->present_pages) / lowmem_pages;
+               tmp = (u64)pages_min * zone->present_pages;
+               do_div(tmp, lowmem_pages);
                if (is_highmem(zone)) {
                        /*
                         * __GFP_HIGH and PF_MEMALLOC allocations usually don't
@@ -2593,8 +2598,8 @@ void setup_per_zone_pages_min(void)
                        zone->pages_min = tmp;
                }
 
-               zone->pages_low   = zone->pages_min + tmp / 4;
-               zone->pages_high  = zone->pages_min + tmp / 2;
+               zone->pages_low   = zone->pages_min + (tmp >> 2);
+               zone->pages_high  = zone->pages_min + (tmp >> 1);
                spin_unlock_irqrestore(&zone->lru_lock, flags);
        }