[Devel] [PATCH RHEL7 COMMIT] cgroup_freezer: fix memory allocation context when checking freeze timeouts

Konstantin Khorenko khorenko at virtuozzo.com
Tue Sep 5 19:00:58 MSK 2023


The commit is pushed to "branch-rh7-3.10.0-1160.99.1.vz7.211.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1160.99.1.vz7.211.1
------>
commit cc4f26d75e24dfe70f62795e9e0f46dd022751d3
Author: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
Date:   Fri Sep 1 15:44:59 2023 +0300

    cgroup_freezer: fix memory allocation context when checking freeze timeouts
    
    check_freezer_timeout(...) is called under spin_lock_irq(...) from
    update_if_frozen(...) the issue is that it does allocations under GFP_KERNEL
    context - fix that by using GFP_ATOMIC.
    
    Fixes: aab9c2fafb6b ("cgroup_freezer: print information about unfreezable process")
    https://jira.vzint.dev/browse/PSBM-150293
    
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 kernel/cgroup_freezer.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c
index d4747ff98090..e5da9a63813d 100644
--- a/kernel/cgroup_freezer.c
+++ b/kernel/cgroup_freezer.c
@@ -269,7 +269,7 @@ static void check_freezer_timeout(struct cgroup *cgroup,
 	if (!__ratelimit(&freeze_timeout_rs))
 		return;
 
-	freezer_cg_name = kmalloc(PATH_MAX, GFP_KERNEL);
+	freezer_cg_name = kmalloc(PATH_MAX, GFP_ATOMIC);
 	if (!freezer_cg_name)
 		return;
 
@@ -283,7 +283,7 @@ static void check_freezer_timeout(struct cgroup *cgroup,
 	       freezer_cg_name, __freeze_timeout/HZ, tgid, task->comm);
 
 	entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries),
-			  GFP_KERNEL);
+			  GFP_ATOMIC);
 	if (!entries)
 		goto free_cg_name;
 


More information about the Devel mailing list