[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 04/15] mm: debug support for region operations
From: |
Daniel Axtens |
Subject: |
[PATCH v2 04/15] mm: debug support for region operations |
Date: |
Mon, 28 Mar 2022 17:22:29 +1100 |
This is handy for debugging. Enable with `set debug=regions`.
Signed-off-by: Daniel Axtens <dja@axtens.net>
---
grub-core/kern/mm.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/grub-core/kern/mm.c b/grub-core/kern/mm.c
index 94e78f9a910d..f36499865632 100644
--- a/grub-core/kern/mm.c
+++ b/grub-core/kern/mm.c
@@ -115,9 +115,8 @@ grub_mm_init_region (void *addr, grub_size_t size)
grub_mm_header_t h;
grub_mm_region_t r, *p, q;
-#if 0
- grub_printf ("Using memory for heap: start=%p, end=%p\n", addr, addr +
(unsigned int) size);
-#endif
+ grub_dprintf ("regions", "Using memory for heap: start=%p, end=%p\n",
+ addr, (char *) addr + (unsigned int) size);
/* Exclude last 4K to avoid overflows. */
/* If addr + 0x1000 overflows then whole region is in excluded zone. */
@@ -142,8 +141,14 @@ grub_mm_init_region (void *addr, grub_size_t size)
* addr q
* |----size-----|-q->pre_size-|<q region>|
*/
+ grub_dprintf ("regions", "Can we extend into region above?"
+ " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " ?=? %p\n",
+ (grub_uint8_t *) addr, size, q->pre_size, (grub_uint8_t *)
q);
if ((grub_uint8_t *) addr + size + q->pre_size == (grub_uint8_t *) q)
{
+ grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p
-> %p)\n",
+ q, (grub_uint8_t *) q + sizeof (*q) + q->size,
+ addr, (grub_uint8_t *) q + sizeof (*q) + q->size);
/*
* Yes, we can merge the memory starting at addr into the
* existing region from below. Align up addr to GRUB_MM_ALIGN
@@ -185,9 +190,15 @@ grub_mm_init_region (void *addr, grub_size_t size)
* q addr
* |<q region>|-q->post_size-|----size-----|
*/
+ grub_dprintf ("regions", "Can we extend into region below?"
+ " %p + %" PRIxGRUB_SIZE " + %" PRIxGRUB_SIZE " + %"
PRIxGRUB_SIZE " ?=? %p\n",
+ (grub_uint8_t *) q, sizeof(*q), q->size, q->post_size,
(grub_uint8_t *) addr);
if ((grub_uint8_t *)q + sizeof(*q) + q->size + q->post_size ==
(grub_uint8_t *) addr)
{
+ grub_dprintf ("regions", "Yes: extending a region: (%p -> %p) -> (%p
-> %p)\n",
+ q, (grub_uint8_t *) q + sizeof (*q) + q->size,
+ q, (grub_uint8_t *) addr + size);
/*
* Yes! Follow a similar pattern to above, but simpler.
* Our header starts at address - post_size, which should align us
@@ -206,6 +217,8 @@ grub_mm_init_region (void *addr, grub_size_t size)
}
}
+ grub_dprintf ("regions", "No: considering a new region at %p of size %"
PRIxGRUB_SIZE "\n",
+ addr, size);
/* Allocate a region from the head. */
r = (grub_mm_region_t) ALIGN_UP ((grub_addr_t) addr, GRUB_MM_ALIGN);
--
2.32.0
- [PATCH v2 00/15] Dynamic allocation of memory regions and IBM vTPM v2, Daniel Axtens, 2022/03/28
- [PATCH v2 02/15] mm: assert that we preserve header vs region alignment, Daniel Axtens, 2022/03/28
- [PATCH v2 03/15] mm: when adding a region, merge with region after as well as before, Daniel Axtens, 2022/03/28
- [PATCH v2 01/15] grub-shell: only pass SeaBIOS fw_opt in for x86 BIOS platforms, Daniel Axtens, 2022/03/28
- [PATCH v2 04/15] mm: debug support for region operations,
Daniel Axtens <=
- [PATCH v2 05/15] mm: Drop unused unloading of modules on OOM, Daniel Axtens, 2022/03/28
- [PATCH v2 06/15] mm: Allow dynamically requesting additional memory regions, Daniel Axtens, 2022/03/28
- [PATCH v2 07/15] efi: mm: Always request a fixed number of pages on init, Daniel Axtens, 2022/03/28
- [PATCH v2 08/15] efi: mm: Extract function to add memory regions, Daniel Axtens, 2022/03/28
- [PATCH v2 10/15] efi: mm: Implement runtime addition of pages, Daniel Axtens, 2022/03/28
- [PATCH v2 09/15] efi: mm: Pass up errors from `add_memory_regions ()`, Daniel Axtens, 2022/03/28
- [PATCH v2 11/15] ieee1275: request memory with ibm, client-architecture-support, Daniel Axtens, 2022/03/28
- [PATCH v2 12/15] ieee1275: drop len -= 1 quirk in heap_init, Daniel Axtens, 2022/03/28
- [PATCH v2 13/15] ieee1275: support runtime memory claiming, Daniel Axtens, 2022/03/28
- [PATCH v2 14/15] [RFC] Add memtool module with memory allocation stress-test, Daniel Axtens, 2022/03/28