diff for duplicates of <20150129012356.GA9672@blaptop> diff --git a/a/1.txt b/N1/1.txt index 13c5474..c7086a0 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -33,3 +33,103 @@ will be same so I think we need more explicit logic to prevent cache thrashing. Could you test below patch? Thanks. + +>From d7659ff20f065b89633037652042968ba9c9f5c2 Mon Sep 17 00:00:00 2001 +From: Minchan Kim <minchan@kernel.org> +Date: Wed, 28 Jan 2015 14:01:57 +0900 +Subject: [PATCH] mm: prevent page thrashing for non-swap + +Josh reported + +"I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some +other stupid program goes off the deep end and eats up my RAM, I hit +some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every +time the program tries to do something to eat more RAM, it cranks disk +hard; the disk starts thrashing, the mouse pointer stops moving, and +nothing goes on. It's like swapping like crazy, except you're reading +library files instead of paged anonymous RAM." + +With swap enable, get_scan_count has a logic to prevent cache thrasing +but it doesn't with no swap case. This patch adds the check for +non-swap case so that we shouldn't drop all of page cache in non-swap +case, either to prevent cache thrashing. + +Reported-by: John Moser <john.r.moser@gmail.com> +Signed-off-by: Minchan Kim <minchan@kernel.org> +--- + mm/vmscan.c | 42 ++++++++++++++++++++++++++++++------------ + 1 file changed, 30 insertions(+), 12 deletions(-) + +diff --git a/mm/vmscan.c b/mm/vmscan.c +index 671e47edb584..2a2236fceaee 100644 +--- a/mm/vmscan.c ++++ b/mm/vmscan.c +@@ -1957,6 +1957,22 @@ enum scan_balance { + SCAN_FILE, + }; + ++bool enough_file_pages(struct zone *zone) ++{ ++ bool ret = true; ++ unsigned long zonefile; ++ unsigned long zonefree; ++ ++ zonefree = zone_page_state(zone, NR_FREE_PAGES); ++ zonefile = zone_page_state(zone, NR_ACTIVE_FILE) + ++ zone_page_state(zone, NR_INACTIVE_FILE); ++ ++ if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) ++ ret = false; ++ ++ return ret; ++} ++ + /* + * Determine how aggressively the anon and file LRU lists should be + * scanned. The relative value of each set of LRU lists is determined +@@ -2039,18 +2055,9 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness, + * thrashing file LRU becomes infinitely more attractive than + * anon pages. Try to detect this based on file LRU size. + */ +- if (global_reclaim(sc)) { +- unsigned long zonefile; +- unsigned long zonefree; +- +- zonefree = zone_page_state(zone, NR_FREE_PAGES); +- zonefile = zone_page_state(zone, NR_ACTIVE_FILE) + +- zone_page_state(zone, NR_INACTIVE_FILE); +- +- if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) { +- scan_balance = SCAN_ANON; +- goto out; +- } ++ if (global_reclaim(sc) && !enough_file_pages(zone)) { ++ scan_balance = SCAN_ANON; ++ goto out; + } + + /* +@@ -2143,6 +2150,17 @@ out: + denominator); + break; + case SCAN_FILE: ++ /* ++ * If there isn't enough page cache to prevent ++ * cache thrashing, OOM is better than long time ++ * unresponsible system. ++ */ ++ if (global_reclaim(sc) && file && ++ !enough_file_pages(zone)) { ++ size = 0; ++ scan = 0; ++ break; ++ } + case SCAN_ANON: + /* Scan one type exclusively */ + if ((scan_balance == SCAN_FILE) != file) { +-- +1.9.1 + +-- +Kind regards, +Minchan Kim diff --git a/a/content_digest b/N1/content_digest index c7f0088..aea4fa6 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -50,6 +50,106 @@ "will be same so I think we need more explicit logic to prevent cache\n" "thrashing. Could you test below patch?\n" "\n" - Thanks. + "Thanks.\n" + "\n" + ">From d7659ff20f065b89633037652042968ba9c9f5c2 Mon Sep 17 00:00:00 2001\n" + "From: Minchan Kim <minchan@kernel.org>\n" + "Date: Wed, 28 Jan 2015 14:01:57 +0900\n" + "Subject: [PATCH] mm: prevent page thrashing for non-swap\n" + "\n" + "Josh reported\n" + "\n" + "\"I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some\n" + "other stupid program goes off the deep end and eats up my RAM, I hit\n" + "some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every\n" + "time the program tries to do something to eat more RAM, it cranks disk\n" + "hard; the disk starts thrashing, the mouse pointer stops moving, and\n" + "nothing goes on. It's like swapping like crazy, except you're reading\n" + "library files instead of paged anonymous RAM.\"\n" + "\n" + "With swap enable, get_scan_count has a logic to prevent cache thrasing\n" + "but it doesn't with no swap case. This patch adds the check for\n" + "non-swap case so that we shouldn't drop all of page cache in non-swap\n" + "case, either to prevent cache thrashing.\n" + "\n" + "Reported-by: John Moser <john.r.moser@gmail.com>\n" + "Signed-off-by: Minchan Kim <minchan@kernel.org>\n" + "---\n" + " mm/vmscan.c | 42 ++++++++++++++++++++++++++++++------------\n" + " 1 file changed, 30 insertions(+), 12 deletions(-)\n" + "\n" + "diff --git a/mm/vmscan.c b/mm/vmscan.c\n" + "index 671e47edb584..2a2236fceaee 100644\n" + "--- a/mm/vmscan.c\n" + "+++ b/mm/vmscan.c\n" + "@@ -1957,6 +1957,22 @@ enum scan_balance {\n" + " \tSCAN_FILE,\n" + " };\n" + " \n" + "+bool enough_file_pages(struct zone *zone)\n" + "+{\n" + "+\tbool ret = true;\n" + "+\tunsigned long zonefile;\n" + "+\tunsigned long zonefree;\n" + "+\n" + "+\tzonefree = zone_page_state(zone, NR_FREE_PAGES);\n" + "+\tzonefile = zone_page_state(zone, NR_ACTIVE_FILE) +\n" + "+\t\t zone_page_state(zone, NR_INACTIVE_FILE);\n" + "+\n" + "+\tif (unlikely(zonefile + zonefree <= high_wmark_pages(zone)))\n" + "+\t\tret = false;\n" + "+\n" + "+\treturn ret;\n" + "+}\n" + "+\n" + " /*\n" + " * Determine how aggressively the anon and file LRU lists should be\n" + " * scanned. The relative value of each set of LRU lists is determined\n" + "@@ -2039,18 +2055,9 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness,\n" + " \t * thrashing file LRU becomes infinitely more attractive than\n" + " \t * anon pages. Try to detect this based on file LRU size.\n" + " \t */\n" + "-\tif (global_reclaim(sc)) {\n" + "-\t\tunsigned long zonefile;\n" + "-\t\tunsigned long zonefree;\n" + "-\n" + "-\t\tzonefree = zone_page_state(zone, NR_FREE_PAGES);\n" + "-\t\tzonefile = zone_page_state(zone, NR_ACTIVE_FILE) +\n" + "-\t\t\t zone_page_state(zone, NR_INACTIVE_FILE);\n" + "-\n" + "-\t\tif (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) {\n" + "-\t\t\tscan_balance = SCAN_ANON;\n" + "-\t\t\tgoto out;\n" + "-\t\t}\n" + "+\tif (global_reclaim(sc) && !enough_file_pages(zone)) {\n" + "+\t\tscan_balance = SCAN_ANON;\n" + "+\t\tgoto out;\n" + " \t}\n" + " \n" + " \t/*\n" + "@@ -2143,6 +2150,17 @@ out:\n" + " \t\t\t\t\t\t\tdenominator);\n" + " \t\t\t\tbreak;\n" + " \t\t\tcase SCAN_FILE:\n" + "+\t\t\t\t/*\n" + "+\t\t\t\t * If there isn't enough page cache to prevent\n" + "+\t\t\t\t * cache thrashing, OOM is better than long time\n" + "+\t\t\t\t * unresponsible system.\n" + "+\t\t\t\t */\n" + "+\t\t\t\tif (global_reclaim(sc) && file &&\n" + "+\t\t\t\t\t\t!enough_file_pages(zone)) {\n" + "+\t\t\t\t\tsize = 0;\n" + "+\t\t\t\t\tscan = 0;\n" + "+\t\t\t\t\tbreak;\n" + "+\t\t\t\t}\n" + " \t\t\tcase SCAN_ANON:\n" + " \t\t\t\t/* Scan one type exclusively */\n" + " \t\t\t\tif ((scan_balance == SCAN_FILE) != file) {\n" + "-- \n" + "1.9.1\n" + "\n" + "-- \n" + "Kind regards,\n" + Minchan Kim -65c34e1e6424cea38ded53cd11dbebc177f12106cf0f48f8f29268036355c4b5 +1207d1b3462b7ac795fca17d8d289e083aa31fec5327f010c04ddce23c32b073
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.