We will want to call calculate_high_delay() twice - once for memory and once for swap, and we should apply the clamp value to sum of the penalties. Clamping has to be applied outside of calculate_high_delay().
Unified · Split
| @@ -2386,14 +2386,7 @@ static unsigned long calculate_high_delay(struct mem_cgroup *memcg, · 2385 unmodified lines | |||
| 2386 | * MEMCG_CHARGE_BATCH pages is nominal, so work out how much smaller or | 2386 | * MEMCG_CHARGE_BATCH pages is nominal, so work out how much smaller or |
| 2387 | * larger the current charge patch is than that. | 2387 | * larger the current charge patch is than that. |
| 2388 | */ | 2388 | */ |
| 2389 | penalty_jiffies = penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH; | 2389 | return penalty_jiffies * nr_pages / MEMCG_CHARGE_BATCH; |
| 2390 | |||
| 2391 | /* | ||
| 2392 | * Clamp the max delay per usermode return so as to still keep the | ||
| 2393 | * application moving forwards and also permit diagnostics, albeit | ||
| 2394 | * extremely slowly. | ||
| 2395 | */ | ||
| 2396 | return min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES); | ||
| 2397 | } | 2390 | } |
| 2398 | 2391 | ||
| 2399 | /* | 2392 | /* |
| @@ -2421,6 +2414,13 @@ void mem_cgroup_handle_over_high(void) · 21 unmodified lines | |||
| 2421 | penalty_jiffies = calculate_high_delay(memcg, nr_pages, | 2414 | penalty_jiffies = calculate_high_delay(memcg, nr_pages, |
| 2422 | mem_find_max_overage(memcg)); | 2415 | mem_find_max_overage(memcg)); |
| 2423 | 2416 | ||
| 2417 | /* | ||
| 2418 | * Clamp the max delay per usermode return so as to still keep the | ||
| 2419 | * application moving forwards and also permit diagnostics, albeit | ||
| 2420 | * extremely slowly. | ||
| 2421 | */ | ||
| 2422 | penalty_jiffies = min(penalty_jiffies, MEMCG_MAX_HIGH_DELAY_JIFFIES); | ||
| 2423 | |||
| 2424 | /* | 2424 | /* |
| 2425 | * Don't sleep if the amount of jiffies this memcg owes us is so low | 2425 | * Don't sleep if the amount of jiffies this memcg owes us is so low |
| 2426 | * that it's not even worth doing, in an attempt to be nice to those who | 2426 | * that it's not even worth doing, in an attempt to be nice to those who |