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

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Mon Sep 4 07:06:53 MSK 2023


Thanks for fixing this!

On 01.09.2023 20:44, Alexander Atanasov wrote:
> 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

Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>

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

-- 
Best regards, Tikhomirov Pavel
Senior Software Developer, Virtuozzo.


More information about the Devel mailing list