2024-05-21 02:41:01

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

Some of memory regions can be reserved for a specific purpose. They are
usually defined through reserved-memory in device tree. If only size
without address is specified in device tree, the address of the region
will be determined at boot time.

We may find the address of the memory regions through booting log, but
it does not show all. And it could be hard to catch the very beginning
log. The memblock_dump_all shows all memblock status but it does not
show region name and its information is difficult to summarize.

This patch introduce a debugfs node, memblock/memsize, to see reserved
memory easily.

Here's an example

$ cat debugfs/memblock/memsize

0x0000000000000000-0x0000000000000000 0x02000000 ( 32768 KB ) map reusable linux,cma
0x0000000000000000-0x0000000000000000 0x01000000 ( 16384 KB ) map reusable vxxxxx
..
0x0000000000000000-0x0000000000000000 0x004e0000 ( 4992 KB ) nomap unusable unknown
0x0000000000000000-0x0000000000000000 0x00400000 ( 4096 KB ) nomap unusable cxxxxx
0x0000000000000000-0x0000000000000000 0x00e00000 ( 14336 KB ) nomap unusable gxxxxx

Reserved : 1223856 KB
.kernel : 275208 KB
.text : 16576 KB
.rwdata : 1963 KB
.rodata : 11920 KB
.bss : 2450 KB
.memmap : 186368 KB
.etc : 55933 KB
.unusable : 948648 KB
System : 11359056 KB
.common : 10306384 KB
.reusable : 1052672 KB
Total : 12582912 KB ( 12288.00 MB )

Jaewon Kim (10):
memblock: introduce memsize showing reserved memory
memblock: detect hidden memory hole size
memblock: handle overlapped reserved memory region
memblock: take a region intersecting an unknown region
memblock: track memblock changed at early param
memblock: recognize late freed size by checking PageReserved
memblock: track kernel size on memsize
memblock: print memsize summary information
memblock: print kernel internal size
memblock: support memsize reusable to consider as reusable

drivers/of/fdt.c | 11 +
drivers/of/of_reserved_mem.c | 12 +-
include/linux/memblock.h | 29 ++
init/main.c | 13 +-
kernel/dma/contiguous.c | 9 +-
mm/Kconfig | 16 ++
mm/memblock.c | 502 ++++++++++++++++++++++++++++++++++-
mm/mm_init.c | 6 +-
mm/page_alloc.c | 10 +-
9 files changed, 597 insertions(+), 11 deletions(-)

--
2.25.1



2024-05-21 02:41:01

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 06/10] memblock: recognize late freed size by checking PageReserved

There are some cases in which reserved pages are freed late after the
initial memblock_free_all of mem_init. We'd like to recognize this
late free pages, and update the memsize information.

Because additional job is needed to a no-map or reusable region, the
late free is usually done to a map and unusable region. So only for map
and unusable region, check if some pages within the region is freed. The
freed pages can be recoginzed by checking if PageReserved flag is clear.
To be fast, let's skip other pages within 64 KB range. And this check is
done when a user wants to see the memsize information.

This is an example. If all pages are freed the region size will be 0.

Before
0x0a2300000-0x0a2400000 0x00100000 ( 1024 KB ) map unusable latefree

After
0x0a2300000-0x0a2300000 0x00000000 ( 0 KB ) map unusable latefree

Signed-off-by: Jaewon Kim <[email protected]>
---
mm/memblock.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)

diff --git a/mm/memblock.c b/mm/memblock.c
index edb2575967ab..de49e7ce74f1 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2608,6 +2608,39 @@ static int memsize_rgn_cmp(const void *a, const void *b)
return 0;
}

+/* assume that freed size is always 64 KB aligned */
+static inline void memblock_memsize_check_size(struct memsize_rgn_struct *rgn)
+{
+ phys_addr_t phy, end, freed = 0;
+ bool has_freed = false;
+ struct page *page;
+
+ if (rgn->reusable || rgn->nomap)
+ return;
+
+ /* check the first page of each 1 MB */
+ phy = rgn->base;
+ end = rgn->base + rgn->size;
+ while (phy < end) {
+ unsigned long pfn = __phys_to_pfn(phy);
+
+ if (!pfn_valid(pfn))
+ return;
+ page = pfn_to_page(pfn);
+ if (!has_freed && !PageReserved(page)) {
+ has_freed = true;
+ freed = phy;
+ } else if (has_freed && PageReserved(page)) {
+ has_freed = false;
+ memblock_memsize_free(freed, phy - freed);
+ }
+
+ if (has_freed && (phy + SZ_64K >= end))
+ memblock_memsize_free(freed, end - freed);
+ phy += SZ_64K;
+ }
+}
+
static int memblock_memsize_show(struct seq_file *m, void *private)
{
int i;
@@ -2621,6 +2654,7 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
long size;

rgn = &memsize_rgn[i];
+ memblock_memsize_check_size(rgn);
base = rgn->base;
size = rgn->size;
end = base + size;
--
2.25.1


2024-05-21 02:41:03

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 03/10] memblock: handle overlapped reserved memory region

It is not common, but defining an overlapped region is possible.
Actually memblock_add_range allows to overlap with existing ones.

The memsize currently does not handle this overlapped case. But this
patch tries to handle one overlapped case.

Here's the case.

There is an unknown memsize region, which means the region was removed
and not passed at bootloader stage. And there is a reserved memory
region defined in device tree which is overlapped with the unknown
region.

We expect that information in device tree make the unknown region clear.
This patch handle the overlapped region with following conditions.

1) The already existing overlapped region should be unknown and no-map.
2) The newly added region should have a name, and its region should be
same with or part of the existing one.

Here is an example.

Before this patch, memsize shows both overlapped region.

0x0ea000000-0x0ed900000 0x03900000 ( 58368 KB ) nomap unusable overlapped
0x0ea000000-0x0f1400000 0x07400000 ( 118784 KB ) nomap unusable unknown

After this patch, the overlapped region is named.

0x0ea000000-0x0ed900000 0x03900000 ( 58368 KB ) nomap unusable overlapped
0x0e9b00000-0x0ea000000 0x00500000 ( 5120 KB ) nomap unusable unknown

Signed-off-by: Jaewon Kim <[email protected]>
---
mm/memblock.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 75 insertions(+), 1 deletion(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 5204ee71ae29..4a0506e14025 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2060,6 +2060,73 @@ static void __init_memblock memsize_get_valid_name(char *valid_name, const char
valid_name[val_size] = '\0';
}

+static inline struct memsize_rgn_struct * __init_memblock memsize_get_new_rgn(void)
+{
+ if (memsize_rgn_count == ARRAY_SIZE(memsize_rgn)) {
+ pr_err("not enough space on memsize_rgn\n");
+ return NULL;
+ }
+ return &memsize_rgn[memsize_rgn_count++];
+}
+
+static bool __init_memblock memsize_update_nomap_region(const char *name, phys_addr_t base,
+ phys_addr_t size, bool nomap)
+{
+ int i;
+ struct memsize_rgn_struct *rmem_rgn, *new_rgn;
+
+ if (!name)
+ return false;
+
+ for (i = 0; i < memsize_rgn_count; i++) {
+ rmem_rgn = &memsize_rgn[i];
+
+ if (!rmem_rgn->nomap)
+ continue;
+ if (strcmp(rmem_rgn->name, "unknown"))
+ continue;
+ if (base < rmem_rgn->base)
+ continue;
+ if (base + size > rmem_rgn->base + rmem_rgn->size)
+ continue;
+
+ if (base == rmem_rgn->base && size == rmem_rgn->size) {
+ memsize_get_valid_name(rmem_rgn->name, name);
+ return true;
+ }
+
+ new_rgn = memsize_get_new_rgn();
+ if (!new_rgn)
+ return true;
+ new_rgn->base = base;
+ new_rgn->size = size;
+ new_rgn->nomap = nomap;
+ new_rgn->reusable = false;
+ memsize_get_valid_name(new_rgn->name, name);
+
+ if (base == rmem_rgn->base && size < rmem_rgn->size) {
+ rmem_rgn->base = base + size;
+ rmem_rgn->size -= size;
+ } else if (base + size == rmem_rgn->base + rmem_rgn->size) {
+ rmem_rgn->size -= size;
+ } else {
+ new_rgn = memsize_get_new_rgn();
+ if (!new_rgn)
+ return true;
+ new_rgn->base = base + size;
+ new_rgn->size = (rmem_rgn->base + rmem_rgn->size)
+ - (base + size);
+ new_rgn->nomap = nomap;
+ new_rgn->reusable = false;
+ strscpy(new_rgn->name, "unknown", sizeof(new_rgn->name));
+ rmem_rgn->size = base - rmem_rgn->base;
+ }
+ return true;
+ }
+
+ return false;
+}
+
void __init_memblock memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap, bool reusable)
{
@@ -2070,7 +2137,14 @@ void __init_memblock memblock_memsize_record(const char *name, phys_addr_t base,
pr_err("not enough space on memsize_rgn\n");
return;
}
- rgn = &memsize_rgn[memsize_rgn_count++];
+
+ if (memsize_update_nomap_region(name, base, size, nomap))
+ return;
+
+ rgn = memsize_get_new_rgn();
+ if (!rgn)
+ return;
+
rgn->base = base;
rgn->size = size;
rgn->nomap = nomap;
--
2.25.1


2024-05-21 02:41:24

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 07/10] memblock: track kernel size on memsize

Some memory regions are already being tracked by previous patches. But
there are many memory allocations from memblock and frees to memblock
during the boot time.

This patch tracks the memblock size used for the common kernel. To to
this, tracking memblock size is disabled for some memory handling logics
like early param, device tree, and default cma size.

For precise kernel size, this patch counts not actually freed size to
buddy at boot time, and does not count freed size from ramdisk and init
section.

Additionally this patch does one important thing. This patch blocks
memblock_add_range of memblock_remove_range not to update memsize if
free pages were already released to the buddy allocator.

This is an example. The kernel size is newly added by this patch.

.kernel : 135137 KB
.unusable : 788073 KB
.reusable : 294912 KB

Signed-off-by: Jaewon Kim <[email protected]>
---
drivers/of/fdt.c | 6 ++++++
include/linux/memblock.h | 6 ++++++
kernel/dma/contiguous.c | 7 ++++--
mm/memblock.c | 46 ++++++++++++++++++++++++++++++++++++++++
mm/page_alloc.c | 10 ++++++++-
5 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index da82e5afed01..08638673e106 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -524,6 +524,8 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!initial_boot_params)
return;

+ memblock_memsize_disable_tracking();
+
fdt_scan_reserved_mem();
fdt_reserve_elfcorehdr();

@@ -537,6 +539,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
}

fdt_init_reserved_mem();
+ memblock_memsize_enable_tracking();
}

/**
@@ -1189,12 +1192,15 @@ void __init early_init_dt_scan_nodes(void)
if (rc)
pr_warn("No chosen node found, continuing without\n");

+ memblock_memsize_disable_tracking();
+
/* Setup memory, calling early_init_dt_add_memory_arch */
early_init_dt_scan_memory();

