commands/memtools: Add memtool module with memory allocation stress-test

When working on memory, it's nice to be able to test your work.

Add a memtest module. When compiled with --enable-mm-debug, it exposes
3 commands:

 * lsmem - print all allocations and free space in all regions
 * lsfreemem - print free space in all regions

 * stress_big_allocs - stress test large allocations:
  - how much memory can we allocate in one chunk?
  - how many 1MB chunks can we allocate?
  - check that gap-filling works with a 1MB aligned 900kB alloc + a
     100kB alloc.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Tested-by: Nageswara R Sastry <rnsastry@linux.ibm.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
This commit is contained in:
Daniel Axtens authored and Daniel Kiper committed 2023-03-07 15:26:36 +01:00
1 parent 1b4d91185b
commit d8953d0793
4 files changed
+163

No files matched your search

+4
View File
@@ -734,6 +734,8 @@ grub_mm_dump_free (void)
{
grub_mm_header_t p;
grub_printf ("Region %p (size %" PRIuGRUB_SIZE ")\n\n", r, r->size);
/* Follow the free list. */
p = r->first;
do
@@ -761,6 +763,8 @@ grub_mm_dump (unsigned lineno)
{
grub_mm_header_t p;
grub_printf ("Region %p (size %" PRIuGRUB_SIZE ")\n\n", r, r->size);
for (p = (grub_mm_header_t) ALIGN_UP ((grub_addr_t) (r + 1),
GRUB_MM_ALIGN);
(grub_addr_t) p < (grub_addr_t) (r+1) + r->size;