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

Alexander Atanasov alexander.atanasov at virtuozzo.com
Fri Sep 1 15:44:59 MSK 2023


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>
---
 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;
 
-- 
2.39.3



More information about the Devel mailing list