/* Handle linux,usable-memory-range property */
early_init_dt_check_for_usable_mem_range();

+ memblock_memsize_enable_tracking();
memblock_memsize_detect_hole();
}

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index aef02c150f2c..a83ad98ac252 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -620,6 +620,9 @@ extern void memblock_memsize_record(const char *name, phys_addr_t base,
extern void memblock_memsize_detect_hole(void);
extern void memblock_memsize_set_name(const char *name);
extern void memblock_memsize_unset_name(void);
+extern void memblock_memsize_enable_tracking(void);
+extern void memblock_memsize_disable_tracking(void);
+extern void memblock_memsize_mod_kernel_size(long size);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
@@ -627,6 +630,9 @@ static inline void memblock_memsize_record(const char *name, phys_addr_t base,
static inline void memblock_memsize_detect_hole(void) { }
static inline void memblock_memsize_set_name(const char *name) { }
static inline void memblock_memsize_unset_name(void) { }
+static inline void memblock_memsize_enable_tracking(void){ }
+static inline void memblock_memsize_disable_tracking(void){ }
+static inline void memblock_memsize_mod_kernel_size(long size) { }
#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 437c85878280..e9c68b1ee975 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -277,10 +277,11 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
{
int ret;

+ memblock_memsize_disable_tracking();
ret = cma_declare_contiguous(base, size, limit, 0, 0, fixed,
"reserved", res_cma);
if (ret)
- return ret;
+ goto out;

/* Architecture specific contiguous memory fixup. */
dma_contiguous_early_fixup(cma_get_base(*res_cma),
@@ -288,7 +289,9 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,

memblock_memsize_record("dma_cma", cma_get_base(*res_cma),
cma_get_size(*res_cma), false, true);
- return 0;
+out:
+ memblock_memsize_enable_tracking();
+ return ret;
}

/**
diff --git a/mm/memblock.c b/mm/memblock.c
index de49e7ce74f1..bb033c20ec43 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2060,6 +2060,23 @@ struct memsize_rgn_struct {
static struct memsize_rgn_struct memsize_rgn[CONFIG_MAX_MEMBLOCK_MEMSIZE] __initdata_memblock;
static int memsize_rgn_count __initdata_memblock;
static const char *memblock_memsize_name __initdata_memblock;
+static long memsize_kinit __initdata_memblock;
+static bool memblock_memsize_tracking __initdata_memblock = true;
+
+void __init memblock_memsize_enable_tracking(void)
+{
+ memblock_memsize_tracking = true;
+}
+
+void __init memblock_memsize_disable_tracking(void)
+{
+ memblock_memsize_tracking = false;
+}
+
+void memblock_memsize_mod_kernel_size(long size)
+{
+ memsize_kinit += size;
+}

static void __init_memblock memsize_get_valid_name(char *valid_name, const char *name)
{
@@ -2313,6 +2330,12 @@ static void __init_memblock memblock_memsize_record_add(struct memblock_type *ty
base, size, false, false);
else if (type == &memblock.memory)
memblock_memsize_free(base, size);
+ } else if (memblock_memsize_tracking) {
+ if (type == &memblock.reserved) {
+ memblock_dbg("%s: kernel %lu %+ld\n", __func__,
+ memsize_kinit, (unsigned long)size);
+ memsize_kinit += size;
+ }
}
}

@@ -2325,6 +2348,12 @@ static void __init_memblock memblock_memsize_record_remove(struct memblock_type
else if (type == &memblock.memory)
memblock_memsize_record(memblock_memsize_name,
base, size, true, false);
+ } else if (memblock_memsize_tracking) {
+ if (type == &memblock.reserved) {
+ memblock_dbg("%s: kernel %lu %+ld\n", __func__,
+ memsize_kinit, (unsigned long)size);
+ memsize_kinit -= size;
+ }
}
}
#endif /* MEMBLOCK_MEMSIZE */
@@ -2442,6 +2471,19 @@ static unsigned long __init __free_memory_core(phys_addr_t start,
unsigned long end_pfn = min_t(unsigned long,
PFN_DOWN(end), max_low_pfn);

+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+ unsigned long start_align_up = PFN_ALIGN(start);
+ unsigned long end_align_down = PFN_PHYS(end_pfn);
+
+ if (start_pfn >= end_pfn) {
+ memblock_memsize_mod_kernel_size(end - start);
+ } else {
+ if (start_align_up > start)
+ memblock_memsize_mod_kernel_size(start_align_up - start);
+ if (end_pfn != max_low_pfn && end_align_down < end)
+ memblock_memsize_mod_kernel_size(end - end_align_down);
+ }
+#endif
if (start_pfn >= end_pfn)
return 0;

@@ -2546,6 +2588,8 @@ void __init memblock_free_all(void)

pages = free_low_memory_core_early();
totalram_pages_add(pages);
+
+ memblock_memsize_disable_tracking();
}

#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_ARCH_KEEP_MEMBLOCK)
@@ -2672,6 +2716,8 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
}

seq_puts(m, "\n");
+ seq_printf(m, " .kernel : %7lu KB\n",
+ DIV_ROUND_UP(memsize_kinit, SZ_1K));
seq_printf(m, " .unusable : %7lu KB\n",
DIV_ROUND_UP(reserved, SZ_1K));
seq_printf(m, " .reusable : %7lu KB\n",
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 2e22ce5675ca..a4c692635e9b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -20,6 +20,7 @@
#include <linux/highmem.h>
#include <linux/interrupt.h>
#include <linux/jiffies.h>
+#include <linux/memblock.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/kasan.h>
@@ -5776,8 +5777,15 @@ unsigned long free_reserved_area(void *start, void *end, int poison, const char
free_reserved_page(page);
}

- if (pages && s)
+ if (pages && s) {
pr_info("Freeing %s memory: %ldK\n", s, K(pages));
+ if (!strcmp(s, "initrd") || !strcmp(s, "unused kernel")) {
+ long size;
+
+ size = -1 * (long)(pages << PAGE_SHIFT);
+ memblock_memsize_mod_kernel_size(size);
+ }
+ }

return pages;
}
--
2.25.1


2024-05-21 02:42:11

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 02/10] memblock: detect hidden memory hole size

Bootloader knows the actual memory size, but bootloader may reserve some
memory for a specific purpose and pass the only remaining memory region
to kernel.

Even though kernel does not know what it is, we need to detect those
regions to sum up all reserved memory. Let me call it memory hole. To
expect the hole size, this patch assume two things. One is that each
physical memory has 1GB aligned size and address. And the hole is less
than 1GB. For the hole, let it be shown as unknown in memsize logic.

This is an example.
0x0bf000000-0x0c0000000 0x01000000 ( 16384 KB ) nomap unusable unknown

Signed-off-by: Jaewon Kim <[email protected]>
---
drivers/of/fdt.c | 2 ++
include/linux/memblock.h | 2 ++
mm/memblock.c | 45 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 49 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index 605c7f471908..da82e5afed01 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1194,6 +1194,8 @@ void __init early_init_dt_scan_nodes(void)

/* Handle linux,usable-memory-range property */
early_init_dt_check_for_usable_mem_range();
+
+ memblock_memsize_detect_hole();
}

bool __init early_init_dt_scan(void *params)
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 9ccba9bb20cb..049313871059 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -617,10 +617,12 @@ static inline void memtest_report_meminfo(struct seq_file *m) { }
extern void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
bool reusable);
+extern void memblock_memsize_detect_hole(void);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
bool reusable) { }
+static inline void memblock_memsize_detect_hole(void) { }
#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/mm/memblock.c b/mm/memblock.c
index f05e7df2f8e1..5204ee71ae29 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2084,6 +2084,51 @@ void __init_memblock memblock_memsize_record(const char *name, phys_addr_t base,
memblock_dbg("%s %pa..%pa nomap:%d reusable:%d\n",
__func__, &base, &end, nomap, reusable);
}
+
+/* This function will be called to by early_init_dt_scan_nodes */
+void __init memblock_memsize_detect_hole(void)
+{
+ phys_addr_t base, end;
+ phys_addr_t prev_end, hole_sz;
+ int idx;
+ struct memblock_region *rgn;
+ int memblock_cnt = (int)memblock.memory.cnt;
+
+ /* assume that the hole size is less than 1 GB */
+ for_each_memblock_type(idx, (&memblock.memory), rgn) {
+ prev_end = (idx == 0) ? round_down(rgn->base, SZ_1G) : end;
+ base = rgn->base;
+ end = rgn->base + rgn->size;
+
+ /* only for the last region, check a hole after the region */
+ if (idx + 1 == memblock_cnt) {
+ hole_sz = round_up(end, SZ_1G) - end;
+ if (hole_sz)
+ memblock_memsize_record(NULL, end, hole_sz,
+ true, false);
+ }
+
+ /* for each region, check a hole prior to the region */
+ hole_sz = base - prev_end;
+ if (!hole_sz)
+ continue;
+ if (hole_sz < SZ_1G) {
+ memblock_memsize_record(NULL, prev_end, hole_sz, true,
+ false);
+ } else {
+ phys_addr_t hole_sz1, hole_sz2;
+
+ hole_sz1 = round_up(prev_end, SZ_1G) - prev_end;
+ if (hole_sz1)
+ memblock_memsize_record(NULL, prev_end,
+ hole_sz1, true, false);
+ hole_sz2 = base % SZ_1G;
+ if (hole_sz2)
+ memblock_memsize_record(NULL, base - hole_sz2,
+ hole_sz2, true, false);
+ }
+ }
+}
#endif /* MEMBLOCK_MEMSIZE */

static void __init free_memmap(unsigned long start_pfn, unsigned long end_pfn)
--
2.25.1


2024-05-21 02:42:18

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 09/10] memblock: print kernel internal size

Kernel internal size information is also useful to compare with other
binary. This patch print kernel text, rwdata, rodata, bss, and others.

Here's an example.

Reserved : 1181708 KB
.kernel : 296172 KB
.text : 16960 KB
.rwdata : 2299 KB
.rodata : 16464 KB
.bss : 7549 KB
.memmap : 196608 KB
.etc : 56293 KB
.unusable : 885536 KB

