Re: [PATCH memcg 0/1] false global OOM triggered by memcg-limited task
From: Vasily Averin <hidden>
Date: 2021-10-19 06:30:49
Also in:
linux-mm, lkml
On 18.10.2021 14:53, Michal Hocko wrote:
On Mon 18-10-21 13:05:35, Vasily Averin wrote:quoted
On 18.10.2021 12:04, Michal Hocko wrote:quoted
On Mon 18-10-21 11:13:52, Vasily Averin wrote: [...]quoted
How could this happen? User-space task inside the memcg-limited container generated a page fault, its handler do_user_addr_fault() called handle_mm_fault which could not allocate the page due to exceeding the memcg limit and returned VM_FAULT_OOM. Then do_user_addr_fault() called pagefault_out_of_memory() which executed out_of_memory() without set of memcg. Partially this problem depends on one of my recent patches, disabled unlimited memory allocation for dying tasks. However I think the problem can happen on non-killed tasks too, for example because of kmem limit.Could you be more specific on how this can happen without your patch? I have to say I haven't realized this side effect when discussing it.
quoted
If required I can try to search how try_charge_memcg() can reject page allocation of non-dying task too.Yes.
Now I think that such failure was very unlikely (w/o my patch and kmem limit).
I cannot exclude it completely, because I did not finished this review and perhaps I missed something,
but I checked most part of code and found nothing.
With my patch ("memcg: prohibit unconditional exceeding the limit of dying tasks") try_charge_memcg() can fail:
a) due to fatal signal
b) when mem_cgroup_oom -> mem_cgroup_out_of_memory -> out_of_memory() returns false (when select_bad_process() found nothing)
To handle a) we can follow to your suggestion and skip excution of out_of_memory() in pagefault_out_of memory()
To handle b) we can go to retry: if mem_cgroup_oom() return OOM_FAILED.
However all these cases can be successfully handled by my new patch
"memcg: prevent false global OOM triggered by memcg limited task"
and I think it is better solution.
Thank you,
Vasily Averin