Skip to content

Commit d483a5d

Browse files
hnaztorvalds
authored andcommitted
mm: vmscan: limit the range of LRU type balancing
When LRU cost only shows up on one list, we abruptly stop scanning that list altogether. That's an extreme reaction: by the time the other list starts thrashing and the pendulum swings back, we may have no recent age information on the first list anymore, and we could have significant latencies until the scanner has caught up. Soften this change in the feedback system by ensuring that no list receives less than a third of overall pressure, and only distribute the other 66% according to LRU cost. This ensures that we maintain a minimum rate of aging on the entire workingset while it's being pressured, while still allowing a generous rate of convergence when the relative sizes of the lists need to adjust. Signed-off-by: Johannes Weiner <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Cc: Joonsoo Kim <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Rik van Riel <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Linus Torvalds <[email protected]>
1 parent 96f8bf4 commit d483a5d

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

mm/vmscan.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2237,12 +2237,11 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
22372237
unsigned long *nr)
22382238
{
22392239
struct mem_cgroup *memcg = lruvec_memcg(lruvec);
2240+
unsigned long anon_cost, file_cost, total_cost;
22402241
int swappiness = mem_cgroup_swappiness(memcg);
22412242
u64 fraction[2];
22422243
u64 denominator = 0; /* gcc */
2243-
unsigned long anon_prio, file_prio;
22442244
enum scan_balance scan_balance;
2245-
unsigned long totalcost;
22462245
unsigned long ap, fp;
22472246
enum lru_list lru;
22482247

@@ -2301,17 +2300,22 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc,
23012300
* the relative IO cost of bringing back a swapped out
23022301
* anonymous page vs reloading a filesystem page (swappiness).
23032302
*
2303+
* Although we limit that influence to ensure no list gets
2304+
* left behind completely: at least a third of the pressure is
2305+
* applied, before swappiness.
2306+
*
23042307
* With swappiness at 100, anon and file have equal IO cost.
23052308
*/
2306-
anon_prio = swappiness;
2307-
file_prio = 200 - anon_prio;
2309+
total_cost = sc->anon_cost + sc->file_cost;
2310+
anon_cost = total_cost + sc->anon_cost;
2311+
file_cost = total_cost + sc->file_cost;
2312+
total_cost = anon_cost + file_cost;
23082313

2309-
totalcost = sc->anon_cost + sc->file_cost;
2310-
ap = anon_prio * (totalcost + 1);
2311-
ap /= sc->anon_cost + 1;
2314+
ap = swappiness * (total_cost + 1);
2315+
ap /= anon_cost + 1;
23122316

2313-
fp = file_prio * (totalcost + 1);
2314-
fp /= sc->file_cost + 1;
2317+
fp = (200 - swappiness) * (total_cost + 1);
2318+
fp /= file_cost + 1;
23152319

23162320
fraction[0] = ap;
23172321
fraction[1] = fp;

0 commit comments

Comments
 (0)