Signed-off-by: Jaewon Kim <[email protected]>
---
include/linux/memblock.h | 6 ++++++
mm/memblock.c | 36 ++++++++++++++++++++++++++++++++++++
mm/mm_init.c | 6 +++++-
3 files changed, 47 insertions(+), 1 deletion(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index a83ad98ac252..7ab8b59bfbc1 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -623,6 +623,9 @@ extern void memblock_memsize_unset_name(void);
extern void memblock_memsize_enable_tracking(void);
extern void memblock_memsize_disable_tracking(void);
extern void memblock_memsize_mod_kernel_size(long size);
+extern void memblock_memsize_mod_memmap_size(long size);
+extern void memblock_memsize_kernel_code_data(unsigned long code,
+ unsigned long data, unsigned long ro, unsigned long bss);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
@@ -633,6 +636,9 @@ static inline void memblock_memsize_unset_name(void) { }
static inline void memblock_memsize_enable_tracking(void){ }
static inline void memblock_memsize_disable_tracking(void){ }
static inline void memblock_memsize_mod_kernel_size(long size) { }
+static inline void memblock_memsize_mod_memmap_size(long size) { }
+static inline void memblock_memsize_kernel_code_data(unsigned long code,
+ unsigned long data, unsigned long ro, unsigned long bss) { }
#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/mm/memblock.c b/mm/memblock.c
index 0906d81f66c2..2fe0dc2575c5 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2061,6 +2061,11 @@ static struct memsize_rgn_struct memsize_rgn[CONFIG_MAX_MEMBLOCK_MEMSIZE] __init
static int memsize_rgn_count __initdata_memblock;
static const char *memblock_memsize_name __initdata_memblock;
static long memsize_kinit __initdata_memblock;
+static long memsize_memap __initdata_memblock;
+static unsigned long memsize_code __initdata_memblock;
+static unsigned long memsize_data __initdata_memblock;
+static unsigned long memsize_ro __initdata_memblock;
+static unsigned long memsize_bss __initdata_memblock;
static bool memblock_memsize_tracking __initdata_memblock = true;

void __init memblock_memsize_enable_tracking(void)
@@ -2073,11 +2078,25 @@ void __init memblock_memsize_disable_tracking(void)
memblock_memsize_tracking = false;
}

+void __init memblock_memsize_mod_memmap_size(long size)
+{
+ memsize_memap += size;
+}
+
void memblock_memsize_mod_kernel_size(long size)
{
memsize_kinit += size;
}

+void __init memblock_memsize_kernel_code_data(unsigned long code, unsigned long data,
+ unsigned long ro, unsigned long bss)
+{
+ memsize_code = code;
+ memsize_data = data;
+ memsize_ro = ro;
+ memsize_bss = bss;
+}
+
static void __init_memblock memsize_get_valid_name(char *valid_name, const char *name)
{
char *head, *tail, *found;
@@ -2691,6 +2710,11 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
struct memsize_rgn_struct *rgn;
unsigned long reserved = 0, reusable = 0, total;
unsigned long system = totalram_pages() << PAGE_SHIFT;
+ unsigned long etc;
+
+ etc = memsize_kinit;
+ etc -= memsize_code + memsize_data + memsize_ro + memsize_bss +
+ memsize_memap;

sort(memsize_rgn, memsize_rgn_count,
sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
@@ -2723,6 +2747,18 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
DIV_ROUND_UP(memsize_kinit + reserved, SZ_1K));
seq_printf(m, " .kernel : %7lu KB\n",
DIV_ROUND_UP(memsize_kinit, SZ_1K));
+ seq_printf(m, " .text : %7lu KB\n"
+ " .rwdata : %7lu KB\n"
+ " .rodata : %7lu KB\n"
+ " .bss : %7lu KB\n"
+ " .memmap : %7lu KB\n"
+ " .etc : %7lu KB\n",
+ DIV_ROUND_UP(memsize_code, SZ_1K),
+ DIV_ROUND_UP(memsize_data, SZ_1K),
+ DIV_ROUND_UP(memsize_ro, SZ_1K),
+ DIV_ROUND_UP(memsize_bss, SZ_1K),
+ DIV_ROUND_UP(memsize_memap, SZ_1K),
+ DIV_ROUND_UP(etc, SZ_1K));
seq_printf(m, " .unusable : %7lu KB\n",
DIV_ROUND_UP(reserved, SZ_1K));
seq_printf(m, "System : %7lu KB\n",
diff --git a/mm/mm_init.c b/mm/mm_init.c
index f72b852bd5b8..45187904db49 100644
--- a/mm/mm_init.c
+++ b/mm/mm_init.c
@@ -1587,8 +1587,10 @@ void __init *memmap_alloc(phys_addr_t size, phys_addr_t align,
MEMBLOCK_ALLOC_ACCESSIBLE,
nid);

- if (ptr && size > 0)
+ if (ptr && size > 0) {
page_init_poison(ptr, size);
+ memblock_memsize_mod_memmap_size((long)size);
+ }

return ptr;
}
@@ -2679,6 +2681,8 @@ static void __init mem_init_print_info(void)
init_data_size = __init_end - __init_begin;
init_code_size = _einittext - _sinittext;

+ memblock_memsize_kernel_code_data(codesize, datasize, rosize, bss_size);
+
/*
* Detect special cases and adjust section sizes accordingly:
* 1) .init.* may be embedded into .data sections
--
2.25.1


2024-05-21 02:44:15

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 10/10] memblock: support memsize reusable to consider as reusable

Sometimes we'd like to include some memory region as reusable even
though it is actually not CMA type. In that case, add reusable in its
device tree description, then memsize will consider it is reusuable and
add its size to the system total memory size.

Signed-off-by: Jaewon Kim <[email protected]>
---
drivers/of/of_reserved_mem.c | 3 +++
include/linux/memblock.h | 2 ++
mm/memblock.c | 7 +++++++
3 files changed, 12 insertions(+)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index ece678e07304..7aedac213995 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -468,6 +468,9 @@ void __init fdt_init_reserved_mem(void)
memblock_memsize_record(rmem->name, rmem->base,
rmem->size, nomap,
reusable);
+ if (reusable &&
+ !of_flat_dt_is_compatible(node, "shared-dma-pool"))
+ memblock_memsize_mod_reusable_size(rmem->size);
}
}
}
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 7ab8b59bfbc1..0aa6202a7a6a 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -626,6 +626,7 @@ extern void memblock_memsize_mod_kernel_size(long size);
extern void memblock_memsize_mod_memmap_size(long size);
extern void memblock_memsize_kernel_code_data(unsigned long code,
unsigned long data, unsigned long ro, unsigned long bss);
+extern void memblock_memsize_mod_reusable_size(long size);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
@@ -639,6 +640,7 @@ static inline void memblock_memsize_mod_kernel_size(long size) { }
static inline void memblock_memsize_mod_memmap_size(long size) { }
static inline void memblock_memsize_kernel_code_data(unsigned long code,
unsigned long data, unsigned long ro, unsigned long bss) { }
+static inline void memblock_memsize_mod_reusable_size(long size) { }
#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/mm/memblock.c b/mm/memblock.c
index 2fe0dc2575c5..a20d60d3bb40 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -2066,6 +2066,7 @@ static unsigned long memsize_code __initdata_memblock;
static unsigned long memsize_data __initdata_memblock;
static unsigned long memsize_ro __initdata_memblock;
static unsigned long memsize_bss __initdata_memblock;
+static long memsize_reusable_size __initdata_memblock;
static bool memblock_memsize_tracking __initdata_memblock = true;

void __init memblock_memsize_enable_tracking(void)
@@ -2117,6 +2118,11 @@ static void __init_memblock memsize_get_valid_name(char *valid_name, const char
valid_name[val_size] = '\0';
}

+void memblock_memsize_mod_reusable_size(long size)
+{
+ memsize_reusable_size += size;
+}
+
static inline struct memsize_rgn_struct * __init_memblock memsize_get_new_rgn(void)
{
if (memsize_rgn_count == ARRAY_SIZE(memsize_rgn)) {
@@ -2716,6 +2722,7 @@ static int memblock_memsize_show(struct seq_file *m, void *private)
etc -= memsize_code + memsize_data + memsize_ro + memsize_bss +
memsize_memap;

+ system += memsize_reusable_size;
sort(memsize_rgn, memsize_rgn_count,
sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
for (i = 0; i < memsize_rgn_count; i++) {
--
2.25.1


2024-05-21 02:44:23

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 01/10] memblock: introduce memsize showing reserved memory

Some of memory regions can be reserved for a specific purpose. They are
usually defined through reserved-memory in device tree. If only size
without address is specified in device tree, the address of the region
will be determined at boot time.

We may find the address of the memory regions through booting log, but
it does not show all. And it could be hard to catch the very beginning
log. The memblock_dump_all shows all memblock status but it does not
show region name and its information is difficult to summarize.

This patch introduce a debugfs node, memblock/memsize, to see reserved
memory easily.

The first patch here will show the only reserved-memory in device tree
like following example. The next patches will show more information.

There is a case in which the reserved memory region name has @ staring
string at the end. That information is not actually needed. Let's remove
those string.

$ cat debugfs/memblock/memsize
0x0f9000000-0x0fb000000 0x02000000 ( 32768 KB ) map reusable linux,cma
0x0b1900000-0x0b1b00000 0x00200000 ( 2048 KB ) nomap unusable test1
0x0b0200000-0x0b0400000 0x00200000 ( 2048 KB ) map unusable test2

unusable : 4096 KB
reusable : 32768 KB

Signed-off-by: Jaewon Kim <[email protected]>
---
drivers/of/fdt.c | 3 +
drivers/of/of_reserved_mem.c | 9 ++-
include/linux/memblock.h | 9 +++
kernel/dma/contiguous.c | 2 +
mm/Kconfig | 16 +++++
mm/memblock.c | 120 +++++++++++++++++++++++++++++++++++
6 files changed, 156 insertions(+), 3 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a8a04f27915b..605c7f471908 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -502,6 +502,8 @@ static void __init fdt_reserve_elfcorehdr(void)
}

memblock_reserve(elfcorehdr_addr, elfcorehdr_size);
+ memblock_memsize_record("elfcorehdr", elfcorehdr_addr, elfcorehdr_size,
+ false, false);

pr_info("Reserving %llu KiB of memory at 0x%llx for elfcorehdr\n",
elfcorehdr_size >> 10, elfcorehdr_addr);
@@ -531,6 +533,7 @@ void __init early_init_fdt_scan_reserved_mem(void)
if (!size)
break;
memblock_reserve(base, size);
+ memblock_memsize_record("memreserve", base, size, false, false);
}

fdt_init_reserved_mem();
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 46e1c3fbc769..ece678e07304 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -438,9 +438,10 @@ void __init fdt_init_reserved_mem(void)
struct reserved_mem *rmem = &reserved_mem[i];
unsigned long node = rmem->fdt_node;
int err = 0;
- bool nomap;
+ bool nomap, reusable;

nomap = of_get_flat_dt_prop(node, "no-map", NULL) != NULL;
+ reusable = of_get_flat_dt_prop(node, "reusable", NULL) != NULL;

if (rmem->size == 0)
err = __reserved_mem_alloc_size(node, rmem->name,
@@ -457,14 +458,16 @@ void __init fdt_init_reserved_mem(void)
rmem->size);
} else {
phys_addr_t end = rmem->base + rmem->size - 1;
- bool reusable =
- (of_get_flat_dt_prop(node, "reusable", NULL)) != NULL;

pr_info("%pa..%pa (%lu KiB) %s %s %s\n",
&rmem->base, &end, (unsigned long)(rmem->size / SZ_1K),
nomap ? "nomap" : "map",
reusable ? "reusable" : "non-reusable",
rmem->name ? rmem->name : "unknown");
+
+ memblock_memsize_record(rmem->name, rmem->base,
+ rmem->size, nomap,
+ reusable);
}
}
}
diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index e2082240586d..9ccba9bb20cb 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -613,5 +613,14 @@ static inline void early_memtest(phys_addr_t start, phys_addr_t end) { }
static inline void memtest_report_meminfo(struct seq_file *m) { }
#endif

+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+extern void memblock_memsize_record(const char *name, phys_addr_t base,
+ phys_addr_t size, bool nomap,
+ bool reusable);
+#else
+static inline void memblock_memsize_record(const char *name, phys_addr_t base,
+ phys_addr_t size, bool nomap,
+ bool reusable) { }
+#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c
index 055da410ac71..437c85878280 100644
--- a/kernel/dma/contiguous.c
+++ b/kernel/dma/contiguous.c
@@ -286,6 +286,8 @@ int __init dma_contiguous_reserve_area(phys_addr_t size, phys_addr_t base,
dma_contiguous_early_fixup(cma_get_base(*res_cma),
cma_get_size(*res_cma));

+ memblock_memsize_record("dma_cma", cma_get_base(*res_cma),
+ cma_get_size(*res_cma), false, true);
return 0;
}

diff --git a/mm/Kconfig b/mm/Kconfig
index b4cb45255a54..7fd25088b9b8 100644
--- a/mm/Kconfig
+++ b/mm/Kconfig
@@ -476,6 +476,22 @@ config HAVE_GUP_FAST
depends on MMU
bool

+config MAX_MEMBLOCK_MEMSIZE
+ int "Maximum number of tracking regions"
+ depends on MEMBLOCK_MEMSIZE
+ default 100
+ range 0 200
+ help
+ This number sets maximum number of tracking regions. If this is set to
+ 0, nothing will be saved.
+
+config MEMBLOCK_MEMSIZE
+ bool "memblock based reserved memory profiling"
+ default n
+ help
+ This patch introduce a node, memblock/memsize, to see reserved memory
+ easily.
+
# Don't discard allocated memory used to track "memory" and "reserved" memblocks
# after early boot, so it can still be used to test for validity of memory.
# Also, memblocks are updated with memory hot(un)plug.
diff --git a/mm/memblock.c b/mm/memblock.c
index d09136e040d3..f05e7df2f8e1 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -19,6 +19,7 @@

#include <asm/sections.h>
#include <linux/io.h>
+#include <linux/sort.h>

#include "internal.h"

@@ -2025,6 +2026,66 @@ static int __init early_memblock(char *p)
}
early_param("memblock", early_memblock);

+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+
+#define NAME_SIZE 100
+struct memsize_rgn_struct {
+ phys_addr_t base;
+ long size;
+ bool nomap; /* 1/32 byte */
+ bool reusable; /* 1/32 byte */
+ char name[NAME_SIZE]; /* 30/32 byte */
+};
+
+static struct memsize_rgn_struct memsize_rgn[CONFIG_MAX_MEMBLOCK_MEMSIZE] __initdata_memblock;
+static int memsize_rgn_count __initdata_memblock;
+
+static void __init_memblock memsize_get_valid_name(char *valid_name, const char *name)
+{
+ char *head, *tail, *found;
+ int val_size;
+
+ head = (char *)name;
+ tail = head + strlen(name);
+
+ /* get tail position after valid char */
+ found = strchr(name, '@');
+ if (found)
+ tail = found;
+
+ val_size = tail - head;
+ if (val_size > NAME_SIZE - 1)
+ val_size = NAME_SIZE - 1;
+ strscpy(valid_name, head, val_size);
+ valid_name[val_size] = '\0';
+}
+
+void __init_memblock memblock_memsize_record(const char *name, phys_addr_t base,
+ phys_addr_t size, bool nomap, bool reusable)
+{
+ struct memsize_rgn_struct *rgn;
+ phys_addr_t end;
+
+ if (memsize_rgn_count == CONFIG_MAX_MEMBLOCK_MEMSIZE) {
+ pr_err("not enough space on memsize_rgn\n");
+ return;
+ }
+ rgn = &memsize_rgn[memsize_rgn_count++];
+ rgn->base = base;
+ rgn->size = size;
+ rgn->nomap = nomap;
+ rgn->reusable = reusable;
+
+ if (!name)
+ strscpy(rgn->name, "unknown", sizeof(rgn->name));
+ else
+ memsize_get_valid_name(rgn->name, name);
+ end = base + size - 1;
+ memblock_dbg("%s %pa..%pa nomap:%d reusable:%d\n",
+ __func__, &base, &end, nomap, reusable);
+}
+#endif /* MEMBLOCK_MEMSIZE */
+
static void __init free_memmap(unsigned long start_pfn, unsigned long end_pfn)
{
struct page *start_pg, *end_pg;
@@ -2289,6 +2350,61 @@ static int memblock_debug_show(struct seq_file *m, void *private)
}
DEFINE_SHOW_ATTRIBUTE(memblock_debug);

+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+
+static int memsize_rgn_cmp(const void *a, const void *b)
+{
+ const struct memsize_rgn_struct *ra = a, *rb = b;
+
+ if (ra->base > rb->base)
+ return -1;
+
+ if (ra->base < rb->base)
+ return 1;
+
+ return 0;
+}
+
+static int memblock_memsize_show(struct seq_file *m, void *private)
+{
+ int i;
+ struct memsize_rgn_struct *rgn;
+ unsigned long reserved = 0, reusable = 0;
+
+ sort(memsize_rgn, memsize_rgn_count,
+ sizeof(memsize_rgn[0]), memsize_rgn_cmp, NULL);
+ for (i = 0; i < memsize_rgn_count; i++) {
+ phys_addr_t base, end;
+ long size;
+
+ rgn = &memsize_rgn[i];
+ base = rgn->base;
+ size = rgn->size;
+ end = base + size;
+
+ seq_printf(m, "0x%pK-0x%pK 0x%08lx ( %7lu KB ) %s %s %s\n",
+ (void *)base, (void *)end,
+ size, DIV_ROUND_UP(size, SZ_1K),
+ rgn->nomap ? "nomap" : " map",
+ rgn->reusable ? "reusable" : "unusable",
+ rgn->name);
+ if (rgn->reusable)
+ reusable += (unsigned long)rgn->size;
+ else
+ reserved += (unsigned long)rgn->size;
+ }
+
+ seq_puts(m, "\n");
+ seq_printf(m, " .unusable : %7lu KB\n",
+ DIV_ROUND_UP(reserved, SZ_1K));
+ seq_printf(m, " .reusable : %7lu KB\n",
+ DIV_ROUND_UP(reusable, SZ_1K));
+ return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(memblock_memsize);
+#endif
+
static int __init memblock_init_debugfs(void)
{
struct dentry *root = debugfs_create_dir("memblock", NULL);
@@ -2301,6 +2417,10 @@ static int __init memblock_init_debugfs(void)
debugfs_create_file("physmem", 0444, root, &physmem,
&memblock_debug_fops);
#endif
+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+ debugfs_create_file("memsize", 0444, root,
+ NULL, &memblock_memsize_fops);
+#endif

return 0;
}
--
2.25.1


2024-05-21 02:44:24

by Jaewon Kim

[permalink] [raw]
Subject: [RESEND PATCH 05/10] memblock: track memblock changed at early param

In addition to reserved-memory in device tree, an option in cmdline may
result in memblock allocation. This patch tries to distinguish memblock
changes done at early param.

A region in memsize will be created with name as the param string. And
the region size will be updated during the param function.

Signed-off-by: Jaewon Kim <[email protected]>
---
include/linux/memblock.h | 4 ++
init/main.c | 13 +++++-
mm/memblock.c | 94 +++++++++++++++++++++++++++++++++++++++-
3 files changed, 107 insertions(+), 4 deletions(-)

diff --git a/include/linux/memblock.h b/include/linux/memblock.h
index 049313871059..aef02c150f2c 100644
--- a/include/linux/memblock.h
+++ b/include/linux/memblock.h
@@ -618,11 +618,15 @@ extern void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
bool reusable);
extern void memblock_memsize_detect_hole(void);
+extern void memblock_memsize_set_name(const char *name);
+extern void memblock_memsize_unset_name(void);
#else
static inline void memblock_memsize_record(const char *name, phys_addr_t base,
phys_addr_t size, bool nomap,
bool reusable) { }
static inline void memblock_memsize_detect_hole(void) { }
+static inline void memblock_memsize_set_name(const char *name) { }
+static inline void memblock_memsize_unset_name(void) { }
#endif

#endif /* _LINUX_MEMBLOCK_H */
diff --git a/init/main.c b/init/main.c
index 206acdde51f5..17c751aac854 100644
--- a/init/main.c
+++ b/init/main.c
@@ -212,8 +212,15 @@ static bool __init obsolete_checksetup(char *line)
pr_warn("Parameter %s is obsolete, ignored\n",
p->str);
return true;
- } else if (p->setup_func(line + n))
- return true;
+ } else {
+ int ret;
+
+ memblock_memsize_set_name(p->str);
+ ret = p->setup_func(line + n);
+ memblock_memsize_unset_name();
+ if (ret)
+ return true;
+ }
}
p++;
} while (p < __setup_end);
@@ -758,8 +765,10 @@ static int __init do_early_param(char *param, char *val,
(strcmp(param, "console") == 0 &&
strcmp(p->str, "earlycon") == 0)
) {
+ memblock_memsize_set_name(p->str);
if (p->setup_func(val) != 0)
pr_warn("Malformed early option '%s'\n", param);
+ memblock_memsize_unset_name();
}
}
/* We accept everything at this stage. */
diff --git a/mm/memblock.c b/mm/memblock.c
index 9b68ddc4af5e..edb2575967ab 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -178,6 +178,18 @@ static inline phys_addr_t memblock_cap_size(phys_addr_t base, phys_addr_t *size)
return *size = min(*size, PHYS_ADDR_MAX - base);
}

+#ifdef CONFIG_MEMBLOCK_MEMSIZE
+static void memblock_memsize_record_add(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size);
+static void memblock_memsize_record_remove(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size);
+#else
+static inline void memblock_memsize_record_add(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size) { }
+static inline void memblock_memsize_record_remove(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size) { }
+#endif /* CONFIG_MEMBLOCK_MEMSIZE */
+
/*
* Address comparison utilities
*/
@@ -595,6 +607,7 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
phys_addr_t end = base + memblock_cap_size(base, &size);
int idx, nr_new, start_rgn = -1, end_rgn;
struct memblock_region *rgn;
+ phys_addr_t new_size = 0;

if (!size)
return 0;
@@ -607,7 +620,8 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
type->regions[0].flags = flags;
memblock_set_region_node(&type->regions[0], nid);
type->total_size = size;
- return 0;
+ new_size = size;
+ goto done;
}

/*
@@ -654,6 +668,7 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
memblock_insert_region(type, idx++, base,
rbase - base, nid,
flags);
+ new_size += rbase - base;
}
}
/* area below @rend is dealt with, forget about it */
@@ -669,6 +684,7 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
end_rgn = idx + 1;
memblock_insert_region(type, idx, base, end - base,
nid, flags);
+ new_size += end - base;
}
}

@@ -687,8 +703,11 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
goto repeat;
} else {
memblock_merge_regions(type, start_rgn, end_rgn);
- return 0;
}
+done:
+ if (new_size == size)
+ memblock_memsize_record_add(type, obase, size);
+ return 0;
}

/**
@@ -858,6 +877,7 @@ static int __init_memblock memblock_remove_range(struct memblock_type *type,

for (i = end_rgn - 1; i >= start_rgn; i--)
memblock_remove_region(type, i);
+ memblock_memsize_record_remove(type, base, size);
return 0;
}

@@ -2039,6 +2059,7 @@ struct memsize_rgn_struct {

static struct memsize_rgn_struct memsize_rgn[CONFIG_MAX_MEMBLOCK_MEMSIZE] __initdata_memblock;
static int memsize_rgn_count __initdata_memblock;
+static const char *memblock_memsize_name __initdata_memblock;

static void __init_memblock memsize_get_valid_name(char *valid_name, const char *name)
{
@@ -2237,6 +2258,75 @@ void __init memblock_memsize_detect_hole(void)
}
}
}
+
+/* assume that freeing region is NOT bigger than the previous region */
+static void __init_memblock memblock_memsize_free(phys_addr_t free_base,
+ phys_addr_t free_size)
+{
+ int i;
+ struct memsize_rgn_struct *rgn;
+ phys_addr_t free_end, end;
+
+ free_end = free_base + free_size - 1;
+ memblock_dbg("%s %pa..%pa\n",
+ __func__, &free_base, &free_end);
+
+ for (i = 0; i < memsize_rgn_count; i++) {
+ rgn = &memsize_rgn[i];
+
+ end = rgn->base + rgn->size;
+ if (free_base < rgn->base ||
+ free_base >= end)
+ continue;
+
+ free_end = free_base + free_size;
+ if (free_base == rgn->base) {
+ rgn->size -= free_size;
+ if (rgn->size != 0)
+ rgn->base += free_size;
+ } else if (free_end == end) {
+ rgn->size -= free_size;
+ } else {
+ memblock_memsize_record(rgn->name, free_end,
+ end - free_end, rgn->nomap, rgn->reusable);
+ rgn->size = free_base - rgn->base;
+ }
+ }
+}
+
+void __init memblock_memsize_set_name(const char *name)
+{
+ memblock_memsize_name = name;
+}
+
+void __init memblock_memsize_unset_name(void)
+{
+ memblock_memsize_name = NULL;
+}
+
+static void __init_memblock memblock_memsize_record_add(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size)
+{
+ if (memblock_memsize_name) {
+ if (type == &memblock.reserved)
+ memblock_memsize_record(memblock_memsize_name,
+ base, size, false, false);
+ else if (type == &memblock.memory)
+ memblock_memsize_free(base, size);
+ }
+}
+
+static void __init_memblock memblock_memsize_record_remove(struct memblock_type *type,
+ phys_addr_t base, phys_addr_t size)
+{
+ if (memblock_memsize_name) {
+ if (type == &memblock.reserved)
+ memblock_memsize_free(base, size);
+ else if (type == &memblock.memory)
+ memblock_memsize_record(memblock_memsize_name,
+ base, size, true, false);
+ }
+}
#endif /* MEMBLOCK_MEMSIZE */

static void __init free_memmap(unsigned long start_pfn, unsigned long end_pfn)
--
2.25.1


2024-05-21 02:53:47

by Jaewon Kim

[permalink] [raw]
Subject: RE: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

>--------- Original Message ---------
>Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
>Date : 2024-05-21 11:40 (GMT+9)
>Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>?
>Some of memory regions can be reserved for a specific purpose. They are
>usually defined through reserved-memory in device tree. If only size
>without address is specified in device tree, the address of the region
>will be determined at boot time.
>
>We may find the address of the memory regions through booting log, but
>it does not show all. And it could be hard to catch the very beginning
>log. The memblock_dump_all shows all memblock status but it does not
>show region name and its information is difficult to summarize.
>
>This patch introduce a debugfs node, memblock/memsize, to see reserved
>memory easily.
>
>Here's an example
>
>$ cat debugfs/memblock/memsize
>
>0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
>0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
>...
>0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
>
>Reserved? ? : 1223856 KB
> .kernel? ? :? 275208 KB
>? .text? ? :? 16576 KB
>? .rwdata? :? ? 1963 KB
>? .rodata? :? 11920 KB
>? .bss? ? ? :? ? 2450 KB
>? .memmap? :? 186368 KB
>? .etc? ? ? :? 55933 KB
> .unusable? :? 948648 KB
>System? ? ? : 11359056 KB
> .common? ? : 10306384 KB
> .reusable? : 1052672 KB
>Total? ? ? : 12582912 KB ( 12288.00 MB )
>
>Jaewon Kim (10):
>? memblock: introduce memsize showing reserved memory
>? memblock: detect hidden memory hole size
>? memblock: handle overlapped reserved memory region
>? memblock: take a region intersecting an unknown region
>? memblock: track memblock changed at early param
>? memblock: recognize late freed size by checking PageReserved
>? memblock: track kernel size on memsize
>? memblock: print memsize summary information
>? memblock: print kernel internal size
>? memblock: support memsize reusable to consider as reusable
>
> drivers/of/fdt.c? ? ? ? ? ? |? 11 +
> drivers/of/of_reserved_mem.c |? 12 +-
> include/linux/memblock.h? ? |? 29 ++
> init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
> kernel/dma/contiguous.c? ? ? |? 9 +-
> mm/Kconfig? ? ? ? ? ? ? ? ? |? 16 ++
> mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
> mm/mm_init.c? ? ? ? ? ? ? ? |? 6 +-
> mm/page_allocc? ? ? ? ? ? ? |? 10 +-
> 9 files changed, 597 insertions(+), 11 deletions(-)
>
>--
>2.25.1

Hello Mike

This is actually RESEND as it was introduced 2 years ago.
Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t

> But you never provided details about *why* you want this information exposed.

For your question, I'd like to say ;
We can see the same format and exact information between different version of kernel status.

1) Internally we can check if the reserved memory changes.
2) Externally we can communicate between chipset vendors and OEM, with a same format.

This helps us to communitcate well, to easily detect changes or just to see differences.

Jaewon Kim


2024-05-21 07:33:36

by Mike Rapoport

[permalink] [raw]
Subject: Re: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
> >--------- Original Message ---------
> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
> >Date : 2024-05-21 11:40 (GMT+9)
> >Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
> >?
> >Some of memory regions can be reserved for a specific purpose. They are
> >usually defined through reserved-memory in device tree. If only size
> >without address is specified in device tree, the address of the region
> >will be determined at boot time.
> >
> >We may find the address of the memory regions through booting log, but
> >it does not show all. And it could be hard to catch the very beginning
> >log. The memblock_dump_all shows all memblock status but it does not
> >show region name and its information is difficult to summarize.
> >
> >This patch introduce a debugfs node, memblock/memsize, to see reserved
> >memory easily.
> >
> >Here's an example
> >
> >$ cat debugfs/memblock/memsize
> >
> >0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
> >0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
> >...
> >0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
> >0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
> >0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
> >
> >Reserved? ? : 1223856 KB
> > .kernel? ? :? 275208 KB
> >? .text? ? :? 16576 KB
> >? .rwdata? :? ? 1963 KB
> >? .rodata? :? 11920 KB
> >? .bss? ? ? :? ? 2450 KB
> >? .memmap? :? 186368 KB
> >? .etc? ? ? :? 55933 KB
> > .unusable? :? 948648 KB
> >System? ? ? : 11359056 KB
> > .common? ? : 10306384 KB
> > .reusable? : 1052672 KB
> >Total? ? ? : 12582912 KB ( 12288.00 MB )
> >
> >Jaewon Kim (10):
> >? memblock: introduce memsize showing reserved memory
> >? memblock: detect hidden memory hole size
> >? memblock: handle overlapped reserved memory region
> >? memblock: take a region intersecting an unknown region
> >? memblock: track memblock changed at early param
> >? memblock: recognize late freed size by checking PageReserved
> >? memblock: track kernel size on memsize
> >? memblock: print memsize summary information
> >? memblock: print kernel internal size
> >? memblock: support memsize reusable to consider as reusable
> >
> > drivers/of/fdt.c? ? ? ? ? ? |? 11 +
> > drivers/of/of_reserved_mem.c |? 12 +-
> > include/linux/memblock.h? ? |? 29 ++
> > init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
> > kernel/dma/contiguous.c? ? ? |? 9 +-
> > mm/Kconfig? ? ? ? ? ? ? ? ? |? 16 ++
> > mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
> > mm/mm_init.c? ? ? ? ? ? ? ? |? 6 +-
> > mm/page_alloc.c? ? ? ? ? ? ? |? 10 +-
> > 9 files changed, 597 insertions(+), 11 deletions(-)
> >
> >--
> >2.25.1
>
> Hello Mike
>
> This is actually RESEND as it was introduced 2 years ago.
> Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
>
> > But you never provided details about *why* you want this information exposed.
>
> For your question, I'd like to say ;
> We can see the same format and exact information between different version of kernel status.
>
> 1) Internally we can check if the reserved memory changes.
> 2) Externally we can communicate between chipset vendors and OEM, with a same format.

Why the existing debugfs interface is not sufficient?

> This helps us to communitcate well, to easily detect changes or just to see differences.
>
> Jaewon Kim
>

--
Sincerely yours,
Mike.

2024-05-21 10:25:10

by Jaewon Kim

