* [PATCH 0/3] memblock: physical memory list cleanups
@ 2017-01-20 12:34 Heiko Carstens
2017-01-20 12:34 ` [PATCH 1/3] memblock: let memblock_type_name know about physmem type Heiko Carstens
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Heiko Carstens @ 2017-01-20 12:34 UTC (permalink / raw)
To: Andrew Morton; +Cc: linux-mm, linux-kernel
Just a couple of trivial memblock patches, which could also be merged
into one patch; whatever is preferred.
Since commit 70210ed950b5 ("mm/memblock: add physical memory list")
the memblock structure knows about a physical memory list.
The memblock code should also print a sane name instead of "unknown"
if it calls memblock_type_name() to get a name for the physmem
memblock type.
In addition the physmem list should also be dumped, if present, and
memblock_dump_all is called to improve debugability.
The last patch embeds the memblock type name into the memblock type
structure in order to hopefully make the code a bit more easier and to
get rid of a bit of code duplication.
Thanks,
Heiko
Heiko Carstens (3):
memblock: let memblock_type_name know about physmem type
memblock: also dump physmem list within __memblock_dump_all
memblock: embed memblock type name within struct memblock_type
arch/s390/kernel/crash_dump.c | 1 +
include/linux/memblock.h | 1 +
mm/memblock.c | 32 +++++++++++++-------------------
3 files changed, 15 insertions(+), 19 deletions(-)
--
2.8.4
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread* [PATCH 1/3] memblock: let memblock_type_name know about physmem type 2017-01-20 12:34 [PATCH 0/3] memblock: physical memory list cleanups Heiko Carstens @ 2017-01-20 12:34 ` Heiko Carstens 2017-01-20 12:34 ` [PATCH 2/3] memblock: also dump physmem list within __memblock_dump_all Heiko Carstens 2017-01-20 12:34 ` [PATCH 3/3] memblock: embed memblock type name within struct memblock_type Heiko Carstens 2 siblings, 0 replies; 4+ messages in thread From: Heiko Carstens @ 2017-01-20 12:34 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-mm, linux-kernel Since commit 70210ed950b5 ("mm/memblock: add physical memory list") the memblock structure knows about a physical memory list. memblock_type_name() should return "physmem" instead of "unknown" if the name of the physmem memblock_type is being asked for. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- mm/memblock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index 7608bc305936..acbfa1dffff2 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -72,6 +72,10 @@ memblock_type_name(struct memblock_type *type) return "memory"; else if (type == &memblock.reserved) return "reserved"; +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP + else if (type == &memblock.physmem) + return "physmem"; +#endif else return "unknown"; } -- 2.8.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/3] memblock: also dump physmem list within __memblock_dump_all 2017-01-20 12:34 [PATCH 0/3] memblock: physical memory list cleanups Heiko Carstens 2017-01-20 12:34 ` [PATCH 1/3] memblock: let memblock_type_name know about physmem type Heiko Carstens @ 2017-01-20 12:34 ` Heiko Carstens 2017-01-20 12:34 ` [PATCH 3/3] memblock: embed memblock type name within struct memblock_type Heiko Carstens 2 siblings, 0 replies; 4+ messages in thread From: Heiko Carstens @ 2017-01-20 12:34 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-mm, linux-kernel Since commit 70210ed950b5 ("mm/memblock: add physical memory list") the memblock structure knows about a physical memory list. The physical memory list should also be dumped if memblock_dump_all() is called in case memblock_debug is switched on. This makes debugging a bit easier. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- mm/memblock.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/memblock.c b/mm/memblock.c index acbfa1dffff2..fbaaf713827c 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1709,6 +1709,9 @@ void __init_memblock __memblock_dump_all(void) memblock_dump(&memblock.memory, "memory"); memblock_dump(&memblock.reserved, "reserved"); +#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP + memblock_dump(&memblock.physmem, "physmem"); +#endif } void __init memblock_allow_resize(void) -- 2.8.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 3/3] memblock: embed memblock type name within struct memblock_type 2017-01-20 12:34 [PATCH 0/3] memblock: physical memory list cleanups Heiko Carstens 2017-01-20 12:34 ` [PATCH 1/3] memblock: let memblock_type_name know about physmem type Heiko Carstens 2017-01-20 12:34 ` [PATCH 2/3] memblock: also dump physmem list within __memblock_dump_all Heiko Carstens @ 2017-01-20 12:34 ` Heiko Carstens 2 siblings, 0 replies; 4+ messages in thread From: Heiko Carstens @ 2017-01-20 12:34 UTC (permalink / raw) To: Andrew Morton; +Cc: linux-mm, linux-kernel Provide the name of each memblock type with struct memblock_type. This allows to get rid of the function memblock_type_name() and duplicating the type names in __memblock_dump_all(). The only memblock_type usage out of mm/memblock.c seems to be arch/s390/kernel/crash_dump.c. While at it, give it a name. Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> --- arch/s390/kernel/crash_dump.c | 1 + include/linux/memblock.h | 1 + mm/memblock.c | 35 +++++++++++------------------------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c index f9293bfefb7f..9c9440dc253a 100644 --- a/arch/s390/kernel/crash_dump.c +++ b/arch/s390/kernel/crash_dump.c @@ -31,6 +31,7 @@ static struct memblock_type oldmem_type = { .max = 1, .total_size = 0, .regions = &oldmem_region, + .name = "oldmem", }; struct save_area { diff --git a/include/linux/memblock.h b/include/linux/memblock.h index 5b759c9acf97..8dee5ec80adf 100644 --- a/include/linux/memblock.h +++ b/include/linux/memblock.h @@ -42,6 +42,7 @@ struct memblock_type { unsigned long max; /* size of the allocated array */ phys_addr_t total_size; /* size of all regions */ struct memblock_region *regions; + char *name; }; struct memblock { diff --git a/mm/memblock.c b/mm/memblock.c index fbaaf713827c..82d21e598e8c 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -35,15 +35,18 @@ struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, .memory.cnt = 1, /* empty dummy entry */ .memory.max = INIT_MEMBLOCK_REGIONS, + .memory.name = "memory", .reserved.regions = memblock_reserved_init_regions, .reserved.cnt = 1, /* empty dummy entry */ .reserved.max = INIT_MEMBLOCK_REGIONS, + .reserved.name = "reserved", #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP .physmem.regions = memblock_physmem_init_regions, .physmem.cnt = 1, /* empty dummy entry */ .physmem.max = INIT_PHYSMEM_REGIONS, + .physmem.name = "physmem", #endif .bottom_up = false, @@ -64,22 +67,6 @@ ulong __init_memblock choose_memblock_flags(void) return system_has_some_mirror ? MEMBLOCK_MIRROR : MEMBLOCK_NONE; } -/* inline so we don't get a warning when pr_debug is compiled out */ -static __init_memblock const char * -memblock_type_name(struct memblock_type *type) -{ - if (type == &memblock.memory) - return "memory"; - else if (type == &memblock.reserved) - return "reserved"; -#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP - else if (type == &memblock.physmem) - return "physmem"; -#endif - else - return "unknown"; -} - /* adjust *@size so that (@base + *@size) doesn't overflow, return new size */ static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size) { @@ -406,12 +393,12 @@ static int __init_memblock memblock_double_array(struct memblock_type *type, } if (!addr) { pr_err("memblock: Failed to double %s array from %ld to %ld entries !\n", - memblock_type_name(type), type->max, type->max * 2); + type->name, type->max, type->max * 2); return -1; } memblock_dbg("memblock: %s is doubled to %ld at [%#010llx-%#010llx]", - memblock_type_name(type), type->max * 2, (u64)addr, + type->name, type->max * 2, (u64)addr, (u64)addr + new_size - 1); /* @@ -1675,14 +1662,14 @@ phys_addr_t __init_memblock memblock_get_current_limit(void) return memblock.current_limit; } -static void __init_memblock memblock_dump(struct memblock_type *type, char *name) +static void __init_memblock memblock_dump(struct memblock_type *type) { unsigned long long base, size; unsigned long flags; int idx; struct memblock_region *rgn; - pr_info(" %s.cnt = 0x%lx\n", name, type->cnt); + pr_info(" %s.cnt = 0x%lx\n", type->name, type->cnt); for_each_memblock_type(type, rgn) { char nid_buf[32] = ""; @@ -1696,7 +1683,7 @@ static void __init_memblock memblock_dump(struct memblock_type *type, char *name memblock_get_region_node(rgn)); #endif pr_info(" %s[%#x]\t[%#016llx-%#016llx], %#llx bytes%s flags: %#lx\n", - name, idx, base, base + size - 1, size, nid_buf, flags); + type->name, idx, base, base + size - 1, size, nid_buf, flags); } } @@ -1707,10 +1694,10 @@ void __init_memblock __memblock_dump_all(void) (unsigned long long)memblock.memory.total_size, (unsigned long long)memblock.reserved.total_size); - memblock_dump(&memblock.memory, "memory"); - memblock_dump(&memblock.reserved, "reserved"); + memblock_dump(&memblock.memory); + memblock_dump(&memblock.reserved); #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP - memblock_dump(&memblock.physmem, "physmem"); + memblock_dump(&memblock.physmem); #endif } -- 2.8.4 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a> ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-01-20 12:35 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2017-01-20 12:34 [PATCH 0/3] memblock: physical memory list cleanups Heiko Carstens 2017-01-20 12:34 ` [PATCH 1/3] memblock: let memblock_type_name know about physmem type Heiko Carstens 2017-01-20 12:34 ` [PATCH 2/3] memblock: also dump physmem list within __memblock_dump_all Heiko Carstens 2017-01-20 12:34 ` [PATCH 3/3] memblock: embed memblock type name within struct memblock_type Heiko Carstens
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox