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

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

Advertisement

Kernel v2.4.11 /mm/oom_kill.c

Filename:/mm/oom_kill.c
Lines Added:64
Lines Deleted:0
Also changed in: (Previous) 2.4.11-pre6  2.4.11-pre5  2.4.11-pre4  2.4.10-ac10  2.4.10-ac9  2.4.10-ac8 
(Following) 2.4.12-ac1  2.4.12-ac2  2.4.12-ac3  2.4.12-ac4  2.4.12-ac5  2.4.12-ac6 

Location
[  2.4.11
  [  mm
     o  oom_kill.c

Patch

diff -u --recursive --new-file v2.4.10/linux/mm/oom_kill.c linux/mm/oom_kill.c
--- v2.4.10/linux/mm/oom_kill.c   Sun Sep 23 11:41:01 2001
+++ linux/mm/oom_kill.c   Fri Oct  5 13:13:43 2001
@@ -192,3 +192,67 @@
    schedule();
    return;
 }
+
+static inline int node_zones_low(pg_data_t *pgdat)
+{
+   zone_t * zone;
+   int i;
+
+   for (i = pgdat->nr_zones-1; i >= 0; i--) {
+      zone = pgdat->node_zones + i;
+
+      if (zone->free_pages > (zone->pages_low))
+         return 0;
+
+   }
+   return 1;
+}
+
+static int all_zones_low(void)
+{
+   pg_data_t * pgdat = pgdat_list;
+
+   pgdat = pgdat_list;
+   do {
+      if (node_zones_low(pgdat))
+         continue;
+      return 0;
+   } while ((pgdat = pgdat->node_next));
+
+   return 1;
+}
+
+/**
+ * out_of_memory - is the system out of memory?
+ *
+ * Returns 0 if there is still enough memory left,
+ * 1 when we are out of memory (otherwise).
+ */
+int out_of_memory(void)
+{
+   long cache_mem, limit;
+
+   /* Enough free memory?  Not OOM. */
+   if (!all_zones_low())
+      return 0;
+
+   /* Enough swap space left?  Not OOM. */
+   if (nr_swap_pages > 0)
+      return 0;
+
+   /*
+    * If the buffer and page cache (including swap cache) are over
+    * their (/proc tunable) minimum, we're still not OOM.  We test
+    * this to make sure we don't return OOM when the system simply
+    * has a hard time with the cache.
+    */
+   cache_mem = atomic_read(&page_cache_size);
+   limit = 2;
+   limit *= num_physpages / 100;
+
+   if (cache_mem > limit)
+      return 0;
+
+   /* Else... */
+   return 1;
+}


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