[permalink] [raw]
Subject: RE:(2) [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

>On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
>> >--------- Original Message ---------
>> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
>> >Date : 2024-05-21 11:40 (GMT+9)
>> >Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>> >?
>> >Some of memory regions can be reserved for a specific purpose. They are
>> >usually defined through reserved-memory in device tree. If only size
>> >without address is specified in device tree, the address of the region
>> >will be determined at boot time.
>> >
>> >We may find the address of the memory regions through booting log, but
>> >it does not show all. And it could be hard to catch the very beginning
>> >log. The memblock_dump_all shows all memblock status but it does not
>> >show region name and its information is difficult to summarize.
>> >
>> >This patch introduce a debugfs node, memblock/memsize, to see reserved
>> >memory easily.
>> >
>> >Here's an example
>> >
>> >$ cat debugfs/memblock/memsize
>> >
>> >0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
>> >0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
>> >...
>> >0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>> >0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>> >0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
>> >
>> >Reserved? ? : 1223856 KB
>> > .kernel? ? :? 275208 KB
>> >? .text? ? :? 16576 KB
>> >? .rwdata? :? ? 1963 KB
>> >? .rodata? :? 11920 KB
>> >? .bss? ? ? :? ? 2450 KB
>> >? .memmap? :? 186368 KB
>> >? .etc? ? ? :? 55933 KB
>> > .unusable? :? 948648 KB
>> >System? ? ? : 11359056 KB
>> > .common? ? : 10306384 KB
>> > .reusable? : 1052672 KB
>> >Total? ? ? : 12582912 KB ( 12288.00 MB )
>> >
>> >Jaewon Kim (10):
>> >? memblock: introduce memsize showing reserved memory
>> >? memblock: detect hidden memory hole size
>> >? memblock: handle overlapped reserved memory region
>> >? memblock: take a region intersecting an unknown region
>> >? memblock: track memblock changed at early param
>> >? memblock: recognize late freed size by checking PageReserved
>> >? memblock: track kernel size on memsize
>> >? memblock: print memsize summary information
>> >? memblock: print kernel internal size
>> >? memblock: support memsize reusable to consider as reusable
>> >
>> > drivers/of/fdt.c? ? ? ? ? ? |? 11 +
>> > drivers/of/of_reserved_mem.c |? 12 +-
>> > include/linux/memblock.h? ? |? 29 ++
>> > init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
>> > kernel/dma/contiguous.c? ? ? |? 9 +-
>> > mm/Kconfig? ? ? ? ? ? ? ? ? |? 16 ++
>> > mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
>> > mm/mm_init.c? ? ? ? ? ? ? ? |? 6 +-
>> > mm/page_alloc.c? ? ? ? ? ? ? |? 10 +-
>> > 9 files changed, 597 insertions(+), 11 deletions(-)
>> >
>> >--
>> >2.25.1
>>
>> Hello Mike
>>
>> This is actually RESEND as it was introduced 2 years ago.
>> Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
>>
>> > But you never provided details about *why* you want this information exposed.
>>
>> For your question, I'd like to say ;
>> We can see the same format and exact information between different version of kernel status.
>>
>> 1) Internally we can check if the reserved memory changes.
>> 2) Externally we can communicate between chipset vendors and OEM, with a same format.
>
>Why the existing debugfs interface is not sufficient?

debugfs/memblock/memory & debugfs/memblock/reserved have changed its format but still does not show name, reusable, kernel size.
If memory is reserved from memblock, and did not freed back to memblock. Memblock does not know even after the memory is freed to system.
I think a simple debug interface is needed to easily communicate with others or compare different SW releases.

>
>> This helps us to communitcate well, to easily detect changes or just to see differences.
>>
>> Jaewon Kim
>>
>
>--
>Sincerely yours,
>Mike.



2024-05-22 08:21:11

by Wei Yang

[permalink] [raw]
Subject: Re: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
>>--------- Original Message ---------
>>Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
>>Date : 2024-05-21 11:40 (GMT+9)
>>Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>>?
>>Some of memory regions can be reserved for a specific purpose. They are
>>usually defined through reserved-memory in device tree. If only size
>>without address is specified in device tree, the address of the region
>>will be determined at boot time.
>>
>>We may find the address of the memory regions through booting log, but
>>it does not show all. And it could be hard to catch the very beginning
>>log. The memblock_dump_all shows all memblock status but it does not
>>show region name and its information is difficult to summarize.
>>
>>This patch introduce a debugfs node, memblock/memsize, to see reserved
>>memory easily.
>>
>>Here's an example
>>
>>$ cat debugfs/memblock/memsize
>>
>>0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
>>0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
>>...
>>0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>>0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>>0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
>>
>>Reserved? ? : 1223856 KB
>> .kernel? ? :? 275208 KB
>>? .text? ? :? 16576 KB
>>? .rwdata? :? ? 1963 KB
>>? .rodata? :? 11920 KB
>>? .bss? ? ? :? ? 2450 KB
>>? .memmap? :? 186368 KB
>>? .etc? ? ? :? 55933 KB
>> .unusable? :? 948648 KB
>>System? ? ? : 11359056 KB
>> .common? ? : 10306384 KB
>> .reusable? : 1052672 KB
>>Total? ? ? : 12582912 KB ( 12288.00 MB )
>>
>>Jaewon Kim (10):
>>? memblock: introduce memsize showing reserved memory
>>? memblock: detect hidden memory hole size
>>? memblock: handle overlapped reserved memory region
>>? memblock: take a region intersecting an unknown region
>>? memblock: track memblock changed at early param
>>? memblock: recognize late freed size by checking PageReserved
>>? memblock: track kernel size on memsize
>>? memblock: print memsize summary information
>>? memblock: print kernel internal size
>>? memblock: support memsize reusable to consider as reusable
>>
>> drivers/of/fdt.c? ? ? ? ? ? |? 11 +
>> drivers/of/of_reserved_mem.c |? 12 +-
>> include/linux/memblock.h? ? |? 29 ++
>> init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
>> kernel/dma/contiguous.c? ? ? |? 9 +-
>> mm/Kconfig? ? ? ? ? ? ? ? ? |? 16 ++
>> mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
>> mm/mm_init.c? ? ? ? ? ? ? ? |? 6 +-
>> mm/page_allocc? ? ? ? ? ? ? |? 10 +-
>> 9 files changed, 597 insertions(+), 11 deletions(-)
>>
>>--
>>2.25.1
>
>Hello Mike
>
>This is actually RESEND as it was introduced 2 years ago.
>Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
>
>> But you never provided details about *why* you want this information exposed.
>
>For your question, I'd like to say ;
>We can see the same format and exact information between different version of kernel status.
>
>1) Internally we can check if the reserved memory changes.
>2) Externally we can communicate between chipset vendors and OEM, with a same format.
>

Maybe you can show the log difference, so that we can see how it helps you.

>This helps us to communitcate well, to easily detect changes or just to see differences.
>
>Jaewon Kim
>

--
Wei Yang
Help you, Help me

2024-05-22 08:22:27

by Wei Yang

[permalink] [raw]
Subject: Re: (2) [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Tue, May 21, 2024 at 07:17:53PM +0900, Jaewon Kim wrote:
>>On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
>>> >--------- Original Message ---------
>>> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
>>> >Date : 2024-05-21 11:40 (GMT+9)
>>> >Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>>> >?
>>> >Some of memory regions can be reserved for a specific purpose. They are
>>> >usually defined through reserved-memory in device tree. If only size
>>> >without address is specified in device tree, the address of the region
>>> >will be determined at boot time.
>>> >
>>> >We may find the address of the memory regions through booting log, but
>>> >it does not show all. And it could be hard to catch the very beginning
>>> >log. The memblock_dump_all shows all memblock status but it does not
>>> >show region name and its information is difficult to summarize.
>>> >
>>> >This patch introduce a debugfs node, memblock/memsize, to see reserved
>>> >memory easily.
>>> >
>>> >Here's an example
>>> >
>>> >$ cat debugfs/memblock/memsize
>>> >
>>> >0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
>>> >0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
>>> >...
>>> >0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>>> >0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>>> >0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
>>> >
>>> >Reserved? ? : 1223856 KB
>>> > .kernel? ? :? 275208 KB
>>> >? .text? ? :? 16576 KB
>>> >? .rwdata? :? ? 1963 KB
>>> >? .rodata? :? 11920 KB
>>> >? .bss? ? ? :? ? 2450 KB
>>> >? .memmap? :? 186368 KB
>>> >? .etc? ? ? :? 55933 KB
>>> > .unusable? :? 948648 KB
>>> >System? ? ? : 11359056 KB
>>> > .common? ? : 10306384 KB
>>> > .reusable? : 1052672 KB
>>> >Total? ? ? : 12582912 KB ( 12288.00 MB )
>>> >
>>> >Jaewon Kim (10):
>>> >? memblock: introduce memsize showing reserved memory
>>> >? memblock: detect hidden memory hole size
>>> >? memblock: handle overlapped reserved memory region
>>> >? memblock: take a region intersecting an unknown region
>>> >? memblock: track memblock changed at early param
>>> >? memblock: recognize late freed size by checking PageReserved
>>> >? memblock: track kernel size on memsize
>>> >? memblock: print memsize summary information
>>> >? memblock: print kernel internal size
>>> >? memblock: support memsize reusable to consider as reusable
>>> >
>>> > drivers/of/fdt.c? ? ? ? ? ? |? 11 +
>>> > drivers/of/of_reserved_mem.c |? 12 +-
>>> > include/linux/memblock.h? ? |? 29 ++
>>> > init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
>>> > kernel/dma/contiguous.c? ? ? |? 9 +-
>>> > mm/Kconfig? ? ? ? ? ? ? ? ? |? 16 ++
>>> > mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
>>> > mm/mm_init.c? ? ? ? ? ? ? ? |? 6 +-
>>> > mm/page_alloc.c? ? ? ? ? ? ? |? 10 +-
>>> > 9 files changed, 597 insertions(+), 11 deletions(-)
>>> >
>>> >--
>>> >2.25.1
>>>
>>> Hello Mike
>>>
>>> This is actually RESEND as it was introduced 2 years ago.
>>> Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
>>>
>>> > But you never provided details about *why* you want this information exposed.
>>>
>>> For your question, I'd like to say ;
>>> We can see the same format and exact information between different version of kernel status.
>>>
>>> 1) Internally we can check if the reserved memory changes.
>>> 2) Externally we can communicate between chipset vendors and OEM, with a same format.
>>
>>Why the existing debugfs interface is not sufficient?
>
>debugfs/memblock/memory & debugfs/memblock/reserved have changed its format but still does not show name, reusable, kernel size.

Would you mind showing which information matters to you most in the following
example log message? What you expect to see and helps you on locating problem?

0x0000000000000000-0x0000000000000000 0x02000000 ( 32768 KB ) map reusable linux,cma
0x0000000000000000-0x0000000000000000 0x01000000 ( 16384 KB ) map reusable vxxxxx
.
0x0000000000000000-0x0000000000000000 0x004e0000 ( 4992 KB ) nomap unusable unknown
0x0000000000000000-0x0000000000000000 0x00400000 ( 4096 KB ) nomap unusable cxxxxx
0x0000000000000000-0x0000000000000000 0x00e00000 ( 14336 KB ) nomap unusable gxxxxx

Reserved : 1223856 KB
.kernel : 275208 KB
.text : 16576 KB
.rwdata : 1963 KB
.rodata : 11920 KB
.bss : 2450 KB
.memmap : 186368 KB
.etc : 55933 KB
.unusable : 948648 KB
System : 11359056 KB
.common : 10306384 KB
.reusable : 1052672 KB
Total : 12582912 KB ( 12288.00 MB )

>If memory is reserved from memblock, and did not freed back to memblock. Memblock does not know even after the memory is freed to system.

You mean we may reserve memory in memblock.reserved, but still have it freed
to system? This sounds a bug to me.

>I think a simple debug interface is needed to easily communicate with others or compare different SW releases.
>
>>
>>> This helps us to communitcate well, to easily detect changes or just to see differences.
>>>
>>> Jaewon Kim
>>>
>>
>>--
>>Sincerely yours,
>>Mike.
>
>

--
Wei Yang
Help you, Help me

