[folded-merged] mm-swap-fix-race-between-swapoff-and-some-swap-operations-v6.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: mm, swap: fix race between swapoff and some swap operations
has been removed from the -mm tree.  Its filename was
     mm-swap-fix-race-between-swapoff-and-some-swap-operations-v6.patch

This patch was dropped because it was folded into mm-swap-fix-race-between-swapoff-and-some-swap-operations.patch

------------------------------------------------------
From: Huang Ying <ying.huang@xxxxxxxxx>
Subject: mm, swap: fix race between swapoff and some swap operations

- Add more comments to get_swap_device() to make it more clear about
  possible swapoff or swapoff+swapon.

Link: http://lkml.kernel.org/r/20180223060010.954-1-ying.huang@xxxxxxxxx
Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx>
Cc: Hugh Dickins <hughd@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 mm/memory.c   |    2 +-
 mm/swapfile.c |   23 +++++++++++++++++++++++
 2 files changed, 24 insertions(+), 1 deletion(-)

--- a/mm/memory.c~mm-swap-fix-race-between-swapoff-and-some-swap-operations-v6
+++ a/mm/memory.c
@@ -2717,7 +2717,7 @@ vm_fault_t do_swap_page(struct vm_fault
 		struct swap_info_struct *si = swp_swap_info(entry);
 
 		if (si->flags & SWP_SYNCHRONOUS_IO &&
-		    __swap_count(entry) == 1) {
+				__swap_count(entry) == 1) {
 			/* skip swapcache */
 			page = alloc_page_vma(GFP_HIGHUSER_MOVABLE, vma,
 							vmf->address);
--- a/mm/swapfile.c~mm-swap-fix-race-between-swapoff-and-some-swap-operations-v6
+++ a/mm/swapfile.c
@@ -1180,6 +1180,29 @@ static unsigned char __swap_entry_free_l
  * return pointer to swap_info_struct, and keep the swap entry valid
  * via preventing the swap device from being swapoff, until
  * put_swap_device() is called.  Otherwise return NULL.
+ *
+ * Notice that swapoff or swapoff+swapon can still happen before the
+ * preempt_disable() in get_swap_device() or after the
+ * preempt_enable() in put_swap_device() if there isn't any other way
+ * to prevent swapoff, such as page lock, page table lock, etc.  The
+ * caller must be prepared for that.  For example, the following
+ * situation is possible.
+ *
+ *   CPU1				CPU2
+ *   do_swap_page()
+ *     ...				swapoff+swapon
+ *     __read_swap_cache_async()
+ *       swapcache_prepare()
+ *         __swap_duplicate()
+ *           // check swap_map
+ *     // verify PTE not changed
+ *
+ * In __swap_duplicate(), the swap_map need to be checked before
+ * changing partly because the specified swap entry may be for another
+ * swap device which has been swapoff.  And in do_swap_page(), after
+ * the page is read from the swap device, the PTE is verified not
+ * changed with the page table locked to check whether the swap device
+ * has been swapoff or swapoff+swapon.
  */
 struct swap_info_struct *get_swap_device(swp_entry_t entry)
 {
_

Patches currently in -mm which might be from ying.huang@xxxxxxxxx are

mm-swap-fix-race-between-swapoff-and-some-swap-operations.patch




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux