Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.4.12-ac6 /mm/swap.c

Filename:/mm/swap.c
Lines Added:60
Lines Deleted:13
Also changed in: (Previous) 2.4.12-ac4  2.4.12-ac5  2.4.12-ac3  2.4.12-ac2  2.4.12-ac1  2.4.10-ac12 
(Following) 2.4.13  2.4.13-ac1  2.4.13-ac2  2.4.13-ac3  2.4.13-ac4  2.4.13-ac5 

Location
[  2.4.12-ac6
  [  mm
     o  swap.c

Patch

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla/mm/swap.c linux.ac/mm/swap.c
--- linux.vanilla/mm/swap.c   Sat Sep 22 18:42:06 2001
+++ linux.ac/mm/swap.c   Wed Oct 10 01:48:38 2001
@@ -24,12 +24,34 @@
 #include <asm/uaccess.h> /* for copy_to/from_user */
 #include <asm/pgtable.h>
 
+/*
+ * We identify three levels of free memory.  We never let free mem
+ * fall below the freepages.min except for atomic allocations.  We
+ * start background swapping if we fall below freepages.high free
+ * pages, and we begin intensive swapping below freepages.low.
+ *
+ * Actual initialization is done in mm/page_alloc.c
+ */
+freepages_t freepages = {
+   0,   /* freepages.min */
+   0,   /* freepages.low */
+   0   /* freepages.high */
+};
+
 /* How many pages do we try to swap or page in/out together? */
 int page_cluster;
 
-/* We track the number of pages currently being asynchronously swapped
-   out, so that we don't try to swap TOO many pages out at once */
-atomic_t nr_async_pages = ATOMIC_INIT(0);
+buffer_mem_t buffer_mem = {
+   2,   /* minimum percent buffer */
+   10,   /* borrow percent buffer */
+   60   /* maximum percent buffer */
+};
+
+buffer_mem_t page_cache = {
+   2,   /* minimum percent page cache */
+   50,   /* borrow percent page cache */
+   75   /* maximum */
+};
 
 pager_daemon_t pager_daemon = {
    512,   /* base number for calculating the number of tries */
@@ -50,9 +72,15 @@
  */
 void deactivate_page_nolock(struct page * page)
 {
-   if (PageActive(page)) {
+   /*
+    * Don't touch it if it's not on the active list.
+    * (some pages aren't on any list at all)
+    */
+   if (PageActive(page) && !page_ramdisk(page)) {
+      page->age = 0;
+      ClearPageReferenced(page);
       del_page_from_active_list(page);
-      add_page_to_inactive_list(page);
+      add_page_to_inactive_dirty_list(page);
    }
 }   
 
@@ -68,10 +96,22 @@
  */
 void activate_page_nolock(struct page * page)
 {
-   if (PageInactive(page)) {
-      del_page_from_inactive_list(page);
+   if (PageInactiveDirty(page)) {
+      del_page_from_inactive_dirty_list(page);
       add_page_to_active_list(page);
+   } else if (PageInactiveClean(page)) {
+      del_page_from_inactive_clean_list(page);
+      add_page_to_active_list(page);
+   } else {
+      /*
+       * The page was not on any list, so we take care
+       * not to do anything.
+       */
    }
+
+   /* Make sure the page gets a fair chance at staying active. */
+   if (page->age < PAGE_AGE_START)
+      page->age = PAGE_AGE_START;
 }
 
 void activate_page(struct page * page)
@@ -87,10 +127,14 @@
  */
 void lru_cache_add(struct page * page)
 {
+   spin_lock(&pagemap_lru_lock);
    if (!PageLocked(page))
       BUG();
-   spin_lock(&pagemap_lru_lock);
-   add_page_to_inactive_list(page);
+   DEBUG_ADD_PAGE
+   add_page_to_active_list(page);
+   /* This should be relatively rare */
+   if (!page->age)
+      deactivate_page_nolock(page);
    spin_unlock(&pagemap_lru_lock);
 }
 
@@ -105,11 +149,14 @@
 {
    if (PageActive(page)) {
       del_page_from_active_list(page);
-   } else if (PageInactive(page)) {
-      del_page_from_inactive_list(page);
-   } else
+   } else if (PageInactiveDirty(page)) {
+      del_page_from_inactive_dirty_list(page);
+   } else if (PageInactiveClean(page)) {
+      del_page_from_inactive_clean_list(page);
+   } else {
       printk("VM: __lru_cache_del, found unknown page ?!\n");
-   DEBUG_LRU_PAGE(page);
+   }
+   DEBUG_ADD_PAGE
 }
 
 /**


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.