linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Yu Zhao <yuzhao@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Muchun Song <muchun.song@linux.dev>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
	Zi Yan <ziy@nvidia.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH mm-unstable v2 1/3] mm/contig_alloc: support __GFP_COMP
Date: Tue, 19 Nov 2024 16:29:06 +0100	[thread overview]
Message-ID: <402ff3e5-4fca-4452-97ba-5b1ec4a6eeb1@redhat.com> (raw)
In-Reply-To: <20240814035451.773331-2-yuzhao@google.com>

> +/* Split a multi-block free page into its individual pageblocks. */
> +static void split_large_buddy(struct zone *zone, struct page *page,
> +			      unsigned long pfn, int order, fpi_t fpi)
> +{
> +	unsigned long end = pfn + (1 << order);
> +
> +	VM_WARN_ON_ONCE(!IS_ALIGNED(pfn, 1 << order));
> +	/* Caller removed page from freelist, buddy info cleared! */
> +	VM_WARN_ON_ONCE(PageBuddy(page));
> +
> +	if (order > pageblock_order)
> +		order = pageblock_order;
> +
> +	while (pfn != end) {
> +		int mt = get_pfnblock_migratetype(page, pfn);
> +
> +		__free_one_page(page, pfn, zone, order, mt, fpi);
> +		pfn += 1 << order;
> +		page = pfn_to_page(pfn);
> +	}
> +}

Hi,

stumbling over this while digging through the code ....

> +
>   static void free_one_page(struct zone *zone, struct page *page,
>   			  unsigned long pfn, unsigned int order,
>   			  fpi_t fpi_flags)
>   {
>   	unsigned long flags;
> -	int migratetype;
>   
>   	spin_lock_irqsave(&zone->lock, flags);
> -	migratetype = get_pfnblock_migratetype(page, pfn);
> -	__free_one_page(page, pfn, zone, order, migratetype, fpi_flags);

This change is rather undesired:

via __free_pages_core()->__free_pages_ok() we can easily end up here 
with order=MAX_PAGE_ORDER.

What your new code will do is split this perfectly reasonable 
MAX_PAGE_ORDER chunk via split_large_buddy() into pageblock-sized 
chunks, and let the buddy merging logic undo our unnecessary splitting.

Is there a way to avoid this and just process the whole MAX_PAGE_ORDER 
chunk like we used to?

-- 
Cheers,

David / dhildenb



  parent reply	other threads:[~2024-11-19 15:29 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-14  3:54 [PATCH mm-unstable v2 0/3] mm/hugetlb: alloc/free gigantic folios Yu Zhao
2024-08-14  3:54 ` [PATCH mm-unstable v2 1/3] mm/contig_alloc: support __GFP_COMP Yu Zhao
2024-08-22  8:21   ` Yu Liao
2024-08-22 17:25     ` Yu Zhao
2024-08-22 18:36     ` Andrew Morton
2024-08-22 17:23   ` Yu Zhao
2024-08-22 18:42     ` Matthew Wilcox
2024-09-02 17:02       ` Yu Zhao
2024-11-19 15:29   ` David Hildenbrand [this message]
2024-11-19 16:12     ` Zi Yan
2024-11-19 16:25       ` David Hildenbrand
2024-11-19 16:31       ` David Hildenbrand
2024-11-19 16:41         ` Zi Yan
2024-11-19 16:49           ` David Hildenbrand
2024-11-19 16:52             ` David Hildenbrand
2024-11-20 15:55               ` Zi Yan
2024-11-20 16:13                 ` David Hildenbrand
2024-11-20 16:46                   ` Zi Yan
2024-08-14  3:54 ` [PATCH mm-unstable v2 2/3] mm/cma: add cma_{alloc,free}_folio() Yu Zhao
2024-08-22 17:24   ` Yu Zhao
2024-09-02 17:04     ` Yu Zhao
2024-08-14  3:54 ` [PATCH mm-unstable v2 3/3] mm/hugetlb: use __GFP_COMP for gigantic folios Yu Zhao
2024-08-16 15:23   ` Zi Yan
2024-08-16 16:02     ` Yu Zhao
2024-08-16 16:30       ` Zi Yan
2024-08-30 17:55 ` [PATCH mm-unstable v2 0/3] mm/hugetlb: alloc/free " jane.chu

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=402ff3e5-4fca-4452-97ba-5b1ec4a6eeb1@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    --cc=ziy@nvidia.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