linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Waiman Long <longman@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Johannes Weiner <hannes@cmpxchg.org>,
	Alex Shi <alex.shi@linux.alibaba.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/filemap: Adding missing mem_cgroup_uncharge() to __add_to_page_cache_locked()
Date: Mon, 25 Jan 2021 09:09:26 -0500	[thread overview]
Message-ID: <1f234e4f-be0d-ecf9-7934-4be3de0d6fe5@redhat.com> (raw)
In-Reply-To: <20210125043631.GD308988@casper.infradead.org>

On 1/24/21 11:36 PM, Matthew Wilcox wrote:
> 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:
> ...
>
That was my original plan. After finding out there was a potentially 
conflicting patch in linux-next:

commit 7a02fa97b897 ("secretmem: add memcg accounting")

@@ -839,7 +840,7 @@ noinline int __add_to_page_cache_locked(struct page 
*page,
         page->mapping = mapping;
         page->index = offset;

-       if (!huge) {
+       if (!huge && !page_is_secretmem(page)) {
                 error = mem_cgroup_charge(page, current->mm, gfp);
                 if (error)
                         goto error;

Adding a boolean is an easy way out without conflicting it.

Cheers,
Longman



  parent reply	other threads:[~2021-01-25 14:09 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-25  4:24 Waiman Long
2021-01-25  4:36 ` Matthew Wilcox
2021-01-25  6:34   ` Miaohe Lin
2021-01-25 14:09   ` Waiman Long [this message]
2021-01-25  4:41 ` Alex Shi
2021-01-25  6:30 ` Miaohe Lin
2021-01-25 14:12   ` Waiman Long
2021-01-25 23:11     ` Andrew Morton
2021-01-25 23:13       ` Waiman Long
2021-01-25  8:07 ` Muchun Song
2021-01-25 15:35   ` Waiman Long
2021-01-25  9:28 ` Michal Hocko
2021-01-25 15:57   ` Waiman Long
2021-01-25 16:03     ` Michal Hocko
2021-01-25 16:25       ` Matthew Wilcox
2021-01-25 16:41         ` Michal Hocko
2021-01-25 18:14           ` Michal Hocko
2021-01-25 18:23             ` Waiman Long
2021-01-25 18:29               ` Matthew Wilcox
2021-01-25 18:45                 ` Waiman Long
2021-01-25 18:31               ` Michal Hocko
2021-01-25 18:52               ` Johannes Weiner
2021-01-25 18:57                 ` Waiman Long
2021-01-26  8:01                   ` Michal Hocko
2021-01-25 18:43           ` Johannes Weiner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f234e4f-be0d-ecf9-7934-4be3de0d6fe5@redhat.com \
    --to=longman@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.shi@linux.alibaba.com \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox