Cold allocation so that swsusp works

From: Pavel Machek (pavel@ucw.cz)
Date: Thu Dec 19 2002 - 15:04:08 EST


Hi!

This is my try to make swsusp work... Does it look acceptable?
                                                                Pavel

--- clean/include/linux/gfp.h 2002-11-01 00:37:40.000000000 +0100
+++ linux-swsusp/include/linux/gfp.h 2002-12-19 20:35:47.000000000 +0100
@@ -18,6 +18,7 @@
 #define __GFP_HIGHIO 0x80 /* Can start high mem physical IO? */
 #define __GFP_FS 0x100 /* Can call down to low-level FS? */
 #define __GFP_COLD 0x200 /* Cache-cold page required */
+#define __GFP_SWSUSP 0x400 /* We want page that used to be free, not some page from list */
 
 #define GFP_NOHIGHIO ( __GFP_WAIT | __GFP_IO)
 #define GFP_NOIO ( __GFP_WAIT)
--- clean/kernel/suspend.c 2002-12-18 22:21:13.000000000 +0100
+++ linux-swsusp/kernel/suspend.c 2002-12-19 20:39:26.000000000 +0100
@@ -547,7 +547,7 @@
 
         pagedir_order = get_bitmask_order(SUSPEND_PD_PAGES(nr_copy_pages));
 
- p = pagedir = (suspend_pagedir_t *)__get_free_pages(GFP_ATOMIC | __GFP_COLD, pagedir_order);
+ p = pagedir = (suspend_pagedir_t *)__get_free_pages(GFP_ATOMIC | __GFP_SWSUSP, pagedir_order);
         if(!pagedir)
                 return NULL;
 
@@ -556,7 +556,7 @@
                 SetPageNosave(page++);
                 
         while(nr_copy_pages--) {
- p->address = get_zeroed_page(GFP_ATOMIC | __GFP_COLD);
+ p->address = get_zeroed_page(GFP_ATOMIC | __GFP_SWSUSP);
                 if(!p->address) {
                         free_suspend_pagedir((unsigned long) pagedir);
                         return NULL;
--- clean/mm/page_alloc.c 2002-12-18 22:21:13.000000000 +0100
+++ linux-swsusp/mm/page_alloc.c 2002-12-19 20:51:59.000000000 +0100
@@ -389,10 +389,10 @@
         unsigned long flags;
         struct page *page = NULL;
 
- if (order == 0) {
+ if ((order == 0) && !(cold & __GFP_SWSUSP)) {
                 struct per_cpu_pages *pcp;
 
- pcp = &zone->pageset[get_cpu()].pcp[cold];
+ pcp = &zone->pageset[get_cpu()].pcp[!!cold];
                 local_irq_save(flags);
                 if (pcp->count <= pcp->low)
                         pcp->count += rmqueue_bulk(zone, 0,
@@ -444,15 +444,10 @@
         struct zone **zones, *classzone;
         struct page *page;
         int i;
- int cold;
 
         if (wait)
                 might_sleep();
 
- cold = 0;
- if (gfp_mask & __GFP_COLD)
- cold = 1;
-
         zones = zonelist->zones; /* the list of zones suitable for gfp_mask */
         classzone = zones[0];
         if (classzone == NULL) /* no zones in the zonelist */
@@ -466,7 +461,7 @@
                 min += z->pages_low;
                 if (z->free_pages >= min ||
                                 (!wait && z->free_pages >= z->pages_high)) {
- page = buffered_rmqueue(z, order, cold);
+ page = buffered_rmqueue(z, order, gfp_mask & (__GFP_COLD | __GFP_SWSUSP));
                         if (page)
                                 return page;
                 }
@@ -489,7 +484,7 @@
                 min += local_min;
                 if (z->free_pages >= min ||
                                 (!wait && z->free_pages >= z->pages_high)) {
- page = buffered_rmqueue(z, order, cold);
+ page = buffered_rmqueue(z, order, gfp_mask & (__GFP_COLD | __GFP_SWSUSP));
                         if (page)
                                 return page;
                 }
@@ -504,7 +499,7 @@
                 for (i = 0; zones[i] != NULL; i++) {
                         struct zone *z = zones[i];
 
- page = buffered_rmqueue(z, order, cold);
+ page = buffered_rmqueue(z, order, gfp_mask & (__GFP_COLD | __GFP_SWSUSP));
                         if (page)
                                 return page;
                 }
@@ -527,7 +522,7 @@
                 min += z->pages_min;
                 if (z->free_pages >= min ||
                                 (!wait && z->free_pages >= z->pages_high)) {
- page = buffered_rmqueue(z, order, cold);
+ page = buffered_rmqueue(z, order, gfp_mask & (__GFP_COLD | __GFP_SWSUSP));
                         if (page)
                                 return page;
                 }

-- 
Worst form of spam? Adding advertisment signatures ala sourceforge.net.
What goes next? Inserting advertisment *into* email?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Dec 23 2002 - 22:00:25 EST