mm: mmu_notifier: fix inconsistent memory between secondary MMU and host
[deliverable/linux.git] / mm / frontswap.c
index 0547a35f798b9377826d85ca331905cac45228bd..2890e67d602621f0aaf6b516905b5340c9ef7b2c 100644 (file)
@@ -44,6 +44,13 @@ EXPORT_SYMBOL(frontswap_enabled);
  */
 static bool frontswap_writethrough_enabled __read_mostly;
 
+/*
+ * If enabled, the underlying tmem implementation is capable of doing
+ * exclusive gets, so frontswap_load, on a successful tmem_get must
+ * mark the page as no longer in frontswap AND mark it dirty.
+ */
+static bool frontswap_tmem_exclusive_gets_enabled __read_mostly;
+
 #ifdef CONFIG_DEBUG_FS
 /*
  * Counters available via /sys/kernel/debug/frontswap (if debugfs is
@@ -96,6 +103,15 @@ void frontswap_writethrough(bool enable)
 }
 EXPORT_SYMBOL(frontswap_writethrough);
 
+/*
+ * Enable/disable frontswap exclusive gets (see above).
+ */
+void frontswap_tmem_exclusive_gets(bool enable)
+{
+       frontswap_tmem_exclusive_gets_enabled = enable;
+}
+EXPORT_SYMBOL(frontswap_tmem_exclusive_gets);
+
 /*
  * Called when a swap device is swapon'd.
  */
@@ -174,8 +190,13 @@ int __frontswap_load(struct page *page)
        BUG_ON(sis == NULL);
        if (frontswap_test(sis, offset))
                ret = frontswap_ops.load(type, offset, page);
-       if (ret == 0)
+       if (ret == 0) {
                inc_frontswap_loads();
+               if (frontswap_tmem_exclusive_gets_enabled) {
+                       SetPageDirty(page);
+                       frontswap_clear(sis, offset);
+               }
+       }
        return ret;
 }
 EXPORT_SYMBOL(__frontswap_load);
This page took 0.039436 seconds and 5 git commands to generate.