linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Juan Yescas <jyescas@google.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>,
	Kalesh Singh <kaleshsingh@google.com>,
	 "T.J. Mercier" <tjmercier@google.com>,
	Isaac Manjarres <isaacmanjarres@google.com>,
	 android-mm <android-mm@google.com>,
	Linux Memory Management List <linux-mm@kvack.org>,
	 Matthew Wilcox <willy@infradead.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	lsf-pc@lists.linux-foundation.org
Subject: Re: [LSF/MM/BPF TOPIC] Discussion: Targeted memory allocation via debugfs
Date: Wed, 8 Apr 2026 14:32:16 -0700	[thread overview]
Message-ID: <CAJDx_rjk-5pp5Z884bnTBss19Xk0msEayR=GAMG2wWCk+WOZ=A@mail.gmail.com> (raw)
In-Reply-To: <e63e0ab9-75bd-4a7f-9400-a8f87c80d1f0@kernel.org>

On Wed, Apr 8, 2026 at 12:47 AM David Hildenbrand (Arm)
<david@kernel.org> wrote:
>
> On 4/8/26 02:12, Juan Yescas wrote:
> > On Mon, Mar 23, 2026 at 2:14 AM David Hildenbrand (Arm)
> > <david@kernel.org> wrote:
> >>
> >> On 3/19/26 01:56, Juan Yescas wrote:
> >>> Thanks David for you comments,
> >>>
> >>>
> >>> On Mon, Mar 16, 2026 at 8:52 AM David Hildenbrand (Arm)
> >>> <david@kernel.org> wrote:
> >>> You’re right that going OOT would bypass the strict API stability and
> >>> extensibility requirements that come with being in-tree.
> >>>
> >>> However, there are some symbols that we would need to be exported in
> >>> order for the module to compile.
> >>
> >> Reason I am asking is because we had similar discussions around memory
> >> hot(un)plug in the past, where we decided that an OOT kernel module to
> >> simulate add/remove was a better choice than exposing weird APIs to user
> >> space.
> >>
> >
> > Hi David, I apologize for the late reply. It’s been a bit of a
> > whirlwind over here with some internal issues.
> >
> >> Which symbols would you need?
> >
> > These are the required symbols:
> >
> > ERROR: modpost: "cma_alloc" [page_alloc_debugfs.ko] undefined!
>
> cma_alloc() will be exported soon:
>
> https://lore.kernel.org/r/20260331-dma-buf-heaps-as-modules-v4-5-e18fda504419@kernel.org
>

Excellent, cma_alloc() and cma_release() will come in handy for this usecase :)

>
> > ERROR: modpost: "migratetype_names" [page_alloc_debugfs.ko] undefined!
>
> I'd assume that you can work around that?
>

That's true, we can just hardcode the strings.

> >
> >  > I guess we'd want to call the buddy by
> >> specifying node+zone+order.
> >>
> > That's correct, for the no cma allocations we'll call "alloc_pages_node_noprof"
> >
> >> Is specifying the migratetype really relevant?
> >>
> >
> > Yes, we want to be able to allocate these types of memory:
> >
> > MIGRATE_MOVABLE,
> > MIGRATE_RECLAIMABLE,
> > MIGRATE_CMA,
> >
> > When the request is for MIGRATE_CMA, the "default_cma_region" will be
> > used for that allocation.
> >
> >>>
> >>>
> >>> Yes, that is actually one of our goals. We often encounter
> >>> "heisenbugs" that only manifest
> >>> under specific workloads and we want the ability to stress the memory subystem.
> >>>
> >>> For example, if we want to increase the unmovable allocations by 16 MiB,
> >>> a 4 KiB kernel, we can do
> >>>
> >>> $ for i in {1..4} \
> >>> do  \
> >>>   echo 1 > /sys/kernel/debug/mm/node-1/zone-Normal/order-10/migrate-Unmovable/alloc
> >>
> >> How will we handle unmovable allocations ending up on movable memory
> >> (e.g., ZONE_MOVABLE)? (e.g., allocating from ZONE_MOVABLE)
> >>
> >
> > Once the allocation is requested using
> >
> > echo 1 > /sys/kernel/debug/mm/node-1/zone-Normal/order-10/migrate-Umovable/alloc
> >
> > We don't care whether the allocation comes from movable/cma memory.
>
> Well, you should.
>
> If you end up doing something like
>
> echo 1 >
> /sys/kernel/debug/mm/node-1/zone-movable/order-10/migrate-Movable/alloc
>
> You are just breaking ZONE_MOVABLE guarantees. Or what am I missing?

I see. How should the ZONE_MOVABLE allocations be handled? Should they
be excluded?

>
> >
> >> Also, is there any reason why we can't do it similar to hugetlb and use
> >> a simple "nr_pages" variable, that can be set and read.
> >>
> >
> > We could use a "nr_pages" variable, but we would also need to set the
> > node, zone and migrate type.
> >
> > It would be cumbersome and error prone to have something like this:
> >
> > echo "Node1/zone-Normal/MIGRATE_RECLAIMABLE/8" > /proc/kernel/debug/mm/nr_pages
>
> I meant something like:
>
> echo 1 >
> /sys/kernel/debug/mm/node-1/zone-Normal/order-10/migrate-Umovable/nr_pages

Got it, we can do something like that. It makes more sense.

>
> (not sure if we really want to specify the migratetype)
>

The migrate type is important because we want to make both MIGRATE_CMA
and MIGRATE_RECLAIMABLE allocations.

Thanks David for your comments.

> --
> Cheers,
>
> David


      reply	other threads:[~2026-04-08 21:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-27  2:42 Juan Yescas
2026-03-16 15:52 ` David Hildenbrand (Arm)
2026-03-19  0:56   ` Juan Yescas
2026-03-23  9:14     ` David Hildenbrand (Arm)
2026-04-08  0:12       ` Juan Yescas
2026-04-08  7:47         ` David Hildenbrand (Arm)
2026-04-08 21:32           ` Juan Yescas [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='CAJDx_rjk-5pp5Z884bnTBss19Xk0msEayR=GAMG2wWCk+WOZ=A@mail.gmail.com' \
    --to=jyescas@google.com \
    --cc=android-mm@google.com \
    --cc=david@kernel.org \
    --cc=isaacmanjarres@google.com \
    --cc=kaleshsingh@google.com \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=lsf-pc@lists.linux-foundation.org \
    --cc=surenb@google.com \
    --cc=tjmercier@google.com \
    --cc=vbabka@suse.cz \
    --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