linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC][PATCH] avoid swapping out with swappiness==0
@ 2012-03-02 17:36 Satoru Moriya
  2012-03-02 22:47 ` Rik van Riel
                   ` (4 more replies)
  0 siblings, 5 replies; 32+ messages in thread
From: Satoru Moriya @ 2012-03-02 17:36 UTC (permalink / raw)
  To: linux-mm
  Cc: linux-kernel, Rik van Riel, lwoodman, jweiner, shaohua.li,
	KOSAKI Motohiro, dle-develop, Seiji Aguchi

Sometimes we'd like to avoid swapping out anonymous memory
in particular, avoid swapping out pages of important process or
process groups while there is a reasonable amount of pagecache
on RAM so that we can satisfy our customers' requirements.

OTOH, we can control how aggressive the kernel will swap memory pages
with /proc/sys/vm/swappiness for global and
/sys/fs/cgroup/memory/memory.swappiness for each memcg.

But with current reclaim implementation, the kernel may swap out
even if we set swappiness==0 and there is pagecache on RAM.

This patch changes the behavior with swappiness==0. If we set
swappiness==0, the kernel does not swap out completely
(for global reclaim until the amount of free pages and filebacked
pages in a zone has been reduced to something very very small
(nr_free + nr_filebacked < high watermark)).

Any comments are welcome.

Regards,
Satoru Moriya

Signed-off-by: Satoru Moriya <satoru.moriya@hds.com>
---
 mm/vmscan.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index c52b235..27dc3e8 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1983,10 +1983,10 @@ static void get_scan_count(struct mem_cgroup_zone *mz, struct scan_control *sc,
 	 * proportional to the fraction of recently scanned pages on
 	 * each list that were recently referenced and in active use.
 	 */
-	ap = (anon_prio + 1) * (reclaim_stat->recent_scanned[0] + 1);
+	ap = anon_prio * (reclaim_stat->recent_scanned[0] + 1);
 	ap /= reclaim_stat->recent_rotated[0] + 1;
 
-	fp = (file_prio + 1) * (reclaim_stat->recent_scanned[1] + 1);
+	fp = file_prio * (reclaim_stat->recent_scanned[1] + 1);
 	fp /= reclaim_stat->recent_rotated[1] + 1;
 	spin_unlock_irq(&mz->zone->lru_lock);
 
@@ -1999,7 +1999,7 @@ out:
 		unsigned long scan;
 
 		scan = zone_nr_lru_pages(mz, lru);
-		if (priority || noswap) {
+		if (priority || noswap || !vmscan_swappiness(mz, sc)) {
 			scan >>= priority;
 			if (!scan && force_scan)
 				scan = SWAP_CLUSTER_MAX;
-- 
1.7.6.4


^ permalink raw reply related	[flat|nested] 32+ messages in thread

end of thread, other threads:[~2012-05-21 13:39 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-02 17:36 [RFC][PATCH] avoid swapping out with swappiness==0 Satoru Moriya
2012-03-02 22:47 ` Rik van Riel
2012-03-02 23:43   ` Satoru Moriya
2012-03-03  2:29   ` Hillf Danton
2012-03-04  6:57 ` Minchan Kim
2012-03-05 21:38   ` Satoru Moriya
2012-03-05 13:49 ` Rik van Riel
2012-03-05 21:56 ` Johannes Weiner
2012-03-07 17:19   ` KOSAKI Motohiro
2012-03-07 18:18     ` Satoru Moriya
2012-03-30 22:44       ` Satoru Moriya
2012-04-02 17:10         ` KOSAKI Motohiro
2012-04-03 11:25           ` Jerome Marchand
2012-04-03 15:15             ` Satoru Moriya
2012-04-04 17:38             ` KOSAKI Motohiro
2012-04-21  0:21               ` Satoru Moriya
2012-05-11 21:11                 ` Satoru Moriya
2012-05-12 22:21                   ` Rik van Riel
2012-04-24  8:20       ` Richard Davies
2012-04-24 22:14         ` Satoru Moriya
2012-04-26 14:26           ` Richard Davies
2012-04-26 15:41             ` KOSAKI Motohiro
2012-05-07 20:09               ` Rik van Riel
2012-05-08  0:05                 ` Minchan Kim
2012-05-21  7:12                 ` Richard Davies
2012-05-21 13:39                   ` Satoru Moriya
2012-04-26 14:50         ` Christoph Lameter
2012-04-26 15:37           ` KOSAKI Motohiro
2012-04-26 16:08             ` Richard Davies
2012-04-26 18:20             ` Christoph Lameter
2012-04-27 13:55           ` Rik van Riel
2012-05-07 20:11 ` Rik van Riel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).