The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
To: Juan Yescas <jyescas@google.com>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
	 "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	Vlastimil Babka <vbabka@suse.cz>,
	 Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	 Michal Hocko <mhocko@suse.com>,
	open list <linux-kernel@vger.kernel.org>,
	 "open list:MEMORY MANAGEMENT - CORE" <linux-mm@kvack.org>,
	android-mm@google.com, fvdl@google.com, tkjos@google.com,
	 minchan@google.com, dskiba@google.com
Subject: Re: [RFC PATCH 00/16] Page Alloc Hogger
Date: Fri, 31 Jul 2026 13:40:42 +0100	[thread overview]
Message-ID: <amyWt8XYlQJRJXmg@lucifer> (raw)
In-Reply-To: <CAJDx_rjNhiS+J9eDkQxPF6B=jJ-Evr-M7NNeS_QcG7XWNDoEYQ@mail.gmail.com>

On Tue, Jul 28, 2026 at 05:36:03PM -0700, Juan Yescas wrote:
> On Tue, Jul 28, 2026 at 12:29 PM David Hildenbrand (Arm)
> <david@kernel.org> wrote:
> >
> > On 7/23/26 09:47, Juan Yescas wrote:
> > > This patch series introduces the Page Alloc Hogger. The Page Alloc Hogger
> > > allows you to allocate memory pages from specific nodes, zones, migration
> > > types, and orders directly via debugfs. This provides key benefits for
> > > testing and debugging:
> >
> > Would it be feasible to carry this as an OOT debugging module? Would a lot of
> > symbols be missing to achieve that?
> >
>
> Thanks David for the comment.
>
> The only symbol that would be needed to have this module as OOT is
> "migratetype_names".

Hmm I could have sworn I replied to this :)

Anyway, I don't think there's any need to export this. It's not like we're going
to radically rename them, and you'd probably have to update your module anyway
if we added a new migratetype.

So this being wholly contained in a module with no core changes seems the best
way?

Cheers, Lorenzo

