[Devel] [PATCH RHEL8 COMMIT] vmalloc: cancel allocation for oom-killed tasks
Konstantin Khorenko
khorenko at virtuozzo.com
Fri Jun 11 20:13:10 MSK 2021
The commit is pushed to "branch-rh8-4.18.0-240.1.1.vz8.5.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-240.1.1.vz8.5.41
------>
commit c1508630a4b18b18944c3c307b92edf9d4135ad3
Author: Vasily Averin <vvs at virtuozzo.com>
Date: Fri Jun 11 20:13:10 2021 +0300
vmalloc: cancel allocation for oom-killed tasks
huge vmalloc allocation can trigger local memcg oom.
Currently it is ignored and can lead to global oom.
https://jira.sw.ru/browse/PSBM-108091
Signed-off-by: Vasily Averin <vvs at virtuozzo.com>
Reviewed-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
(cherry-picked from vz7 commit 2eb147cb3573 ("vmalloc: cancel allocation for
oom-killed tasks"))
https://jira.sw.ru/browse/PSBM-127856
Signed-off-by: Valeriy Vdovin <valeriy.vdovin at virtuozzo.com>
---
mm/vmalloc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index 67317fb29b64..05f871f44571 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -1762,6 +1762,11 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
for (i = 0; i < area->nr_pages; i++) {
struct page *page;
+ if (unlikely(test_thread_flag(TIF_MEMDIE))) {
+ area->nr_pages = i;
+ goto nofail;
+ }
+
if (node == NUMA_NO_NODE)
page = alloc_page(alloc_mask|highmem_mask);
else
@@ -1785,6 +1790,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask,
warn_alloc(gfp_mask, NULL,
"vmalloc: allocation failure, allocated %ld of %ld bytes",
(area->nr_pages*PAGE_SIZE), area->size);
+nofail:
vfree(area->addr);
return NULL;
}
More information about the Devel
mailing list