linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Muchun Song <muchun.song@linux.dev>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org,
	Linux Memory Management List <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <songmuchun@bytedance.com>,
	Mike Kravetz <mike.kravetz@oracle.com>,
	Matthew Wilcox <willy@infradead.org>,
	Mina Almasry <almasrymina@google.com>,
	linmiaohe@huawei.com, minhquangbui99@gmail.com,
	aneesh.kumar@linux.ibm.com
Subject: Re: [PATCH v2 7/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_uncharge_page() to folios
Date: Wed, 2 Nov 2022 14:56:48 +0800	[thread overview]
Message-ID: <C406644F-2DDF-4404-9D00-41199DE033DB@linux.dev> (raw)
In-Reply-To: <20221101223059.460937-8-sidhartha.kumar@oracle.com>



> On Nov 2, 2022, at 06:30, Sidhartha Kumar <sidhartha.kumar@oracle.com> wrote:
> 
> Continue to use a folio inside free_huge_page() by converting
> hugetlb_cgroup_uncharge_page*() to folios.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>


Reviewed-by: Muchun Song <songmuchun@bytedance.com>

A nit below.

> ---
> include/linux/hugetlb_cgroup.h | 16 ++++++++--------
> mm/hugetlb.c                   | 15 +++++++++------
> mm/hugetlb_cgroup.c            | 21 ++++++++++-----------
> 3 files changed, 27 insertions(+), 25 deletions(-)
> 
> diff --git a/include/linux/hugetlb_cgroup.h b/include/linux/hugetlb_cgroup.h
> index 789b6fef176d..c70f92fe493e 100644
> --- a/include/linux/hugetlb_cgroup.h
> +++ b/include/linux/hugetlb_cgroup.h
> @@ -158,10 +158,10 @@ extern void hugetlb_cgroup_commit_charge(int idx, unsigned long nr_pages,
> extern void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages,
>      struct hugetlb_cgroup *h_cg,
>      struct page *page);
> -extern void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
> - struct page *page);
> -extern void hugetlb_cgroup_uncharge_page_rsvd(int idx, unsigned long nr_pages,
> -      struct page *page);
> +extern void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages,
> + struct folio *folio);
> +extern void hugetlb_cgroup_uncharge_folio_rsvd(int idx, unsigned long nr_pages,
> +      struct folio *folio);
> 
> extern void hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
>   struct hugetlb_cgroup *h_cg);
> @@ -254,14 +254,14 @@ hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages,
> {
> }
> 
> -static inline void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
> - struct page *page)
> +static inline void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages,
> + struct folio *folio)
> {
> }
> 
> -static inline void hugetlb_cgroup_uncharge_page_rsvd(int idx,
> +static inline void hugetlb_cgroup_uncharge_folio_rsvd(int idx,
>     unsigned long nr_pages,
> -     struct page *page)
> +     struct folio *folio)
> {
> }
> static inline void hugetlb_cgroup_uncharge_cgroup(int idx,
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 387b8d74107d..2ecc0a6cf883 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1726,10 +1726,10 @@ void free_huge_page(struct page *page)
> 
> spin_lock_irqsave(&hugetlb_lock, flags);
> folio_clear_hugetlb_migratable(folio);
> - hugetlb_cgroup_uncharge_page(hstate_index(h),
> -     pages_per_huge_page(h), page);
> - hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h),
> -  pages_per_huge_page(h), page);
> + hugetlb_cgroup_uncharge_folio(hstate_index(h),
> +     pages_per_huge_page(h), folio);
> + hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h),
> +  pages_per_huge_page(h), folio);
> if (restore_reserve)
> h->resv_huge_pages++;
> 
> @@ -2855,6 +2855,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,
> struct hugepage_subpool *spool = subpool_vma(vma);
> struct hstate *h = hstate_vma(vma);
> struct page *page;
> + struct folio *folio;
> long map_chg, map_commit;
> long gbl_chg;
> int ret, idx;
> @@ -2918,6 +2919,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,
> * a reservation exists for the allocation.
> */
> page = dequeue_huge_page_vma(h, vma, addr, avoid_reserve, gbl_chg);
> +

Redundant blank line.