>
> However, although this module was originally designed to debug CMA
> issues, it can be
> easily used to debug issues in kswapd, direct reclaims, OOM killer,
> etc. We could even
> use this module to add kunit test cases.
>
> Let's take for example this case. We want to allocate Unmovable memory and check
> that the allocation came from Movable, as per the buddy allocator
> fallback mechanism.
> How can we do that in user space?
>
> $ cat /proc/pagetypeinfo
> Page block order: 9
> Pages per block:  512
>
> Free pages count per migrate type at order 0  1  2  3  4  5  6  7  8  9   10
> Node 0, zone    DMA, type   Unmovable      0  0  0  0  0  0  0  0  0  0    0
> Node 0, zone    DMA, type     Movable      1  1  1  0  1  1  2  2  1  3  732
> Node 0, zone    DMA, type Reclaimable      0  0  0  0  0  0  0  0  0  0    0
> Node 0, zone    DMA, type  HighAtomic      0  0  0  0  0  0  0  0  0  0    0
> Node 0, zone    DMA, type         CMA      0  0  0  0  0  0  0  0  0  1    7
> Node 0, zone    DMA, type     Isolate      0  0  0  0  0  0  0  0  0  0    0
> Node 0, zone Normal, type   Unmovable     13  7  0  1  0  0  1  0  1  0    0
> Node 0, zone Normal, type     Movable      1  1  1  1  1  1  1  0  1  1 1221
> Node 0, zone Normal, type Reclaimable      1  0  0  0  0  0  1  0  0  1    0
> Node 0, zone Normal, type  HighAtomic      0  0  0  0  0  0  0  0  0  0    0
> Node 0, zone Normal, type         CMA      0  0  0  0  0  0  0  0  0  1    7
> Node 0, zone Normal, type     Isolate      0  0  0  0  0  0  0  0  0  0    0
>
> // Allocate Unmovable memory (note that there are NO Unmovable pages,
> so the allocation will fall back from Movable)
> $ echo 1221 > /sys/kernel/debug/mm/node-0/zone-Normal/order-10/migrate-Unmovable/nr_pages_allocs
>
> $ cat /proc/pagetypeinfo
> Page block order: 9
> Pages per block:  512
>
> Free pages count per migrate type at order       0      1      2
> 3      4      5      6      7      8      9     10
> Node    0, zone      DMA, type    Unmovable      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone      DMA, type      Movable      1      1      1
> 0      1      1      2      2      1      3    701
> Node    0, zone      DMA, type  Reclaimable      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone      DMA, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone      DMA, type          CMA      0      0      0
> 0      0      0      0      0      0      1     31
> Node    0, zone      DMA, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type    Unmovable      1      0      0
> 1      1      1      1      1      1      0      0
> Node    0, zone   Normal, type      Movable      1      0      1
> 1      1      1      1      1      1      1      7
> Node    0, zone   Normal, type  Reclaimable      0      1      0
> 0      1      0      0      0      1      0      0
> Node    0, zone   Normal, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type          CMA      0      0      0
> 0      0      0      0      0      0      1      7
> Node    0, zone   Normal, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
>
> Number of blocks type     Unmovable      Movable  Reclaimable
> HighAtomic          CMA      Isolate
> Node 0, zone      DMA           14         1458            0
>  0           64            0
> Node 0, zone   Normal         2440          102            2
>  0           16            0
>
> // Now we want to test that Reclaimable memory allocations fall back
> from ZONE_DMA and Migrate Movable
>
> $ echo 600 > /sys/kernel/debug/mm/node-0/zone-Normal/order-10/migrate-Reclaimable/nr_pages_allocs
> # cat /proc/pagetypeinfo
> Page block order: 9
> Pages per block:  512
>
> Free pages count per migrate type at order       0      1      2
> 3      4      5      6      7      8      9     10
> Node    0, zone      DMA, type    Unmovable      0      0      0
> 0      0      1      1      0      0      1      0
> Node    0, zone      DMA, type      Movable      1      1      1
> 0      1      1      2      2      1      3     99
> Node    0, zone      DMA, type  Reclaimable      1      0      0
> 1      0      0      1      0      1      1      0
> Node    0, zone      DMA, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone      DMA, type          CMA      0      0      0
> 0      0      0      0      0      0      1     31
> Node    0, zone      DMA, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type    Unmovable      1      0      0
> 1      1      1      1      1      1      0      0
> Node    0, zone   Normal, type      Movable      0      0      0
> 1      0      0      1      0      1      0      7
> Node    0, zone   Normal, type  Reclaimable      0      1      0
> 0      1      0      0      0      1      0      0
> Node    0, zone   Normal, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type          CMA      0      0      0
> 0      0      0      0      0      0      1      7
> Node    0, zone   Normal, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
>
> Number of blocks type     Unmovable      Movable  Reclaimable
> HighAtomic          CMA      Isolate
> Node 0, zone      DMA           16          254         1202
>  0           64            0
> Node 0, zone   Normal         2440          102            2
>  0           16            0
>
> // Now, we want to free all the MIGRATE_UNMOVABLE allocations and
> sleep 1 second for every
> // allocation and see how the pages return to the MIGRATE_UNMOVABLE bucket:
>
> for i in `seq 1 1221`; do echo $i > /sys/kernel/debug/mm/free; sleep 10; done
>
> // in another console
>
> watch cat /proc/pagetypeinfo
>                             2026-07-29 00:28:49
>
> Page block order: 9
> Pages per block:  512
>
> Free pages count per migrate type at order       0      1      2
> 3      4      5      6      7      8      9     10
> Node    0, zone      DMA, type    Unmovable      0      0      0
> 0      0      1      1      0      0      1      0
> Node    0, zone      DMA, type      Movable      1      1      1
> 0      1      1      2      2      1      3     99
> Node    0, zone      DMA, type  Reclaimable      1      0      0
> 1      0      0      1      0      1      1      0
> Node    0, zone      DMA, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone      DMA, type          CMA      0      0      0
> 0      0      0      0      0      0      1     31
> Node    0, zone      DMA, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type    Unmovable      1      0      0
> 1      1      1      1      1      1      0    698
> Node    0, zone   Normal, type      Movable      1      0      0
> 1      0      0      0      0      1      0      7
> Node    0, zone   Normal, type  Reclaimable      0      1      0
> 0      1      0      0      0      1      0      0
> Node    0, zone   Normal, type   HighAtomic      0      0      0
> 0      0      0      0      0      0      0      0
> Node    0, zone   Normal, type          CMA      0      0      0
> 0      0      0      0      0      0      1      7
> Node    0, zone   Normal, type      Isolate      0      0      0
> 0      0      0      0      0      0      0      0
>
> Number of blocks type     Unmovable      Movable  Reclaimable
> HighAtomic          CMA      Isolate
> Node 0, zone      DMA           16          254         1202
>  0           64            0
> Node 0, zone   Normal         2440          102            2
>  0           16            0
>
> Achieving the same result in a user program is not as straightforward.
>
> The Page Alloc Hogger gives us the flexibility to allocate from any
> valid memory we desire.
>
> As I mentioned before, it allows us to test/check/analyze/generate:
>
> - kwapd triggers
> - direct reclaims
> - OOM killer
> - generate page fragmentation using simple scripts instead of complex programs
>
> Greetigns
>
> Juan
>
>
> > --
> > Cheers,
> >
> > David

