vmscan.c (4eda48235011d6965f5229f8955ddcd355311570) | vmscan.c (c55e8d035b28b2867e68b0e2d0eee2c0f1016b43) |
---|---|
1/* 2 * linux/mm/vmscan.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 * 6 * Swap reorganised 29.12.95, Stephen Tweedie. 7 * kswapd added: 7.1.96 sct 8 * Removed kswapd_ctl limits, and swap out as many pages as needed --- 1042 unchanged lines hidden (view full) --- 1051 * __GFP_IO|__GFP_FS for this reason); but more thought 1052 * would probably show more reasons. 1053 * 1054 * 3) Legacy memcg encounters a page that is already marked 1055 * PageReclaim. memcg does not have any dirty pages 1056 * throttling so we could easily OOM just because too many 1057 * pages are in writeback and there is nothing else to 1058 * reclaim. Wait for the writeback to complete. | 1/* 2 * linux/mm/vmscan.c 3 * 4 * Copyright (C) 1991, 1992, 1993, 1994 Linus Torvalds 5 * 6 * Swap reorganised 29.12.95, Stephen Tweedie. 7 * kswapd added: 7.1.96 sct 8 * Removed kswapd_ctl limits, and swap out as many pages as needed --- 1042 unchanged lines hidden (view full) --- 1051 * __GFP_IO|__GFP_FS for this reason); but more thought 1052 * would probably show more reasons. 1053 * 1054 * 3) Legacy memcg encounters a page that is already marked 1055 * PageReclaim. memcg does not have any dirty pages 1056 * throttling so we could easily OOM just because too many 1057 * pages are in writeback and there is nothing else to 1058 * reclaim. Wait for the writeback to complete. |
1059 * 1060 * In cases 1) and 2) we activate the pages to get them out of 1061 * the way while we continue scanning for clean pages on the 1062 * inactive list and refilling from the active list. The 1063 * observation here is that waiting for disk writes is more 1064 * expensive than potentially causing reloads down the line. 1065 * Since they're marked for immediate reclaim, they won't put 1066 * memory pressure on the cache working set any longer than it 1067 * takes to write them to disk. |
|
1059 */ 1060 if (PageWriteback(page)) { 1061 /* Case 1 above */ 1062 if (current_is_kswapd() && 1063 PageReclaim(page) && 1064 test_bit(PGDAT_WRITEBACK, &pgdat->flags)) { 1065 nr_immediate++; | 1068 */ 1069 if (PageWriteback(page)) { 1070 /* Case 1 above */ 1071 if (current_is_kswapd() && 1072 PageReclaim(page) && 1073 test_bit(PGDAT_WRITEBACK, &pgdat->flags)) { 1074 nr_immediate++; |
1066 goto keep_locked; | 1075 goto activate_locked; |
1067 1068 /* Case 2 above */ 1069 } else if (sane_reclaim(sc) || 1070 !PageReclaim(page) || !may_enter_fs) { 1071 /* 1072 * This is slightly racy - end_page_writeback() 1073 * might have just cleared PageReclaim, then 1074 * setting PageReclaim here end up interpreted 1075 * as PageReadahead - but that does not matter 1076 * enough to care. What we do want is for this 1077 * page to have PageReclaim set next time memcg 1078 * reclaim reaches the tests above, so it will 1079 * then wait_on_page_writeback() to avoid OOM; 1080 * and it's also appropriate in global reclaim. 1081 */ 1082 SetPageReclaim(page); 1083 nr_writeback++; | 1076 1077 /* Case 2 above */ 1078 } else if (sane_reclaim(sc) || 1079 !PageReclaim(page) || !may_enter_fs) { 1080 /* 1081 * This is slightly racy - end_page_writeback() 1082 * might have just cleared PageReclaim, then 1083 * setting PageReclaim here end up interpreted 1084 * as PageReadahead - but that does not matter 1085 * enough to care. What we do want is for this 1086 * page to have PageReclaim set next time memcg 1087 * reclaim reaches the tests above, so it will 1088 * then wait_on_page_writeback() to avoid OOM; 1089 * and it's also appropriate in global reclaim. 1090 */ 1091 SetPageReclaim(page); 1092 nr_writeback++; |
1084 goto keep_locked; | 1093 goto activate_locked; |
1085 1086 /* Case 3 above */ 1087 } else { 1088 unlock_page(page); 1089 wait_on_page_writeback(page); 1090 /* then go back and try same page again */ 1091 list_add_tail(&page->lru, page_list); 1092 continue; --- 76 unchanged lines hidden (view full) --- 1169 * Immediately reclaim when written back. 1170 * Similar in principal to deactivate_page() 1171 * except we already have the page isolated 1172 * and know it's dirty 1173 */ 1174 inc_node_page_state(page, NR_VMSCAN_IMMEDIATE); 1175 SetPageReclaim(page); 1176 | 1094 1095 /* Case 3 above */ 1096 } else { 1097 unlock_page(page); 1098 wait_on_page_writeback(page); 1099 /* then go back and try same page again */ 1100 list_add_tail(&page->lru, page_list); 1101 continue; --- 76 unchanged lines hidden (view full) --- 1178 * Immediately reclaim when written back. 1179 * Similar in principal to deactivate_page() 1180 * except we already have the page isolated 1181 * and know it's dirty 1182 */ 1183 inc_node_page_state(page, NR_VMSCAN_IMMEDIATE); 1184 SetPageReclaim(page); 1185 |
1177 goto keep_locked; | 1186 goto activate_locked; |
1178 } 1179 1180 if (references == PAGEREF_RECLAIM_CLEAN) 1181 goto keep_locked; 1182 if (!may_enter_fs) 1183 goto keep_locked; 1184 if (!sc->may_writepage) 1185 goto keep_locked; --- 2685 unchanged lines hidden --- | 1187 } 1188 1189 if (references == PAGEREF_RECLAIM_CLEAN) 1190 goto keep_locked; 1191 if (!may_enter_fs) 1192 goto keep_locked; 1193 if (!sc->may_writepage) 1194 goto keep_locked; --- 2685 unchanged lines hidden --- |