> if (!page) {
> spin_unlock_irq(&hugetlb_lock);
> page = alloc_buddy_huge_page_with_mpol(h, vma, addr);
> @@ -2932,6 +2934,7 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,
> set_page_refcounted(page);
> /* Fall through */
> }
> + folio = page_folio(page);
> hugetlb_cgroup_commit_charge(idx, pages_per_huge_page(h), h_cg, page);
> /* If allocation is not consuming a reservation, also store the
> * hugetlb_cgroup pointer on the page.
> @@ -2961,8 +2964,8 @@ struct page *alloc_huge_page(struct vm_area_struct *vma,
> rsv_adjust = hugepage_subpool_put_pages(spool, 1);
> hugetlb_acct_memory(h, -rsv_adjust);
> if (deferred_reserve)
> - hugetlb_cgroup_uncharge_page_rsvd(hstate_index(h),
> - pages_per_huge_page(h), page);
> + hugetlb_cgroup_uncharge_folio_rsvd(hstate_index(h),
> + pages_per_huge_page(h), folio);
> }
> return page;
> 
> diff --git a/mm/hugetlb_cgroup.c b/mm/hugetlb_cgroup.c
> index 351ffb40261c..7793401acc12 100644
> --- a/mm/hugetlb_cgroup.c
> +++ b/mm/hugetlb_cgroup.c
> @@ -349,11 +349,10 @@ void hugetlb_cgroup_commit_charge_rsvd(int idx, unsigned long nr_pages,
> /*
>  * Should be called with hugetlb_lock held
>  */
> -static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
> -   struct page *page, bool rsvd)
> +static void __hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages,
> +   struct folio *folio, bool rsvd)
> {
> struct hugetlb_cgroup *h_cg;
> - struct folio *folio = page_folio(page);
> 
> if (hugetlb_cgroup_disabled())
> return;
> @@ -371,27 +370,27 @@ static void __hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
> css_put(&h_cg->css);
> else {
> unsigned long usage =
> - h_cg->nodeinfo[page_to_nid(page)]->usage[idx];
> + h_cg->nodeinfo[folio_nid(folio)]->usage[idx];
> /*
> * This write is not atomic due to fetching usage and writing
> * to it, but that's fine because we call this with
> * hugetlb_lock held anyway.
> */
> - WRITE_ONCE(h_cg->nodeinfo[page_to_nid(page)]->usage[idx],
> + WRITE_ONCE(h_cg->nodeinfo[folio_nid(folio)]->usage[idx],
>   usage - nr_pages);
> }
> }
> 
> -void hugetlb_cgroup_uncharge_page(int idx, unsigned long nr_pages,
> -  struct page *page)
> +void hugetlb_cgroup_uncharge_folio(int idx, unsigned long nr_pages,
> +  struct folio *folio)
> {
> - __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, false);
> + __hugetlb_cgroup_uncharge_folio(idx, nr_pages, folio, false);
> }
> 
> -void hugetlb_cgroup_uncharge_page_rsvd(int idx, unsigned long nr_pages,
> -       struct page *page)
> +void hugetlb_cgroup_uncharge_folio_rsvd(int idx, unsigned long nr_pages,
> +       struct folio *folio)
> {
> - __hugetlb_cgroup_uncharge_page(idx, nr_pages, page, true);
> + __hugetlb_cgroup_uncharge_folio(idx, nr_pages, folio, true);
> }
> 
> static void __hugetlb_cgroup_uncharge_cgroup(int idx, unsigned long nr_pages,
> -- 
> 2.31.1
> 
> 



  reply	other threads:[~2022-11-02  6:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 22:30 [PATCH v2 0/9] convert hugetlb_cgroup helper functions " Sidhartha Kumar
2022-11-01 22:30 ` [PATCH v2 1/9] mm/hugetlb_cgroup: convert __set_hugetlb_cgroup() " Sidhartha Kumar
2022-11-02  3:05   ` Muchun Song
2022-11-01 22:30 ` [PATCH v2 2/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_from_page() " Sidhartha Kumar
2022-11-02  6:25   ` Muchun Song
2022-11-01 22:30 ` [PATCH v2 3/9] mm/hugetlb_cgroup: convert set_hugetlb_cgroup*() " Sidhartha Kumar
2022-11-02  6:45   ` Muchun Song
2022-11-10  0:20     ` Sidhartha Kumar
2022-11-10  7:34       ` Muchun Song
2022-11-10 19:08   ` Mike Kravetz
2022-11-01 22:30 ` [PATCH v2 4/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_migrate " Sidhartha Kumar
2022-11-02  6:47   ` Muchun Song
2022-11-01 22:30 ` [PATCH v2 5/9] mm/hugetlb: convert isolate_or_dissolve_huge_page " Sidhartha Kumar
2022-11-02  6:48   ` Muchun Song
2023-06-12 17:41   ` Matthew Wilcox
2023-06-12 18:45     ` Sidhartha Kumar
2023-06-12 23:34     ` Mike Kravetz
2023-06-13 23:29       ` Mike Kravetz
2022-11-01 22:30 ` [PATCH v2 6/9] mm/hugetlb: convert free_huge_page " Sidhartha Kumar
2022-11-02  6:53   ` Muchun Song
2022-11-01 22:30 ` [PATCH v2 7/9] mm/hugetlb_cgroup: convert hugetlb_cgroup_uncharge_page() " Sidhartha Kumar
2022-11-02  6:56   ` Muchun Song [this message]
2022-11-01 22:30 ` [PATCH v2 8/9] mm/hugeltb_cgroup: convert hugetlb_cgroup_commit_charge*() " Sidhartha Kumar
2022-11-02  6:57   ` Muchun Song
2022-11-01 22:30 ` [PATCH v2 9/9] mm/hugetlb: convert move_hugetlb_state() " Sidhartha Kumar
2022-11-02  7:01   ` Muchun Song

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=C406644F-2DDF-4404-9D00-41199DE033DB@linux.dev \
    --to=muchun.song@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=aneesh.kumar@linux.ibm.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=minhquangbui99@gmail.com \
    --cc=sidhartha.kumar@oracle.com \
    --cc=songmuchun@bytedance.com \
    --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