From: Yang Shi <shy828301@gmail.com>
To: Peter Xu <peterx@redhat.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
David Stevens <stevensd@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
Johannes Weiner <hannes@cmpxchg.org>,
"Zach O'Keefe" <zokeefe@google.com>
Subject: Re: [PATCH] mm/khugepaged: Cleanup memcg uncharge for failure path
Date: Fri, 3 Mar 2023 11:00:24 -0800 [thread overview]
Message-ID: <CAHbLzkog36Ch2Ys8+ZOjbpug68p5XLjt-0Mc1TBVuNAirqRW+A@mail.gmail.com> (raw)
In-Reply-To: <20230303151218.311015-1-peterx@redhat.com>
On Fri, Mar 3, 2023 at 7:12 AM Peter Xu <peterx@redhat.com> wrote:
>
> Explicit memcg uncharging is not needed when the memcg accounting has the
> same lifespan of the page/folio. That becomes the case for khugepaged
> after Yang & Zach's recent rework so the hpage will be allocated for each
> collapse rather than being cached.
>
> Cleanup the explicit memcg uncharge in khugepaged failure path and leave
> that for put_page().
Thanks for the cleanup. Reviewed-by: Yang Shi <shy828301@gmail.com>
>
> Suggested-by: Zach O'Keefe <zokeefe@google.com>
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
> mm/khugepaged.c | 8 ++------
> 1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/mm/khugepaged.c b/mm/khugepaged.c
> index 941d1c7ea910..dd5a7d9bc593 100644
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -1230,10 +1230,8 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address,
> out_up_write:
> mmap_write_unlock(mm);
> out_nolock:
> - if (hpage) {
> - mem_cgroup_uncharge(page_folio(hpage));
> + if (hpage)
> put_page(hpage);
> - }
> trace_mm_collapse_huge_page(mm, result == SCAN_SUCCEED, result);
> return result;
> }
> @@ -2250,10 +2248,8 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr,
> unlock_page(hpage);
> out:
> VM_BUG_ON(!list_empty(&pagelist));
> - if (hpage) {
> - mem_cgroup_uncharge(page_folio(hpage));
> + if (hpage)
> put_page(hpage);
> - }
>
> trace_mm_khugepaged_collapse_file(mm, hpage, index, is_shmem, addr, file, nr, result);
> return result;
> --
> 2.39.1
>
prev parent reply other threads:[~2023-03-03 19:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 15:12 Peter Xu
2023-03-03 15:22 ` Zach O'Keefe
2023-03-03 19:00 ` Yang Shi [this message]
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=CAHbLzkog36Ch2Ys8+ZOjbpug68p5XLjt-0Mc1TBVuNAirqRW+A@mail.gmail.com \
--to=shy828301@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=stevensd@chromium.org \
--cc=zokeefe@google.com \
/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