2024-05-22 08:47:56

by Jaewon Kim

[permalink] [raw]
Subject: RE: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

>Sender : Wei Yang <[email protected]>
>Date : 2024-05-22 17:16 (GMT+9)
>Title : Re: (2) [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>?
>On Tue, May 21, 2024 at 07:17:53PM +0900, Jaewon Kim wrote:
>>>On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
>>>> >--------- Original Message ---------
>>>> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
>>>> >Date? : 2024-05-21 11:40 (GMT+9)
>>>> >Title? : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
>>>> >?
>>>> >Some of memory regions can be reserved for a specific purpose. They are
>>>> >usually defined through reserved-memory in device tree. If only size
>>>> >without address is specified in device tree, the address of the region
>>>> >will be determined at boot time.
>>>> >
>>>> >We may find the address of the memory regions through booting log, but
>>>> >it does not show all. And it could be hard to catch the very beginning
>>>> >log. The memblock_dump_all shows all memblock status but it does not
>>>> >show region name and its information is difficult to summarize.
>>>> >
>>>> >This patch introduce a debugfs node, memblock/memsize, to see reserved
>>>> >memory easily.
>>>> >
>>>> >Here's an example
>>>> >
>>>> >$ cat debugfs/memblock/memsize
>>>> >
>>>> >0x0000000000000000-0x0000000000000000 0x02000000 (?? 32768 KB )?? map reusable linux,cma
>>>> >0x0000000000000000-0x0000000000000000 0x01000000 (?? 16384 KB )?? map reusable vxxxxx
>>>> >...
>>>> >0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>>>> >0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>>>> >0x0000000000000000-0x0000000000000000 0x00e00000 (?? 14336 KB ) nomap unusable gxxxxx
>>>> >
>>>> >Reserved? ? : 1223856 KB
>>>> > .kernel? ? :? 275208 KB
>>>> >? .text? ?? :?? 16576 KB
>>>> >? .rwdata?? :? ? 1963 KB
>>>> >? .rodata?? :?? 11920 KB
>>>> >? .bss? ? ? :? ? 2450 KB
>>>> >? .memmap?? :? 186368 KB
>>>> >? .etc? ? ? :?? 55933 KB
>>>> > .unusable? :? 948648 KB
>>>> >System? ? ? : 11359056 KB
>>>> > .common? ? : 10306384 KB
>>>> > .reusable? : 1052672 KB
>>>> >Total? ? ?? : 12582912 KB ( 12288.00 MB )
>>>> >
>>>> >Jaewon Kim (10):
>>>> >? memblock: introduce memsize showing reserved memory
>>>> >? memblock: detect hidden memory hole size
>>>> >? memblock: handle overlapped reserved memory region
>>>> >? memblock: take a region intersecting an unknown region
>>>> >? memblock: track memblock changed at early param
>>>> >? memblock: recognize late freed size by checking PageReserved
>>>> >? memblock: track kernel size on memsize
>>>> >? memblock: print memsize summary information
>>>> >? memblock: print kernel internal size
>>>> >? memblock: support memsize reusable to consider as reusable
>>>> >
>>>> > drivers/of/fdt.c? ? ? ? ? ?? |? 11 +
>>>> > drivers/of/of_reserved_mem.c |? 12 +-
>>>> > include/linux/memblock.h? ?? |? 29 ++
>>>> > init/main.c? ? ? ? ? ? ? ? ? |? 13 +-
>>>> > kernel/dma/contiguous.c? ? ? |?? 9 +-
>>>> > mm/Kconfig? ? ? ? ? ? ? ? ?? |? 16 ++
>>>> > mm/memblock.c? ? ? ? ? ? ? ? | 502 ++++++++++++++++++++++++++++++++++-
>>>> > mm/mm_init.c? ? ? ? ? ? ? ?? |?? 6 +-
>>>> > mm/page_alloc.c? ? ? ? ? ? ? |? 10 +-
>>>> > 9 files changed, 597 insertions(+), 11 deletions(-)
>>>> >
>>>> >--
>>>> >2.25.1
>>>>
>>>> Hello Mike
>>>>
>>>> This is actually RESEND as it was introduced 2 years ago.
>>>> Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
>>>>
>>>> > But you never provided details about *why* you want this information exposed.
>>>>
>>>> For your question, I'd like to say ;
>>>> We can see the same format and exact information between different version of kernel status.
>>>>
>>>> 1) Internally we can check if the reserved memory changes.
>>>> 2) Externally we can communicate between chipset vendors and OEM, with a same format.


Hi

> Maybe you can show the log difference, so that we can see how it helps you.

For your new email, could you elaborate the difference you meant?
Do you mean difference between existing debugfs membock interfaces and the one I introdued here?


>>>
>>>Why the existing debugfs interface is not sufficient?
>>
>>debugfs/memblock/memory & debugfs/memblock/reserved have changed its format but still does not show name, reusable, kernel size.
>
>Would you mind showing which information matters to you most in the following
>example log message? What you expect to see and helps you on locating problem?
>
>0x0000000000000000-0x0000000000000000 0x02000000 (? 32768 KB )? map reusable linux,cma
>0x0000000000000000-0x0000000000000000 0x01000000 (? 16384 KB )? map reusable vxxxxx
>..
>0x0000000000000000-0x0000000000000000 0x004e0000 (? ? 4992 KB ) nomap unusable unknown
>0x0000000000000000-0x0000000000000000 0x00400000 (? ? 4096 KB ) nomap unusable cxxxxx
>0x0000000000000000-0x0000000000000000 0x00e00000 (? 14336 KB ) nomap unusable gxxxxx
>
>Reserved? ? : 1223856 KB
> .kernel? ? :? 275208 KB
>? .text? ? :? 16576 KB
>? .rwdata? :? ? 1963 KB
>? .rodata? :? 11920 KB
>? .bss? ? ? :? ? 2450 KB
>? .memmap? :? 186368 KB
>? .etc? ? ? :? 55933 KB
> .unusable? :? 948648 KB
>System? ? ? : 11359056 KB
> .common? ? : 10306384 KB
> .reusable? : 1052672 KB
>Total? ? ? : 12582912 KB ( 12288.00 MB )
>


I need all those information actually. address, size, map/nomap, reusable/unusable,
name. For me it was very helpful to rearrange the memory regions as it shows clearly.
The address could be seen after allowing it through /proc/sys/kernel/kptr_restrict.

Kernel size information is also helpful to me. The memmap size for struct pages
could be increased according to DRAM memory size. By rearranging the reserved regions
to be packed we can save memmap memory, then we can see the results easily from this.
We can compare other text, ro, rw, etc so that we can find which part of kernel has
changed.


>>If memory is reserved from memblock, and did not freed back to memblock. Memblock does not know even after the memory is freed to system.
>
>You mean we may reserve memory in memblock.reserved, but still have it freed
>to system? This sounds a bug to me.

I mean something like free_reserved_area. The reserved free pages would be free to
system buddy allocator directly without reporting it to memblock.

>
>>I think a simple debug interface is needed to easily communicate with others or compare different SW releases.
>>
>>>
>>>> This helps us to communitcate well, to easily detect changes or just to see differences.
>>>>
>>>> Jaewon Kim
>>>>
>>>
>>>--
>>>Sincerely yours,
>>>Mike.
>>
>>
>
>--
>Wei Yang
>Help you, Help me
>




2024-05-22 18:53:40

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 09/10] memblock: print kernel internal size

Hi Jaewon,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on robh/for-next linus/master]
[cannot apply to rppt-memblock/for-next v6.9 next-20240522]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jaewon-Kim/memblock-introduce-memsize-showing-reserved-memory/20240521-104201
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240521023957.2587005-10-jaewon31.kim%40samsung.com
patch subject: [RESEND PATCH 09/10] memblock: print kernel internal size
config: x86_64-randconfig-r052-20240522 (https://download.01.org/0day-ci/archive/20240523/[email protected]/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240523/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in vmlinux.o
>> WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0x11 (section: .text) -> memsize_memap (section: .meminit.data)
WARNING: modpost: missing MODULE_DESCRIPTION() in arch/x86/kernel/cpu/mce/mce-inject.o
WARNING: modpost: missing MODULE_DESCRIPTION() in arch/x86/crypto/curve25519-x86_64.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/locking/locktorture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/locking/test-ww_mutex.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcutorture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcuscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/refscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/time/clocksource-wdtest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/time/time_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/torture.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/resource_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/sysctl-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/kasan/kasan_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/dmapool_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/hwpoison-inject.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/fat/fat_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nfs/nfsv4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp737.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp860.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp864.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp936.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp949.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1251.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-1.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-6.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp1255.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-15.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-r.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-gaelic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-turkish.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/cramfs/cramfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/isofs/isofs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/hfs/hfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/smb/common/cifs_arc4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/smb/common/cifs_md4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/qnx4/qnx4.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/qnx6/qnx6.o
WARNING: modpost: missing MODULE_DESCRIPTION() in crypto/curve25519-generic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit-example-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/math/rational-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/string_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/string_helpers_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/find_bit_benchmark.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_firmware.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/cpumask_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_hash.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_ida.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_list_sort.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_module.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_sort.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_static_keys.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_static_key_base.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_printf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_bitmap.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_maple_tree.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_free_pages.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_kprobes.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_ref_tracker.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/atomic64_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/bitfield_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/checksum_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/list-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/hashtable_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/test_bits.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/cmdline_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/slub_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/memcpy_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/is_signed_type_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/overflow_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/stackinit_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/fortify_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/siphash_kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pinctrl/pinctrl-mcp23s08_i2c.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/platform_lcd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/clk_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/clk-gate_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/clk/clk-fractional-divider_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/qcom/hdma.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/dmatest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/rt4831-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/ttynull.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/lp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/ppdev.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/tlclk.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_kunit_helpers.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_buddy_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_cmdline_parser_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_connector_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_damage_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_dp_mst_helper_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_exec_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_format_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_framebuffer_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_gem_shmem_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_managed_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_mm_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/gpu/drm/tests/drm_modes_test.o

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-22 19:03:37

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 07/10] memblock: track kernel size on memsize

