Skip to contentSkip to conversation

mm-deactivate-invalidated-pages.patch

PATCH Andrew Morton 2 participants 2 messages Jan 18, 2011

Subsystems (3)
lore
Share & tools
lore

Andrew Morton

author maintainer
#0 lore raw

I haven't merged this. What do we think its status/desirability is? Testing results?

I have a note against it: "When PageActive is unset, we need to change cgroup lru too.". Did that get addressed?

Thanks.

From: Minchan Kim <[email protected]>

Recently, there are reported problem about thrashing.
(http://marc.info/?l=rsync&m=128885034930933&w=2) It happens by backup workloads(ex, nightly rsync). That's because the workload makes just use-once pages and touches pages twice. It promotes the page into active list so that it results in working set page eviction.

Some app developer want to support POSIX_FADV_NOREUSE. But other OSes don't support it, either.
(http://marc.info/?l=linux-mm&m=128928979512086&w=2)

By Other approach, app developer uses POSIX_FADV_DONTNEED. But it has a problem. If kernel meets page is writing during invalidate_mapping_pages, it can't work. It is very hard for application programmer to use it. Because they always have to sync data before calling fadivse(..POSIX_FADV_DONTNEED) to make sure the pages could be discardable. At last, they can't use deferred write of kernel so that they could see performance loss.
(http://insights.oetiker.ch/linux/fadvise.html)

In fact, invalidate is very big hint to reclaimer. It means we don't use the page any more. So let's move the writing page into inactive list's head.

If it is real working set, it could have a enough time to activate the page since we always try to keep many pages in inactive list.

I reused Peter's lru_demote() with some changes.

[[email protected]: s/deactive/deactivate/g]
Cc Rik van Riel <[email protected]>
Cc KOSAKI Motohiro <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Nick Piggin <[email protected]>

---

 include/linux/swap.h |    1 
 mm/swap.c            |   58 +++++++++++++++++++++++++++++++++++++++++
 mm/truncate.c        |   16 ++++++++---
 3 files changed, 71 insertions(+), 4 deletions(-)
include/linux/swap.h renamed from include/linux/swap.h~mm-deactivate-invalidated-pages +1 -0
diff -puN include/linux/swap.h~mm-deactivate-invalidated-pages include/linux/swap.h
@@ -215,6 +215,7 @@ extern void mark_page_accessed(struct pa
 extern void lru_add_drain(void);
 extern int lru_add_drain_all(void);
 extern void rotate_reclaimable_page(struct page *page);
+extern void lru_deactivate_page(struct page *page);
 extern void swap_setup(void);
 
 extern void add_page_to_unevictable_list(struct page *page);
mm/swap.c renamed from mm/swap.c~mm-deactivate-invalidated-pages +58 -0

76 lines not on this page · raw message

mm/truncate.c renamed from mm/truncate.c~mm-deactivate-invalidated-pages +12 -4
diff -puN mm/truncate.c~mm-deactivate-invalidated-pages mm/truncate.c
@@ -332,7 +332,8 @@ unsigned long invalidate_mapping_pages(s
 {
 	struct pagevec pvec;
 	pgoff_t next = start;
-	unsigned long ret = 0;
+	unsigned long ret;
+	unsigned long count = 0;
 	int i;
 
 	pagevec_init(&pvec, 0);
@@ -359,8 +360,15 @@ unsigned long invalidate_mapping_pages(s
 			if (lock_failed)
 				continue;
 
-			ret += invalidate_inode_page(page);
-
+			ret = invalidate_inode_page(page);
+			/*
+			 * If the page was dirty or under writeback we cannot
+			 * invalidate it now.  Move it to the tail of the
+			 * inactive LRU so that reclaim will free it promptly.
+			 */
+			if (!ret)
+				lru_deactivate_page(page);
+			count += ret;
 			unlock_page(page);
 			if (next > end)
 				break;
@@ -369,7 +377,7 @@ unsigned long invalidate_mapping_pages(s
 		mem_cgroup_uncharge_end();
 		cond_resched();
 	}
-	return ret;
+	return count;
 }
 EXPORT_SYMBOL(invalidate_mapping_pages);
 

_

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#1 lore raw
Quoted 3 lines · Andrew Morton

I haven't merged this.  What do we think its status/desirability is? Testing results?

Please, revert this.
This patch is old. I have sent several versions to mm. It's a last version.
http://www.spinics.net/lists/linux-mm/msg12492.html
Testing result is following as.
http://marc.info/?l=linux-kernel&m=129225429008739&w=3

Some people already applied it into their kernel and they said to me that this patch series solve response problem in his computer. It's a real issue.
But unfortunately they reported a problem to me so I sent a patch. So I have to resend this series with my one fix and with test result. Hmm.. maybe I need a enough time to rebase and retest.

I will resend it after you release mmotm.

Quoted 3 lines

I have a note against it: "When PageActive is unset, we need to change cgroup lru too.".  Did that get addressed?

Yes. [add/del]_page_to_lru_list already does it.

Thanks, Andrew.

Signature · 9 lines
Kind regards,
Minchan Kim

--
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/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>