]> git.ipfire.org Git - thirdparty/grub.git/commit
commands/memtools: Add lsmemregions command
authorLeo Sandoval <lsandova@redhat.com>
Tue, 21 Oct 2025 18:39:00 +0000 (12:39 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Fri, 24 Oct 2025 17:39:51 +0000 (19:39 +0200)
commit42c0997864a8d13f8a6b6eddf14087af5134ef2f
treebd06b357a982979e874c6f89dd937e109707d89d
parent20211246a8c4358bd72a249e96d3eb2af9c15a5f
commands/memtools: Add lsmemregions command

Prints memory regions general information including size, number of
blocks, total free and total allocated memory per region. The reason
behind is to have a tool that shows general information about regions
and how fragmented the memory is at some particular time.

Below is an example showing how this tool before and after memory stress.

    grub> lsmemregions

    Region 0x78f6e000 (size 33554368 blocks 1048574 free 27325472 alloc 6232768)

    > stress_big_allocations
    ...

    grub> lsmemregions

    Region 0x7af8e000 (size 4032 blocks 126 free 2720 alloc 1312)
    Region 0x80c000 (size 81856 blocks 2558 free 81856 alloc 0)
    Region 0x7d165000 (size 167872 blocks 5246 free 167872 alloc 0)
    Region 0x7d0bf000 (size 655296 blocks 20478 free 655296 alloc 0)
    Region 0x7ee00000 (size 1331136 blocks 41598 free 1331136 alloc 0)
    Region 0x100000 (size 7385024 blocks 230782 free 7385024 alloc 0)
    Region 0x7af95000 (size 25382848 blocks 793214 free 25382848 alloc 0)
    Region 0x1780000 (size 2038357952 blocks 63698686 free 2077517536 alloc 5445568)

Signed-off-by: Leo Sandoval <lsandova@redhat.com>
Reviewed-by: Andrew Hamilton <adhamilt@gmail.com>
Reviewed-by: Avnish Chouhan <avnish@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/memtools.c
grub-core/kern/mm.c
include/grub/mm.h