Johannes Weiner 9317d0fffe mm: page_counter: mitigate consequences of a page_counter underflow
When the unsigned page_counter underflows, even just by a few pages, a
cgroup will not be able to run anything afterwards and trigger the OOM
killer in a loop.

Underflows shouldn't happen, but when they do in practice, we may just be
off by a small amount that doesn't interfere with the normal operation -
consequences don't need to be that dire.

Reset the page_counter to 0 upon underflow.  We'll issue a warning that
the accounting will be off and then try to keep limping along.

[ We used to do this with the original res_counter, where it was a
  more straight-forward correction inside the spinlock section. I
  didn't carry it forward into the lockless page counters for
  simplicity, but it turns out this is quite useful in practice. ]

Link: https://lkml.kernel.org/r/20210408143155.2679744-1-hannes@cmpxchg.org
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Chris Down <chris@chrisdown.name>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2021-04-30 11:20:38 -07:00
..
2021-04-26 10:25:03 -07:00
2021-02-26 09:41:00 -08:00
2021-02-24 13:38:27 -08:00
2021-02-26 09:41:01 -08:00
2021-04-30 11:20:37 -07:00
2021-04-30 11:20:37 -07:00
2021-04-27 13:08:12 -07:00
2021-04-06 09:28:17 -06:00
2021-04-30 11:20:36 -07:00
2020-12-15 12:13:47 -08:00
2021-03-02 17:25:46 -07:00
2021-04-16 16:10:37 -07:00
2021-04-28 12:00:13 -07:00
2021-04-30 11:20:36 -07:00
2021-02-26 09:40:59 -08:00
2021-02-26 09:40:59 -08:00
2021-04-30 11:20:37 -07:00