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 <[email protected]>
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 <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>
(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 <[email protected]>
---
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;
}
_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel