Skip to contentSkip to conversation

mm: swapoff prototype: frontswap handling added

RFC Superseded Kelley Nielsen 2 participants 2 messages Nov 12, 2014

Subsystems (3)

v6 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

RFC v6 2/2 mm: swapoff prototype: frontswap handling added

The prototype of the new swapoff (without the quadratic complexity) presently ignores the frontswap case. Pass the count of pages_to_unuse down the page table walks in try_to_unuse(), and return from the walk when the desired number of pages has been swapped back in.

---
 mm/shmem.c    |  1 +
 mm/swapfile.c | 53 +++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 38 insertions(+), 16 deletions(-)
mm/shmem.c +1 -0
index 2a7179c..e7a813f 100644
@@ -629,6 +629,7 @@ static int shmem_unuse_inode(struct inode *inode, unsigned int type)
 	int entries = 0;
 	swp_entry_t entry;
 	unsigned int stype;
+
 	pgoff_t start = 0;
 	gfp = mapping_gfp_mask(mapping);
 
mm/swapfile.c +37 -16

148 lines not on this page · raw message

Signature · 7 lines
1.8.3.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#1 lore raw
Quoted 17 lines · Kelley Nielsen

The prototype of the new swapoff (without the quadratic complexity) presently ignores the frontswap case. Pass the count of pages_to_unuse down the page table walks in try_to_unuse(), and return from the walk when the desired number of pages has been swapped back in.

---
 mm/shmem.c    |  1 +
 mm/swapfile.c | 53 +++++++++++++++++++++++++++++++++++++----------------
 2 files changed, 38 insertions(+), 16 deletions(-)
mm/shmem.c +0 -0
index 2a7179c..e7a813f 100644

mm/shmem.c static int shmem_unuse_inode(struct inode *inode, unsigned int type) · line 633

Quoted 5 lines
mm/shmem.c +1 -0
@@ -629,6 +629,7 @@ static int shmem_unuse_inode(struct inode *inode, unsigned int type)
 	int entries = 0;
 	swp_entry_t entry;
 	unsigned int stype;
+
 	pgoff_t start = 0;

Why is there an shmem.c blank line in the frontswap patch?

mm/shmem.c static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd, · line 1223

Quoted 13 lines
mm/shmem.c +9 -0
@@ -1210,6 +1212,15 @@ static int unuse_pte_range(struct vm_area_struct *vma, pmd_t *pmd,
 		SetPageDirty(page);
 		unlock_page(page);
 		page_cache_release(page);
+		if (ret && pages_to_unuse > 0) {
+			pages_to_unuse--;
+			/*
+			 * we've unused all we need for frontswap,
+			 * so return special code to indicate this.
+			 */
+			if (pages_to_unuse == 0)
+				return 2;
+		}

If you are using a magic value, could you make it a #define so people can more easily find out why the code is testing for == 2 elsewhere?

One obvious bug is that the pages_to_unuse variable is passed by value, so try_to_unuse never sees that unuse_pte_range decremented the counter. You will want to use a pointer instead.

A second issue is that you decrement pages_to_unuse on every pte unmap, and not on every swap slot that is unused. Would it make more sense to decrement pages_to_unuse where you call delete_from_swap_cache?

Other than that, this series looks good to me.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>