Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kiryl Shutsemau <kas@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 David Hildenbrand <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Lorenzo Stoakes <ljs@kernel.org>, Michal Hocko <mhocko@suse.com>,
	 Suren Baghdasaryan <surenb@google.com>,
	Vlastimil Babka <vbabka@kernel.org>,
	 linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 0/2] mm/cma: accept memory of CMA areas reserved with memblock_reserve()
Date: Thu, 29 Oct 2026 15:39:03 +0000	[thread overview]
Message-ID: <auNoZgOgoFElHYUt@thinkstation> (raw)
In-Reply-To: <auNgRT19droHmv3Y@kernel.org>

On Thu, Oct 29, 2026 at 05:03:33PM +0200, Mike Rapoport wrote:
> On Thu, Oct 29, 2026 at 01:17:06PM +0000, Kiryl Shutsemau wrote:
> > On Thu, Oct 29, 2026 at 02:40:21PM +0200, Mike Rapoport wrote:
> > > On Thu, Oct 29, 2026 at 12:27:23PM +0000, Kiryl Shutsemau wrote:
> > > > On Thu, Oct 29, 2026 at 12:18:36PM +0200, Mike Rapoport (Microsoft) wrote:
> > > > > Pages of allocated CMA areas are released to the buddy allocator with
> > > > > __free_pages(), which does not check for unaccepted memory.
> > > > > 
> > > > > This usually works because memblock accepts the memory it allocates.
> > > > > 
> > > > > However, multi-range CMA areas, used by hugetlb_cma, and fixed CMA areas
> > > > > requested with cma=<size>@<base> are reserved with memblock_reserve() and
> > > > > their memory is never accepted.
> > > > 
> > > > It feels like memblock_reserve() abuse, no?
> > > > 
> > > > crashkernel=size@base already uses memblock_phys_alloc_range() for this.
> > > > Should the fixed and multi-range CMA paths go through the allocation API
> > > > as well.
> > > 
> > > Fixed path already has the range, why would it use allocation APIs?
> > 
> > Having the range doesn't make it a reservation. Both paths take free
> > memory for the kernel's use, which is an allocation, and an allocation
> > has to be accepted. memblock_reserve() is for memory that is already in
> > use: kernel image, initrd, firmware tables. Using it for allocations
> > leaves acceptance to every caller, and both CMA paths missed it.
> 
> memblock_reserve() predates any allocation APIs and it is used to say "I
> know this memory is free, I'm taking it". So memory acceptance should have
> take it into account.
> 
> > If memblock_phys_alloc_range() is the wrong tool, let's add a
> > memblock_*alloc*() helper that takes the exact range and does the reserve
> > plus memblock_prep_allocation(), the way memblock_alloc_hugetlb() finishes
> > its own search. There is no search, so the multi-range path doesn't get
> > slower, and accept_memory() stays inside memblock.
> 
> A new helper that does reserve and accept makes sense, but let's do it on
> top and also audit other callers of memblock_reserve().

Fair enough. Feel free to use for this patchset:

Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>

-- 
  Kiryl Shutsemau / Kirill A. Shutemov


      reply	other threads:[~2026-10-29 15:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 10:18 [PATCH 0/2] mm/cma: accept memory of CMA areas reserved with memblock_reserve() Mike Rapoport (Microsoft)
2026-10-29 10:18 ` [PATCH 1/2] mm/cma: accept memory of multi-range CMA areas Mike Rapoport (Microsoft)
2026-10-29 10:52   ` Gupta, Pankaj
2026-10-29 12:19     ` Mike Rapoport
2026-10-29 10:18 ` [PATCH 2/2] mm/cma: accept memory of CMA areas reserved at a fixed address Mike Rapoport (Microsoft)
2026-10-29 12:27 ` [PATCH 0/2] mm/cma: accept memory of CMA areas reserved with memblock_reserve() Kiryl Shutsemau
2026-10-29 12:40   ` Mike Rapoport
2026-10-29 13:17     ` Kiryl Shutsemau
2026-10-29 15:03       ` Mike Rapoport
2026-10-29 15:39         ` Kiryl Shutsemau [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=auNoZgOgoFElHYUt@thinkstation \
    --to=kas@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rppt@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.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