WAN: protect Cisco HDLC state changes with a spinlock.
[safe/jmp/linux-2.6] / mm / swap.c
index d034b21..91e1944 100644 (file)
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -5,7 +5,7 @@
  */
 
 /*
- * This file contains the default values for the opereation of the
+ * This file contains the default values for the operation of the
  * Linux VM subsystem. Fine-tuning documentation can be found in
  * Documentation/sysctl/vm.txt.
  * Started 18.12.91
@@ -28,6 +28,8 @@
 #include <linux/percpu.h>
 #include <linux/cpu.h>
 #include <linux/notifier.h>
+#include <linux/backing-dev.h>
+#include <linux/memcontrol.h>
 
 /* How many pages do we try to swap or page in/out together? */
 int page_cluster;
@@ -40,7 +42,7 @@ static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs) = { 0, };
  * This path almost never happens for VM activity - pages are normally
  * freed via pagevecs.  But it gets used by networking.
  */
-static void fastcall __page_cache_release(struct page *page)
+static void __page_cache_release(struct page *page)
 {
        if (PageLRU(page)) {
                unsigned long flags;
@@ -76,12 +78,11 @@ void put_page(struct page *page)
 EXPORT_SYMBOL(put_page);
 
 /**
- * put_pages_list(): release a list of pages
+ * put_pages_list() - release a list of pages
+ * @pages: list of pages threaded on page->lru
  *
  * Release a list of pages which are strung together on page.lru.  Currently
  * used by read_cache_pages() and related error recovery code.
- *
- * @pages: list of pages threaded on page->lru
  */
 void put_pages_list(struct list_head *pages)
 {
@@ -131,40 +132,27 @@ static void pagevec_move_tail(struct pagevec *pvec)
  * Writeback is about to end against a page which has been marked for immediate
  * reclaim.  If it still appears to be reclaimable, move it to the tail of the
  * inactive list.
- *
- * Returns zero if it cleared PG_writeback.
  */
-int rotate_reclaimable_page(struct page *page)
+void  rotate_reclaimable_page(struct page *page)
 {
-       struct pagevec *pvec;
-       unsigned long flags;
-
-       if (PageLocked(page))
-               return 1;
-       if (PageDirty(page))
-               return 1;
-       if (PageActive(page))
-               return 1;
-       if (!PageLRU(page))
-               return 1;
-
-       page_cache_get(page);
-       local_irq_save(flags);
-       pvec = &__get_cpu_var(lru_rotate_pvecs);
-       if (!pagevec_add(pvec, page))
-               pagevec_move_tail(pvec);
-       local_irq_restore(flags);
-
-       if (!test_clear_page_writeback(page))
-               BUG();
+       if (!PageLocked(page) && !PageDirty(page) && !PageActive(page) &&
+           PageLRU(page)) {
+               struct pagevec *pvec;
+               unsigned long flags;
 
-       return 0;
+               page_cache_get(page);
+               local_irq_save(flags);
+               pvec = &__get_cpu_var(lru_rotate_pvecs);
+               if (!pagevec_add(pvec, page))
+                       pagevec_move_tail(pvec);
+               local_irq_restore(flags);
+       }
 }
 
 /*
  * FIXME: speed this up?
  */
-void fastcall activate_page(struct page *page)
+void activate_page(struct page *page)
 {
        struct zone *zone = page_zone(page);
 
@@ -174,6 +162,7 @@ void fastcall activate_page(struct page *page)
                SetPageActive(page);
                add_page_to_active_list(zone, page);
                __count_vm_event(PGACTIVATE);
+               mem_cgroup_move_lists(page, true);
        }
        spin_unlock_irq(&zone->lru_lock);
 }
@@ -185,7 +174,7 @@ void fastcall activate_page(struct page *page)
  * inactive,referenced         ->      active,unreferenced
  * active,unreferenced         ->      active,referenced
  */
-void fastcall mark_page_accessed(struct page *page)
+void mark_page_accessed(struct page *page)
 {
        if (!PageActive(page) && PageReferenced(page) && PageLRU(page)) {
                activate_page(page);
@@ -201,7 +190,7 @@ EXPORT_SYMBOL(mark_page_accessed);
  * lru_cache_add: add a page to the page lists
  * @page: the page to add
  */
-void fastcall lru_cache_add(struct page *page)
+void lru_cache_add(struct page *page)
 {
        struct pagevec *pvec = &get_cpu_var(lru_add_pvecs);
 
@@ -211,7 +200,7 @@ void fastcall lru_cache_add(struct page *page)
        put_cpu_var(lru_add_pvecs);
 }
 
-void fastcall lru_cache_add_active(struct page *page)
+void lru_cache_add_active(struct page *page)
 {
        struct pagevec *pvec = &get_cpu_var(lru_add_active_pvecs);
 
@@ -547,6 +536,10 @@ void __init swap_setup(void)
 {
        unsigned long megs = num_physpages >> (20 - PAGE_SHIFT);
 
+#ifdef CONFIG_SWAP
+       bdi_init(swapper_space.backing_dev_info);
+#endif
+
        /* Use a smaller cluster for small-memory machines */
        if (megs < 16)
                page_cluster = 2;