lkml.org 
[lkml]   [2021]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] mm/filemap: Adding missing mem_cgroup_uncharge() to __add_to_page_cache_locked()
On Sun, Jan 24, 2021 at 11:24:41PM -0500, Waiman Long wrote:
> diff --git a/mm/filemap.c b/mm/filemap.c
> index 5c9d564317a5..aa0e0fb04670 100644
> --- a/mm/filemap.c
> +++ b/mm/filemap.c
> @@ -835,6 +835,7 @@ noinline int __add_to_page_cache_locked(struct page *page,
> XA_STATE(xas, &mapping->i_pages, offset);
> int huge = PageHuge(page);
> int error;
> + bool charged = false;

I don't think we need this extra bool.

> @@ -896,6 +898,8 @@ noinline int __add_to_page_cache_locked(struct page *page,
>
> if (xas_error(&xas)) {
> error = xas_error(&xas);
> + if (charged)
> + mem_cgroup_uncharge(page);
> goto error;
> }

Better:

- goto error;
+ goto uncharge;
...
+uncharge:
+ if (!huge)
+ mem_cgroup_uncharge(page);
error:
...

\
 
 \ /
  Last update: 2021-01-25 05:40    [W:0.189 / U:1.516 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site