kernel - SWAP CACHE part 4/many - Add PG_SWAPPED
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 4 Feb 2010 00:50:09 +0000 (16:50 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 4 Feb 2010 00:50:09 +0000 (16:50 -0800)
* Add the PG_SWAPPED flag to struct vm_page to indicate when
  backing store has been assigned to a VM page.

sys/vm/swap_pager.c
sys/vm/vm_page.h

index 584caaa..ada569d 100644 (file)
@@ -763,7 +763,10 @@ swap_pager_haspage(vm_object_t object, vm_pindex_t pindex)
 void
 swap_pager_unswapped(vm_page_t m)
 {
-       swp_pager_meta_ctl(m->object, m->pindex, SWM_FREE);
+       if (m->flags & PG_SWAPPED) {
+               swp_pager_meta_ctl(m->object, m->pindex, SWM_FREE);
+               vm_page_flag_clear(m, PG_SWAPPED);
+       }
 }
 
 /*
@@ -1652,6 +1655,7 @@ swp_pager_async_iodone(struct bio *bio)
                        m->valid = VM_PAGE_BITS_ALL;
                        vm_page_undirty(m);
                        vm_page_flag_clear(m, PG_ZERO | PG_SWAPINPROG);
+                       vm_page_flag_set(m, PG_SWAPPED);
 
                        /*
                         * We have to wake specifically requested pages
@@ -1685,6 +1689,7 @@ swp_pager_async_iodone(struct bio *bio)
                         */
                        vm_page_undirty(m);
                        vm_page_flag_clear(m, PG_SWAPINPROG);
+                       vm_page_flag_set(m, PG_SWAPPED);
                        vm_page_io_finish(m);
                        if (vm_page_count_severe())
                                vm_page_deactivate(m);
index 04fe284..e9ecc14 100644 (file)
@@ -318,6 +318,9 @@ extern struct vpgqueues vm_page_queues[PQ_COUNT];
  *  somewhere, and that the page can be dirtied by hardware at any time
  *  and may have to be tested for that.  The modified bit in unmanaged
  *  mappings or in the special clean map is not tested.
+ *
+ *  PG_SWAPPED indicates that the page is backed by a swap block.  Any
+ *  VM object type other than OBJT_DEFAULT can have swap-backed pages now.
  */
 #define        PG_BUSY         0x0001          /* page is in transit (O) */
 #define        PG_WANTED       0x0002          /* someone is waiting for page (O) */
@@ -333,6 +336,7 @@ extern struct vpgqueues vm_page_queues[PQ_COUNT];
 #define PG_UNMANAGED   0x0800          /* No PV management for page */
 #define PG_MARKER      0x1000          /* special queue marker page */
 #define PG_RAM         0x2000          /* read ahead mark */
+#define PG_SWAPPED     0x4000          /* backed by swap */
 
 /*
  * Misc constants.