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

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

Advertisement

Kernel v2.4.13-ac2 /mm/swap.c

Filename:/mm/swap.c
Lines Added:67
Lines Deleted:24
Also changed in: (Previous) 2.4.13  2.4.13-pre6  2.4.13-pre5  2.4.13-pre4  2.4.13-pre3  2.4.12-ac6 
(Following) 2.4.13-ac1  2.4.13-ac3  2.4.13-ac4  2.4.13-ac5  2.4.13-ac6  2.4.13-ac7 

Location
[  2.4.13-ac2
  [  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   Thu Oct 25 16:26:39 2001
+++ linux.ac/mm/swap.c   Thu Oct 25 21:17:04 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 */
@@ -48,11 +70,17 @@
  * called on a page which is not on any of the lists, the
  * page is left alone.
  */
-static inline void deactivate_page_nolock(struct page * page)
+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);
    }
 }   
 
@@ -66,12 +94,24 @@
 /*
  * Move an inactive page to the active list.
  */
-static inline void activate_page_nolock(struct page * page)
+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
 }
 
 /**
@@ -130,15 +177,11 @@
  */
 void __init swap_setup(void)
 {
-   unsigned long megs = num_physpages >> (20 - PAGE_SHIFT);
-
-   /* Use a smaller cluster for small-memory machines */
-   if (megs < 16)
+   /* Use a smaller cluster for memory <16MB or <32MB */
+   if (num_physpages < ((16 * 1024 * 1024) >> PAGE_SHIFT))
       page_cluster = 2;
-   else
+   else if (num_physpages < ((32 * 1024 * 1024) >> PAGE_SHIFT))
       page_cluster = 3;
-   /*
-    * Right now other parts of the system means that we
-    * _really_ don't want to cluster much more
-    */
+   else
+      page_cluster = 4;
 }


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