Hi Jaewon,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on robh/for-next linus/master]
[cannot apply to rppt-memblock/for-next v6.9 next-20240522]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jaewon-Kim/memblock-introduce-memsize-showing-reserved-memory/20240521-104201
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240521023957.2587005-8-jaewon31.kim%40samsung.com
patch subject: [RESEND PATCH 07/10] memblock: track kernel size on memsize
config: parisc-randconfig-r132-20240522 (https://download.01.org/0day-ci/archive/20240523/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240523/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in vmlinux.o
>> WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0xc (section: .text) -> memsize_kinit (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0x10 (section: .text) -> memsize_kinit (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0x18 (section: .text) -> memsize_kinit (section: .meminit.data)
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcuscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/time/time_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/dmapool_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/fat/fat_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp775.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp865.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp866.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp869.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp936.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-5.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-14.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-u.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-ru.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-cyrillic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-gaelic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-iceland.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-romanian.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-roman.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-turkish.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/binfmt_script.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/ext4/ext4-inode-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/jbd2/jbd2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/btrfs/btrfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/bcachefs/mean_and_variance_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in security/keys/trusted-keys/trusted.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit-example-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/math/prime_numbers.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/asn1_encoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/irqchip/irq-meson-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/dwc/pci-exynos.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-altera.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-altera-msi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-mediatek-gen3.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/platform_lcd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/rt4831-backlight.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_accel.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_DAC1064.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_Ti3026.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/macmodes.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/via/viafb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/kyro/kyrofb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/qcom/hdma_mgmt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/ti/omap-dma.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/dmatest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/imx/soc-imx8m.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/ixp4xx/ixp4xx-qmgr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/max20411-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/rt4831-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/reset/hisilicon/hi6220_reset.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/8250_pxa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/serial_cs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/hw_random/omap-rng.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/lp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/ppdev.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iommu/iova.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-raw-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-spmi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-w1.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/block/loop.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/arizona.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/pcf50633-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/rt4831.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dax/dax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_cmdset_0020.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/lib_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/rtc-tps65910.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-ccgx-ucsi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-ali1563.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-pxa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/i2c/uda1342.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/tuners/tda9887.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/dvb-frontends/au8522_decoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/dvb-frontends/mb86a16.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/rc-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/common/videobuf2/videobuf2-dvb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/pci/saa7134/saa7134-empress.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/pci/saa7134/saa7134-dvb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-async.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-fwnode.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/power/reset/piix4-poweroff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/watchdog/omap_wdt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/watchdog/menz69_wdt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/mmc_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_simpleondemand.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_userspace.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/perf/fsl_imx8_ddr_perf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem-apple-efuses.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mm-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mn-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mp-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/parport/parport.o

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-22 22:41:39

by kernel test robot

[permalink] [raw]
Subject: Re: [RESEND PATCH 10/10] memblock: support memsize reusable to consider as reusable

Hi Jaewon,

kernel test robot noticed the following build warnings:

[auto build test WARNING on akpm-mm/mm-everything]
[also build test WARNING on robh/for-next linus/master]
[cannot apply to rppt-memblock/for-next v6.9 next-20240522]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Jaewon-Kim/memblock-introduce-memsize-showing-reserved-memory/20240521-104201
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20240521023957.2587005-11-jaewon31.kim%40samsung.com
patch subject: [RESEND PATCH 10/10] memblock: support memsize reusable to consider as reusable
config: parisc-randconfig-r132-20240522 (https://download.01.org/0day-ci/archive/20240523/[email protected]/config)
compiler: hppa-linux-gcc (GCC) 13.2.0
reproduce: (https://download.01.org/0day-ci/archive/20240523/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>, old ones prefixed by <<):

WARNING: modpost: missing MODULE_DESCRIPTION() in vmlinux.o
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0xc (section: .text) -> memsize_kinit (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0x10 (section: .text) -> memsize_kinit (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_kernel_size+0x18 (section: .text) -> memsize_kinit (section: .meminit.data)
>> WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_reusable_size+0xc (section: .text) -> memsize_reusable_size (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_reusable_size+0x10 (section: .text) -> memsize_reusable_size (section: .meminit.data)
WARNING: modpost: vmlinux: section mismatch in reference: memblock_memsize_mod_reusable_size+0x18 (section: .text) -> memsize_reusable_size (section: .meminit.data)
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/rcu/rcuscale.o
WARNING: modpost: missing MODULE_DESCRIPTION() in kernel/time/time_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in mm/dmapool_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/fat/fat_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp437.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp775.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp865.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp866.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp869.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_cp936.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-5.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_iso8859-14.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-u.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_koi8-ru.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-cyrillic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-gaelic.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-iceland.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-romanian.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-roman.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/mac-turkish.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/nls/nls_ucs2_utils.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/binfmt_script.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/ext4/ext4-inode-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/jbd2/jbd2.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/btrfs/btrfs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in fs/bcachefs/mean_and_variance_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in security/keys/trusted-keys/trusted.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/kunit/kunit-example-test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/math/prime_numbers.o
WARNING: modpost: missing MODULE_DESCRIPTION() in lib/asn1_encoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/irqchip/irq-meson-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/dwc/pci-exynos.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-altera.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-altera-msi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/pci/controller/pcie-mediatek-gen3.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/platform_lcd.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/backlight/rt4831-backlight.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_accel.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_DAC1064.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/matrox/matroxfb_Ti3026.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/macmodes.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/via/viafb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/video/fbdev/kyro/kyrofb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/qcom/hdma_mgmt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/ti/omap-dma.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dma/dmatest.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/imx/soc-imx8m.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/soc/ixp4xx/ixp4xx-qmgr.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/max20411-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/regulator/rt4831-regulator.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/reset/hisilicon/hi6220_reset.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/8250_pxa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/tty/serial/8250/serial_cs.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/hw_random/omap-rng.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/lp.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/char/ppdev.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/iommu/iova.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-kunit.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-raw-ram.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-spmi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/base/regmap/regmap-w1.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/block/loop.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/arizona.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/pcf50633-gpio.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mfd/rt4831.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/dax/dax.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mtd/chips/cfi_cmdset_0020.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/lib_test.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/rtc/rtc-tps65910.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-ccgx-ucsi.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-ali1563.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/i2c/busses/i2c-pxa.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/i2c/uda1342.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/tuners/tda9887.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/dvb-frontends/au8522_decoder.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/dvb-frontends/mb86a16.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/rc/rc-core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/common/videobuf2/videobuf2-dvb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/pci/saa7134/saa7134-empress.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/pci/saa7134/saa7134-dvb.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-async.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/media/v4l2-core/v4l2-fwnode.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/power/reset/piix4-poweroff.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/watchdog/omap_wdt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/watchdog/menz69_wdt.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/mmc/core/mmc_core.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_simpleondemand.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_performance.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/devfreq/governor_userspace.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/perf/fsl_imx8_ddr_perf.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/hwtracing/intel_th/intel_th_msu_sink.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/nvmem/nvmem-apple-efuses.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mm-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mn-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/interconnect/imx/imx8mp-interconnect.o
WARNING: modpost: missing MODULE_DESCRIPTION() in drivers/parport/parport.o

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

2024-05-23 08:56:04

by Wei Yang

[permalink] [raw]
Subject: Re: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Wed, May 22, 2024 at 05:47:38PM +0900, Jaewon Kim wrote:
[...]
>
>Hi
>
>> Maybe you can show the log difference, so that we can see how it helps you.
>
>For your new email, could you elaborate the difference you meant?
>Do you mean difference between existing debugfs membock interfaces and the one I introdued here?
>

You mentioned the difference between kernel version helps you locate the
problem. That is the difference of your new debugfs.


--
Wei Yang
Help you, Help me

2024-05-23 09:28:34

by Jaewon Kim

[permalink] [raw]
Subject: RE: [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

>[...]
>>
>>Hi
>>
>>> Maybe you can show the log difference, so that we can see how it helps you.
>>
>>For your new email, could you elaborate the difference you meant?
>>Do you mean difference between existing debugfs membock interfaces and the one I introdued here?
>>
>
>You mentioned the difference between kernel version helps you locate the
>problem. That is the difference of your new debugfs.

Correct. Actually we get many SW release from chipset vendors. Even though
their kernel version is same, the reserved memory status varies. So we can
easily compare them.

BR

>
>
>--
>Wei Yang
>Help you, Help me

2024-05-23 14:36:55

by Mike Rapoport

[permalink] [raw]
Subject: Re: (2) [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Tue, May 21, 2024 at 07:17:53PM +0900, Jaewon Kim wrote:
> >On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
> >> >--------- Original Message ---------
> >> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
> >> >Date : 2024-05-21 11:40 (GMT+9)
> >> >Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
> >> >?
> >> >Some of memory regions can be reserved for a specific purpose. They are
> >> >usually defined through reserved-memory in device tree. If only size
> >> >without address is specified in device tree, the address of the region
> >> >will be determined at boot time.
> >> >
> >> >We may find the address of the memory regions through booting log, but
> >> >it does not show all. And it could be hard to catch the very beginning
> >> >log. The memblock_dump_all shows all memblock status but it does not
> >> >show region name and its information is difficult to summarize.
> >> >
> >> >This patch introduce a debugfs node, memblock/memsize, to see reserved
> >> >memory easily.
> >>
> >> This is actually RESEND as it was introduced 2 years ago.
> >> Please refer to https://lore.kernel.org/linux-mm/[email protected]/#t
> >>
> >> > But you never provided details about *why* you want this information exposed.
> >>
> >> For your question, I'd like to say ;
> >> We can see the same format and exact information between different version of kernel status.
> >>
> >> 1) Internally we can check if the reserved memory changes.
> >> 2) Externally we can communicate between chipset vendors and OEM, with a same format.
> >
> >Why the existing debugfs interface is not sufficient?
>
> debugfs/memblock/memory & debugfs/memblock/reserved have changed its
> format but still does not show name, reusable, kernel size. If memory is
> reserved from memblock, and did not freed back to memblock. Memblock does
> not know even after the memory is freed to system. I think a simple
> debug interface is needed to easily communicate with others or compare
> different SW releases.

I still don't understand what problem are you trying to solve with these
patches.

--
Sincerely yours,
Mike.

2024-05-24 17:33:59

by Pintu Agarwal

[permalink] [raw]
Subject: Re: (2) [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory

On Thu, 23 May 2024 at 20:06, Mike Rapoport <[email protected]> wrote:
>
> On Tue, May 21, 2024 at 07:17:53PM +0900, Jaewon Kim wrote:
> > >On Tue, May 21, 2024 at 11:53:29AM +0900, Jaewon Kim wrote:
> > >> >--------- Original Message ---------
> > >> >Sender : 김재원 <[email protected]>System Performance Lab.(MX)/삼성전자
> > >> >Date : 2024-05-21 11:40 (GMT+9)
> > >> >Title : [RESEND PATCH 00/10] memblock: introduce memsize showing reserved memory
> > >> >?
> > >> >Some of memory regions can be reserved for a specific purpose. They are
> > >> >usually defined through reserved-memory in device tree. If only size
> > >> >without address is specified in device tree, the address of the region
> > >> >will be determined at boot time.
> > >> >
> > >> >We may find the address of the memory regions through booting log, but
> > >> >it does not show all. And it could be hard to catch the very beginning
> > >> >log. The memblock_dump_all shows all memblock status but it does not
> > >> >show region name and its information is difficult to summarize.

Something similar, we have already proposed almost 10 years ago for memblock.
That time I realised some of these reserved memory break-up becomes
useful and handy when we are gathering reserved memory stats on a
small embedded device where every bit of memory reserved is important
and being questioned.

You can get some information about Kernel reserved from dmesg | grep
-i Memory (including the kernel init, text, data) and the cma-reserved
as well. Here the cma-reserved was added by me.

You can also get these Kernel reserved size info from vmlinux.
size -t vmlinux