[PATCH] vmscan: skip reclaim_mapped determination if we do not swap

This puts the variables and the way to get to reclaim_mapped in one block.
And allows zone_reclaim or other things to skip the determination (maybe
this whole block of code does not belong into refill_inactive_zone()?)

Signed-off-by: Christoph Lameter <clameter@sgi.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Christoph Lameter and committed by Linus Torvalds 2903fb16 072eaa5d

+41 -34
+41 -34
mm/vmscan.c
··· 1195 1195 struct page *page; 1196 1196 struct pagevec pvec; 1197 1197 int reclaim_mapped = 0; 1198 - long mapped_ratio; 1199 - long distress; 1200 - long swap_tendency; 1198 + 1199 + if (unlikely(sc->may_swap)) { 1200 + long mapped_ratio; 1201 + long distress; 1202 + long swap_tendency; 1203 + 1204 + /* 1205 + * `distress' is a measure of how much trouble we're having 1206 + * reclaiming pages. 0 -> no problems. 100 -> great trouble. 1207 + */ 1208 + distress = 100 >> zone->prev_priority; 1209 + 1210 + /* 1211 + * The point of this algorithm is to decide when to start 1212 + * reclaiming mapped memory instead of just pagecache. Work out 1213 + * how much memory 1214 + * is mapped. 1215 + */ 1216 + mapped_ratio = (sc->nr_mapped * 100) / total_memory; 1217 + 1218 + /* 1219 + * Now decide how much we really want to unmap some pages. The 1220 + * mapped ratio is downgraded - just because there's a lot of 1221 + * mapped memory doesn't necessarily mean that page reclaim 1222 + * isn't succeeding. 1223 + * 1224 + * The distress ratio is important - we don't want to start 1225 + * going oom. 1226 + * 1227 + * A 100% value of vm_swappiness overrides this algorithm 1228 + * altogether. 1229 + */ 1230 + swap_tendency = mapped_ratio / 2 + distress + vm_swappiness; 1231 + 1232 + /* 1233 + * Now use this metric to decide whether to start moving mapped 1234 + * memory onto the inactive list. 1235 + */ 1236 + if (swap_tendency >= 100) 1237 + reclaim_mapped = 1; 1238 + } 1201 1239 1202 1240 lru_add_drain(); 1203 1241 spin_lock_irq(&zone->lru_lock); ··· 1244 1206 zone->pages_scanned += pgscanned; 1245 1207 zone->nr_active -= pgmoved; 1246 1208 spin_unlock_irq(&zone->lru_lock); 1247 - 1248 - /* 1249 - * `distress' is a measure of how much trouble we're having reclaiming 1250 - * pages. 0 -> no problems. 100 -> great trouble. 1251 - */ 1252 - distress = 100 >> zone->prev_priority; 1253 - 1254 - /* 1255 - * The point of this algorithm is to decide when to start reclaiming 1256 - * mapped memory instead of just pagecache. Work out how much memory 1257 - * is mapped. 1258 - */ 1259 - mapped_ratio = (sc->nr_mapped * 100) / total_memory; 1260 - 1261 - /* 1262 - * Now decide how much we really want to unmap some pages. The mapped 1263 - * ratio is downgraded - just because there's a lot of mapped memory 1264 - * doesn't necessarily mean that page reclaim isn't succeeding. 1265 - * 1266 - * The distress ratio is important - we don't want to start going oom. 1267 - * 1268 - * A 100% value of vm_swappiness overrides this algorithm altogether. 1269 - */ 1270 - swap_tendency = mapped_ratio / 2 + distress + vm_swappiness; 1271 - 1272 - /* 1273 - * Now use this metric to decide whether to start moving mapped memory 1274 - * onto the inactive list. 1275 - */ 1276 - if (swap_tendency >= 100 && sc->may_swap) 1277 - reclaim_mapped = 1; 1278 1209 1279 1210 while (!list_empty(&l_hold)) { 1280 1211 cond_resched();