[Devel] [PATCH rh7] mm/filemap: fix potential memcg->cache charge leak

Vasily Averin vvs at virtuozzo.com
Fri Oct 9 10:14:15 MSK 2020


vz8 is affected too, please cherry-pick 
vz7 commit 79a5642e9d9a6bdbb56d9e0ee990fd96b7c8625c

On 10/8/20 1:10 PM, Andrey Ryabinin wrote:
> __add_to_page_cache_locked() after mem_cgroup_try_charge_cache()
> uses mem_cgroup_cancel_charge() in one of the error paths.
> This may lead to leaking a few memcg->cache charges.
> 
> Use mem_cgroup_cancel_cache_charge() to fix this.
> 
> https://jira.sw.ru/browse/PSBM-121046
> Signed-off-by: Andrey Ryabinin <aryabinin at virtuozzo.com>
> ---
>  mm/filemap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 53db13f236da..2bd5ca4e7528 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -732,7 +732,7 @@ static int __add_to_page_cache_locked(struct page *page,
>  	error = radix_tree_maybe_preload(gfp_mask & GFP_RECLAIM_MASK);
>  	if (error) {
>  		if (!huge)
> -			mem_cgroup_cancel_charge(page, memcg);
> +			mem_cgroup_cancel_cache_charge(page, memcg);
>  		return error;
>  	}
>  
> 


More information about the Devel mailing list