linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tarun Sahu <tsahu@linux.ibm.com>
To: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	akpm@linux-foundation.org, songmuchun@bytedance.com,
	mike.kravetz@oracle.com, willy@infradead.org,
	almasrymina@google.com, linmiaohe@huawei.com, hughd@google.com
Subject: Re: [PATCH mm-unstable v3 06/10] mm/hugetlb: convert add_hugetlb_page() to folios and add hugetlb_cma_folio()
Date: Sun, 20 Nov 2022 00:29:50 +0530	[thread overview]
Message-ID: <20221119185950.nko3aki3gvh4zu64@tarunpc> (raw)
In-Reply-To: <20221117211501.17150-7-sidhartha.kumar@oracle.com>

Hi,
Though it is already merged, it is just comment thing.

On Nov 17 2022, Sidhartha Kumar wrote:
> Convert add_hugetlb_page() to take in a folio, also convert
> hugetlb_cma_page() to take in a folio.
> 
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
> ---
>  mm/hugetlb.c | 40 ++++++++++++++++++++--------------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 80301fab56d8..bf36aa8e6072 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -54,13 +54,13 @@ struct hstate hstates[HUGE_MAX_HSTATE];
>  #ifdef CONFIG_CMA
>  static struct cma *hugetlb_cma[MAX_NUMNODES];
>  static unsigned long hugetlb_cma_size_in_node[MAX_NUMNODES] __initdata;
> -static bool hugetlb_cma_page(struct page *page, unsigned int order)
> +static bool hugetlb_cma_folio(struct folio *folio, unsigned int order)
>  {
> -	return cma_pages_valid(hugetlb_cma[page_to_nid(page)], page,
> +	return cma_pages_valid(hugetlb_cma[folio_nid(folio)], &folio->page,
>  				1 << order);
>  }
>  #else
> -static bool hugetlb_cma_page(struct page *page, unsigned int order)
> +static bool hugetlb_cma_folio(struct folio *folio, unsigned int order)
>  {
>  	return false;
>  }
> @@ -1506,17 +1506,17 @@ static void remove_hugetlb_folio_for_demote(struct hstate *h, struct folio *foli
>  	__remove_hugetlb_folio(h, folio, adjust_surplus, true);
>  }
>  
> -static void add_hugetlb_page(struct hstate *h, struct page *page,
> +static void add_hugetlb_folio(struct hstate *h, struct folio *folio,
>  			     bool adjust_surplus)
>  {
>  	int zeroed;
> -	int nid = page_to_nid(page);
> +	int nid = folio_nid(folio);
>  
> -	VM_BUG_ON_PAGE(!HPageVmemmapOptimized(page), page);
> +	VM_BUG_ON_FOLIO(!folio_test_hugetlb_vmemmap_optimized(folio), folio);
>  
>  	lockdep_assert_held(&hugetlb_lock);
>  
> -	INIT_LIST_HEAD(&page->lru);
> +	INIT_LIST_HEAD(&folio->lru);
>  	h->nr_huge_pages++;
>  	h->nr_huge_pages_node[nid]++;
>  
> @@ -1525,21 +1525,21 @@ static void add_hugetlb_page(struct hstate *h, struct page *page,
>  		h->surplus_huge_pages_node[nid]++;
>  	}
>  
> -	set_compound_page_dtor(page, HUGETLB_PAGE_DTOR);
> -	set_page_private(page, 0);
> +	folio_set_compound_dtor(folio, HUGETLB_PAGE_DTOR);
> +	folio_change_private(folio, 0);
>  	/*
>  	 * We have to set HPageVmemmapOptimized again as above
                           ^
This can be changed to folio version of itself.

> -	 * set_page_private(page, 0) cleared it.
> +	 * folio_change_private(folio, 0) cleared it.
>  	 */
> -	SetHPageVmemmapOptimized(page);
> +	folio_set_hugetlb_vmemmap_optimized(folio);
>  
>  	/*
> -	 * This page is about to be managed by the hugetlb allocator and
> +	 * This folio is about to be managed by the hugetlb allocator and
>  	 * should have no users.  Drop our reference, and check for others
>  	 * just in case.
>  	 */
> -	zeroed = put_page_testzero(page);
> -	if (!zeroed)
> +	zeroed = folio_put_testzero(folio);
> +	if (unlikely(!zeroed))
>  		/*
>  		 * It is VERY unlikely soneone else has taken a ref on
>  		 * the page.  In this case, we simply return as the
> @@ -1548,8 +1548,8 @@ static void add_hugetlb_page(struct hstate *h, struct page *page,
>  		 */
>  		return;
>  
> -	arch_clear_hugepage_flags(page);
> -	enqueue_huge_page(h, page);
> +	arch_clear_hugepage_flags(&folio->page);
> +	enqueue_huge_page(h, &folio->page);
>  }
>  
>  static void __update_and_free_page(struct hstate *h, struct page *page)
> @@ -1575,7 +1575,7 @@ static void __update_and_free_page(struct hstate *h, struct page *page)
>  		 * page and put the page back on the hugetlb free list and treat
>  		 * as a surplus page.
>  		 */
> -		add_hugetlb_page(h, page, true);
> +		add_hugetlb_folio(h, page_folio(page), true);
>  		spin_unlock_irq(&hugetlb_lock);
>  		return;
>  	}
> @@ -1600,7 +1600,7 @@ static void __update_and_free_page(struct hstate *h, struct page *page)
>  	 * need to be given back to CMA in free_gigantic_page.
>  	 */
>  	if (hstate_is_gigantic(h) ||
> -	    hugetlb_cma_page(page, huge_page_order(h))) {
> +	    hugetlb_cma_folio(folio, huge_page_order(h))) {
>  		destroy_compound_gigantic_folio(folio, huge_page_order(h));
>  		free_gigantic_page(page, huge_page_order(h));
>  	} else {
> @@ -2184,7 +2184,7 @@ int dissolve_free_huge_page(struct page *page)
>  			update_and_free_hugetlb_folio(h, folio, false);
>  		} else {
>  			spin_lock_irq(&hugetlb_lock);
> -			add_hugetlb_page(h, &folio->page, false);
> +			add_hugetlb_folio(h, folio, false);
>  			h->max_huge_pages++;
>  			spin_unlock_irq(&hugetlb_lock);
>  		}
> @@ -3451,7 +3451,7 @@ static int demote_free_huge_page(struct hstate *h, struct page *page)
>  		/* Allocation of vmemmmap failed, we can not demote page */
>  		spin_lock_irq(&hugetlb_lock);
>  		set_page_refcounted(page);
> -		add_hugetlb_page(h, page, false);
> +		add_hugetlb_folio(h, page_folio(page), false);
>  		return rc;
>  	}
>  
> -- 
> 2.38.1
> 


  reply	other threads:[~2022-11-19 19:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-17 21:14 [PATCH mm-unstable v3 00/10] convert core hugetlb functions to folios Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 01/10] mm: add folio dtor and order setter functions Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 02/10] mm/hugetlb: convert destroy_compound_gigantic_page() to folios Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 03/10] mm/hugetlb: convert dissolve_free_huge_page() " Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 04/10] mm/hugetlb: convert remove_hugetlb_page() " Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 05/10] mm/hugetlb: convert update_and_free_page() " Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 06/10] mm/hugetlb: convert add_hugetlb_page() to folios and add hugetlb_cma_folio() Sidhartha Kumar
2022-11-19 18:59   ` Tarun Sahu [this message]
2022-11-21 15:22     ` Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 07/10] mm/hugetlb: convert enqueue_huge_page() to folios Sidhartha Kumar
2022-11-17 21:14 ` [PATCH mm-unstable v3 08/10] mm/hugetlb: convert free_gigantic_page() " Sidhartha Kumar
2022-11-17 21:15 ` [PATCH mm-unstable v3 09/10] mm/hugetlb: convert hugetlb prep functions " Sidhartha Kumar
2022-11-17 21:15 ` [PATCH mm-unstable v3 10/10] mm/hugetlb: change hugetlb allocation functions to return a folio Sidhartha Kumar

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=20221119185950.nko3aki3gvh4zu64@tarunpc \
    --to=tsahu@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=almasrymina@google.com \
    --cc=hughd@google.com \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.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