--
Cheers, Lorenzo

  parent reply	other threads:[~2026-07-31 12:41 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  7:47 [RFC PATCH 00/16] Page Alloc Hogger Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 01/16] mm: Page Alloc Hogger module Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 02/16] mm: Define structs for allocation requests and store allocations Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 03/16] mm: Define the caches for the structs req_alloc and page_alloc Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 04/16] mm: Define function to create a dir for each online node Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 05/16] mm: Define function to create a dir for populated zone Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 06/16] mm: Define function to create a dir for each page order Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 07/16] mm: Define function to create a dir for each migrate type Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 08/16] mm: Define function that creates the "nr_pages_allocs" file Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 09/16] mm: Read the nr_pages_allocs value given by user Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 10/16] mm: Set the selected zone in gfp_t flags Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 11/16] mm: Sets the migrate type " Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 12/16] mm: Define the make_alloc() function Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 13/16] mm: Create the file asociated with an allocation Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 14/16] mm: Free pages, remove files and clean cache when one alloc fails Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 15/16] mm: Create the "free" file to release the previously allocated pages Juan Yescas
2026-07-23  7:47 ` [RFC PATCH 16/16] mm: Release resources when the page alloc hogger module exits Juan Yescas
2026-07-28 19:29 ` [RFC PATCH 00/16] Page Alloc Hogger David Hildenbrand (Arm)
2026-07-29  0:36   ` Juan Yescas
2026-07-30  7:50     ` Lorenzo Stoakes (ARM)
2026-07-31 15:32       ` Juan Yescas
2026-07-31 15:55         ` Lorenzo Stoakes (ARM)
2026-07-31 17:52           ` Juan Yescas
2026-07-31 12:40     ` Lorenzo Stoakes (ARM) [this message]
2026-07-31 12:42       ` Lorenzo Stoakes (ARM)

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=amyWt8XYlQJRJXmg@lucifer \
    --to=ljs@kernel.org \
    --cc=Liam.Howlett@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=android-mm@google.com \
    --cc=david@kernel.org \
    --cc=dskiba@google.com \
    --cc=fvdl@google.com \
    --cc=jyescas@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lorenzo.stoakes@oracle.com \
    --cc=mhocko@suse.com \
    --cc=minchan@google.com \
    --cc=rppt@kernel.org \
    --cc=surenb@google.com \
    --cc=tkjos@google.com \
    --cc=vbabka@suse.cz \
    /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