mm/memblock: remove empty dummy entry
Subsystems (3)
PATCH v3 1/1 mm/memblock: remove empty dummy entry
The dummy entry is introduced in the initial implementation of lmb in commit 7c8c6b9776fb ("powerpc: Merge lmb.c and make MM initialization use it.").
As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later.
* This simplifies the lmb_add() code below...
*/While current code is reimplemented by Tejun in commit 784656f9c680 ("memblock: Reimplement memblock_add_region()"). This empty dummy entry seems not benefit the code any more.
Let's remove it.
---
v2: remove cnt initialization to 0 and keep special case for empty array
v3: reset cnt to 0 in memblock test
--- mm/memblock.c | 7 ++----- tools/testing/memblock/tests/basic_api.c | 8 ++++---- tools/testing/memblock/tests/common.c | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-)
mm/memblock.c +2 -5
@@ -114,12 +114,10 @@ static struct memblock_region memblock_physmem_init_regions[INIT_PHYSMEM_REGIONS struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, - .memory.cnt =1 ,/* empty dummy entry */ .memory.max =INIT_MEMBLOCK_MEMORY_REGIONS , .memory.name ="memory" , .reserved.regions = memblock_reserved_init_regions, - .reserved.cnt =1 ,/* empty dummy entry */ .reserved.max =INIT_MEMBLOCK_RESERVED_REGIONS , .reserved.name ="reserved" ,
@@ -130,7 +128,6 @@ struct memblock memblock __initdata_memblock = {#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP struct memblock_type physmem = { .regions = memblock_physmem_init_regions, - .cnt =1 ,/* empty dummy entry */ .max =INIT_PHYSMEM_REGIONS , .name ="physmem" , };
@@ -356,7 +353,6 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u/* Special case for empty arrays */ if (type->cnt ==0 ) {WARN_ON (type->total_size !=0 ); - type->cnt =1 ; type->regions[0 ].base =0 ; type->regions[0 ].size =0 ; type->regions[0 ].flags =0 ;
@@ -600,12 +596,13 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,/* special case for empty array */ if (type->regions[0 ].size ==0 ) { -WARN_ON (type->cnt !=1 || type->total_size); +WARN_ON (type->cnt !=0 || type->total_size); type->regions[0 ].base = base; type->regions[0 ].size = size; type->regions[0 ].flags = flags;memblock_set_region_node (&type->regions[0 ], nid); type->total_size = size; + type->cnt =1 ;return 0 ; }
tools/testing/memblock/tests/basic_api.c +4 -4
@@ -15,12 +15,12 @@ static int memblock_initialization_check(void)PREFIX_PUSH ();ASSERT_NE (memblock.memory.regions,NULL ); -ASSERT_EQ (memblock.memory.cnt,1 ); +ASSERT_EQ (memblock.memory.cnt,0 );ASSERT_EQ (memblock.memory.max,EXPECTED_MEMBLOCK_REGIONS );ASSERT_EQ (strcmp (memblock.memory.name,"memory" ),0 );ASSERT_NE (memblock.reserved.regions,NULL ); -ASSERT_EQ (memblock.reserved.cnt,1 ); +ASSERT_EQ (memblock.reserved.cnt,0 );ASSERT_EQ (memblock.memory.max,EXPECTED_MEMBLOCK_REGIONS );ASSERT_EQ (strcmp (memblock.reserved.name,"reserved" ),0 );
@@ -1295,7 +1295,7 @@ static int memblock_remove_only_region_check(void)ASSERT_EQ (rgn->base,0 );ASSERT_EQ (rgn->size,0 ); -ASSERT_EQ (memblock.memory.cnt,1 ); +ASSERT_EQ (memblock.memory.cnt,0 );ASSERT_EQ (memblock.memory.total_size,0 );test_pass_pop ();
@@ -1723,7 +1723,7 @@ static int memblock_free_only_region_check(void)ASSERT_EQ (rgn->base,0 );ASSERT_EQ (rgn->size,0 ); -ASSERT_EQ (memblock.reserved.cnt,1 ); +ASSERT_EQ (memblock.reserved.cnt,0 );ASSERT_EQ (memblock.reserved.total_size,0 );test_pass_pop ();
tools/testing/memblock/tests/common.c +2 -2
@@ -40,13 +40,13 @@ void reset_memblock_regions(void) {memset (memblock.memory.regions,0 , memblock.memory.cnt *sizeof (struct memblock_region )); - memblock.memory.cnt =1 ; + memblock.memory.cnt =0 ; memblock.memory.max =INIT_MEMBLOCK_REGIONS ; memblock.memory.total_size =0 ;memset (memblock.reserved.regions,0 , memblock.reserved.cnt *sizeof (struct memblock_region )); - memblock.reserved.cnt =1 ; + memblock.reserved.cnt =0 ; memblock.reserved.max =INIT_MEMBLOCK_RESERVED_REGIONS ; memblock.reserved.total_size =0 ; }
Signature · 1 line
2.34.1
Mike Rapoport
maintainerQuoted 56 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>---
v2: remove cnt initialization to 0 and keep special case for empty array
v3: reset cnt to 0 in memblock test--- mm/memblock.c | 7 ++----- tools/testing/memblock/tests/basic_api.c | 8 ++++---- tools/testing/memblock/tests/common.c | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-)mm/memblock.c +0
-3@@ -114,12 +114,10 @@ static struct memblock_region memblock_physmem_init_regions[INIT_PHYSMEM_REGIONS struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, - .memory.cnt =1 ,/* empty dummy entry */ .memory.max =INIT_MEMBLOCK_MEMORY_REGIONS , .memory.name ="memory" , .reserved.regions = memblock_reserved_init_regions, - .reserved.cnt =1 ,/* empty dummy entry */ .reserved.max =INIT_MEMBLOCK_RESERVED_REGIONS , .reserved.name ="reserved" ,@@ -130,7 +128,6 @@ struct memblock memblock __initdata_memblock = {#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP struct memblock_type physmem = { .regions = memblock_physmem_init_regions, - .cnt =1 ,/* empty dummy entry */ .max =INIT_PHYSMEM_REGIONS , .name ="physmem" , };
mm/memblock.c static void __init_memblock memblock_remove_region(struct memblock_type *type, u · line 359
Quoted 4 lines
mm/memblock.c +0
-1@@ -356,7 +353,6 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u/* Special case for empty arrays */ if (type->cnt ==0 ) {WARN_ON (type->total_size !=0 ); - type->cnt =1 ;
Sorry if I wasn't clear, I meant to keep special case only in memblock_add_range. Here I think
WARN_ON(type->cnt == 0 && type->total_size != 0);
should be enough.
Quoted 78 lines
mm/memblock.c +2
-1type->regions[0 ].base =0 ; type->regions[0 ].size =0 ; type->regions[0 ].flags =0 ;@@ -600,12 +596,13 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,/* special case for empty array */ if (type->regions[0 ].size ==0 ) { -WARN_ON (type->cnt !=1 || type->total_size); +WARN_ON (type->cnt !=0 || type->total_size); type->regions[0 ].base = base; type->regions[0 ].size = size; type->regions[0 ].flags = flags;memblock_set_region_node (&type->regions[0 ], nid); type->total_size = size; + type->cnt =1 ;return 0 ; }tools/testing/memblock/tests/basic_api.c +4
-4@@ -15,12 +15,12 @@ static int memblock_initialization_check(void)PREFIX_PUSH ();ASSERT_NE (memblock.memory.regions,NULL ); -ASSERT_EQ (memblock.memory.cnt,1 ); +ASSERT_EQ (memblock.memory.cnt,0 );ASSERT_EQ (memblock.memory.max,EXPECTED_MEMBLOCK_REGIONS );ASSERT_EQ (strcmp (memblock.memory.name,"memory" ),0 );ASSERT_NE (memblock.reserved.regions,NULL ); -ASSERT_EQ (memblock.reserved.cnt,1 ); +ASSERT_EQ (memblock.reserved.cnt,0 );ASSERT_EQ (memblock.memory.max,EXPECTED_MEMBLOCK_REGIONS );ASSERT_EQ (strcmp (memblock.reserved.name,"reserved" ),0 );@@ -1295,7 +1295,7 @@ static int memblock_remove_only_region_check(void)ASSERT_EQ (rgn->base,0 );ASSERT_EQ (rgn->size,0 ); -ASSERT_EQ (memblock.memory.cnt,1 ); +ASSERT_EQ (memblock.memory.cnt,0 );ASSERT_EQ (memblock.memory.total_size,0 );test_pass_pop ();@@ -1723,7 +1723,7 @@ static int memblock_free_only_region_check(void)ASSERT_EQ (rgn->base,0 );ASSERT_EQ (rgn->size,0 ); -ASSERT_EQ (memblock.reserved.cnt,1 ); +ASSERT_EQ (memblock.reserved.cnt,0 );ASSERT_EQ (memblock.reserved.total_size,0 );test_pass_pop ();tools/testing/memblock/tests/common.c +2
-2@@ -40,13 +40,13 @@ void reset_memblock_regions(void) {memset (memblock.memory.regions,0 , memblock.memory.cnt *sizeof (struct memblock_region )); - memblock.memory.cnt =1 ; + memblock.memory.cnt =0 ; memblock.memory.max =INIT_MEMBLOCK_REGIONS ; memblock.memory.total_size =0 ;memset (memblock.reserved.regions,0 , memblock.reserved.cnt *sizeof (struct memblock_region )); - memblock.reserved.cnt =1 ; + memblock.reserved.cnt =0 ; memblock.reserved.max =INIT_MEMBLOCK_RESERVED_REGIONS ; memblock.reserved.total_size =0 ; }Signature · 1 line
2.34.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 65 lines · Mike Rapoport
Quoted 56 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>---
v2: remove cnt initialization to 0 and keep special case for empty array
v3: reset cnt to 0 in memblock test--- mm/memblock.c | 7 ++----- tools/testing/memblock/tests/basic_api.c | 8 ++++---- tools/testing/memblock/tests/common.c | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-)mm/memblock.c +0
-3@@ -114,12 +114,10 @@ static struct memblock_region memblock_physmem_init_regions[INIT_PHYSMEM_REGIONS struct memblock memblock __initdata_memblock = { .memory.regions = memblock_memory_init_regions, - .memory.cnt =1 ,/* empty dummy entry */ .memory.max =INIT_MEMBLOCK_MEMORY_REGIONS , .memory.name ="memory" , .reserved.regions = memblock_reserved_init_regions, - .reserved.cnt =1 ,/* empty dummy entry */ .reserved.max =INIT_MEMBLOCK_RESERVED_REGIONS , .reserved.name ="reserved" ,@@ -130,7 +128,6 @@ struct memblock memblock __initdata_memblock = {#ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP struct memblock_type physmem = { .regions = memblock_physmem_init_regions, - .cnt =1 ,/* empty dummy entry */ .max =INIT_PHYSMEM_REGIONS , .name ="physmem" , };mm/memblock.c static void __init_memblock memblock_remove_region(struct memblock_type *type, u · line 359
Quoted 4 lines
mm/memblock.c +0
-1@@ -356,7 +353,6 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, u/* Special case for empty arrays */ if (type->cnt ==0 ) {WARN_ON (type->total_size !=0 ); - type->cnt =1 ;Sorry if I wasn't clear, I meant to keep special case only in
memblock_add_range. Here I think
Quoted 4 lines
WARN_ON(type->cnt == 0 && type->total_size != 0);should be enough.
You mean change like this?
mm/memblock.c +1 -10
@@ -352,16 +352,7 @@ static void __init_memblock memblock_remove_region(struct memblock_type *type, umemmove (&type->regions[r], &type->regions[r +1 ], (type->cnt - (r +1 )) *sizeof (type->regions[r])); type->cnt--; - -/* Special case for empty arrays */ -if (type->cnt ==0 ) { -WARN_ON (type->total_size !=0 ); - type->cnt =1 ; - type->regions[0 ].base =0 ; - type->regions[0 ].size =0 ; - type->regions[0 ].flags =0 ; -memblock_set_region_node (&type->regions[0 ],MAX_NUMNODES ); - } +WARN_ON (type->cnt ==0 && type->total_size !=0 ); }#ifndef CONFIG_ARCH_KEEP_MEMBLOCK
This doesn't work, since on removing the last region, memmove would take no effect and left regions[0].base .size .flags not changed.
So we need to keep the special handling here.
From: Mike Rapoport (IBM) <[email protected]>
Quoted 11 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */[...]
Applied to for-next branch of memblock.git tree, thanks!
[1/1] mm/memblock: remove empty dummy entry
commit: e5d1fdecfaf8470bad3874d00c7921e3883495b7
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
branch: for-next
--
Sincerely yours,
Mike.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 25 lines · Guenter Roeck
Hi,
Quoted 14 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Quoted 7 lines
Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>
Quoted 5 lines
With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
Bisect log is attached for reference.
Thanks for the reporting.
Would you mind running the test to take a look?
It is in tools/testing/memblock. Simply make and ./main.
Quoted 31 lines
Guenter
---
# bad: [2102cb0d050d34d50b9642a3a50861787527e922] Add linux-next specific files for 20240619
# good: [6ba59ff4227927d3a8530fc2973b80e94b54d58f] Linux 6.10-rc4
git bisect start 'HEAD' 'v6.10-rc4'
# good: [a8fa5261ec87d5aafd3211548d93008d5739457d] Merge branch 'master' ofgit://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect gooda8fa5261ec87d5aafd3211548d93008d5739457d
# good: [ee551f4db89753511a399b808db75654facec7c8] Merge branch 'for-linux-next' of https://gitlab.freedesktop.org/drm/i915/kernel
git bisect goodee551f4db89753511a399b808db75654facec7c8
# good: [ec3557f4b791d72d93bfb69702d441d2c9f8cd0d] Merge branch 'next' ofgit://git.kernel.org/pub/scm/virt/kvm/kvm.git
git bisect goodec3557f4b791d72d93bfb69702d441d2c9f8cd0d
# good: [48d51b3acbb237074014d498d76ea6b6ce5aed69] Merge branch 'next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git
git bisect good48d51b3acbb237074014d498d76ea6b6ce5aed69
# good: [59972b98583cd97febf9ecc576a706a7c5046278] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
git bisect good59972b98583cd97febf9ecc576a706a7c5046278
# good: [49aa15d761ce8976bb131f06886e89bd10cdb9fd] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
git bisect good49aa15d761ce8976bb131f06886e89bd10cdb9fd
# bad: [129b9b07cd69885a804319c3fac82ef79e012e07] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git
git bisect bad129b9b07cd69885a804319c3fac82ef79e012e07
# good: [344db92cbecc8da1f58d559926c61ceb72e72a03] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git
git bisect good344db92cbecc8da1f58d559926c61ceb72e72a03
# bad: [ce8ebb95439459f7e24b02c6943e278f46d2d328]mm/mm_init.c: get the highest zone directly
git bisect badce8ebb95439459f7e24b02c6943e278f46d2d328
# bad: [1a879671bdfd14698a839f30de8e6d76e1e858fd] memblock tests: addmemblock_overlaps_region_checks
git bisect bad1a879671bdfd14698a839f30de8e6d76e1e858fd
# bad: [3d3165193776ddacf59f101f0fa05cfab9f1a9ba] memblock tests: addmemblock_reserve_all_locations_check()
git bisect bad3d3165193776ddacf59f101f0fa05cfab9f1a9ba
# bad: [721f4a6526daafca15634f30c9865e880da3e1d1] mm/memblock: remove empty dummy entry
git bisect bad721f4a6526daafca15634f30c9865e880da3e1d1# first bad commit: [721f4a6526daafca15634f30c9865e880da3e1d1] mm/memblock: remove empty dummy entry
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 29 lines · Wei Yang
Quoted 28 lines · Guenter Roeck
Hi,
Quoted 14 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Quoted 7 lines
Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
Quoted 9 lines
Quoted 2 lines
Bisect log is attached for reference.
Thanks for the reporting.
Would you mind running the test to take a look?
It is in
tools/testing/memblock. Simply make and ./main.
This is a silent failure. There is no console output, so the image crashes before it gets to that point.
Building microblaze:petalogix-s3adsp1800:initrd ... running ................R............. failed (silent)
------------
qemu log:
qemu-system-microblaze: terminating on signal 15 from pid 2343410 (/bin/bash)
Guenter
Quoted 33 lines · Guenter Roeck
Quoted 32 lines · Wei Yang
Quoted 30 lines · Guenter Roeck
Hi,
Quoted 14 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Quoted 7 lines
Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
Bisect log is attached for reference.
Quoted 6 lines
Quoted 6 lines
Thanks for the reporting.
Would you mind running the test to take a look?
It is in
tools/testing/memblock. Simply make and ./main.
This is a user-space test case, would you mind running it with this commit applied?
Quoted 9 lines
This is a silent failure. There is no console output, so the image crashes before it gets to that point.
Building microblaze:petalogix-s3adsp1800:initrd ... running ................R............. failed (silent)
------------
qemu log:
qemu-system-microblaze: terminating on signal 15 from pid 2343410 (/bin/bash)
Would you mind add kernel parameter memblock=debug without the commit applied? If my understanding is correct, you can bootup without this commit, right?
Quoted 1 line
Guenter
Signature · 2 lines
Wei Yang Help you, Help me
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mike Rapoport
maintainer(added microblaze maintainer)
Quoted 50 lines · Guenter Roeck
Quoted 34 lines · Wei Yang
Quoted 33 lines · Guenter Roeck
Quoted 20 lines · Wei Yang
Quoted 19 lines · Guenter Roeck
Hi,
Quoted 16 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Let's remove it.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
This is a silent failure. There is no console output, so the image crashes before it gets to that point.
Quoted 7 lines
Quoted 4 lines
Building microblaze:petalogix-s3adsp1800:initrd ... running ................R............. failed (silent)
------------
qemu log:
qemu-system-microblaze: terminating on signal 15 from pid 2343410 (/bin/bash)Would you mind add kernel parameter memblock=debug without the commit applied? If my understanding is correct, you can bootup without this commit, right?
Yes. With this change on top of linux-next:
arch/microblaze/mm/init.c +0
-0
arch/microblaze/mm/init.c asmlinkage void __init mmu_init(void) · line 196
Quoted 2 lines
arch/microblaze/mm/init.c +0
-0@@ -195,7 +195,9 @@ asmlinkage void __init mmu_init(void)if (!memblock.reserved.cnt) {
I tried to understand what this was supposed to check, but this test was there from day 1, so git archaeology didn't help :(
Anyway, it's perfectly fine to have any number of memblock reservations here or no at all.
early_init_devtree() is called before mmu_init() and it sets up memblock.memory via early_init_dt_scan() and even allows memblock allocations. So the check for !memblock.reserved.cnt here seems wrong.
Quoted 28 lines
arch/microblaze/mm/init.c +2
-0pr_emerg ("Error memory count\n" ); +#if 0 machine_restart (NULL ); +#endif }the log starts with:
random: crng init done
Ramdisk addr0x51923788,
FDT at0x51f43d88
Error memory count
MEMBLOCK configuration:
memory size =0x10000000reserved size =0x015bb600memory.cnt =0x1
memory[0x0] [0x50000000-0x5fffffff],0x10000000bytes flags:0x0
reserved.cnt =0x3reserved[0x0] [0x50000000-0x50f5cfff], 0x00f5d000 bytes flags: 0x0 reserved[0x1] [0x510c0000-0x510fffff], 0x00040000 bytes flags: 0x0 reserved[0x2] [0x51923788-0x51f41d87], 0x0061e600 bytes flags: 0x0Linux version 6.10.0-rc4-next-20240620-dirty ([email protected]) (microblaze-linux-gcc (GCC) 11.4.0, GNU ld (GNU Binutils) 2.40) #1 Fri Jun 21 21:00:40 PDT 2024
setup_memory:max_mapnr:0x10000setup_memory:min_low_pfn:0x50000setup_memory:max_low_pfn:0x60000setup_memory:max_pfn:0x60000memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x51100000pte_alloc_one_kernel+0x50/0x64memblock_reserve: [0x510bf000-0x510bffff]memblock_alloc_range_nid+0x104/0x1d4
Quoted 1 line
Guenter
I think simply removing the check for !memblock.reserved.cnt is the right thing to do here:
From 975c5ba011330238444c82d0b171779c2156d2dc Mon Sep 17 00:00:00 2001
From: "Mike Rapoport (IBM)" <[email protected]>
Date: Sat, 22 Jun 2024 20:46:36 +0300
Subject: [PATCH] microblaze: don't treat zero reserved memory regions as error
Before commit 721f4a6526da ("mm/memblock: remove empty dummy entry") the check for non-zero of memblock.reserved.cnt in mmu_init() would always be true either because memblock.reserved.cnt is initialized to 1 or because there were memory reservations earlier.
The removal of dummy empty entry in memblock caused this check to fail because now memblock.reserved.cnt is initialized to 0.
Remove the check for non-zero of memblock.reserved.cnt because it's perfectly fine to have an empty memblock.reserved array that early in boot.
--- arch/microblaze/mm/init.c | 5 ----- 1 file changed, 5 deletions(-)
arch/microblaze/mm/init.c +0 -5
@@ -193,11 +193,6 @@ asmlinkage void __init mmu_init(void) {unsigned int kstart, ksize; -if (!memblock.reserved.cnt) { -pr_emerg ("Error memory count\n" ); -machine_restart (NULL ); - } -if ((u32 ) memblock.memory.regions[0 ].size <0x400000 ) {pr_emerg ("Memory must be greater than 4MB\n" );machine_restart (NULL );
Signature · 6 lines
2.43.0 -- Sincerely yours, Mike.
Wei Yang
Reviewed-byQuoted 112 lines · Mike Rapoport
(added microblaze maintainer)
Quoted 50 lines · Guenter Roeck
Quoted 34 lines · Wei Yang
Quoted 33 lines · Guenter Roeck
Quoted 20 lines · Wei Yang
Quoted 19 lines · Guenter Roeck
Hi,
Quoted 16 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Let's remove it.
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
This is a silent failure. There is no console output, so the image crashes before it gets to that point.
Quoted 7 lines
Quoted 4 lines
Building microblaze:petalogix-s3adsp1800:initrd ... running ................R............. failed (silent)
------------
qemu log:
qemu-system-microblaze: terminating on signal 15 from pid 2343410 (/bin/bash)Would you mind add kernel parameter memblock=debug without the commit applied? If my understanding is correct, you can bootup without this commit, right?
Yes. With this change on top of linux-next:
arch/microblaze/mm/init.c +0
-0arch/microblaze/mm/init.c asmlinkage void __init mmu_init(void) · line 196
Quoted 2 lines
arch/microblaze/mm/init.c +0
-0@@ -195,7 +195,9 @@ asmlinkage void __init mmu_init(void)if (!memblock.reserved.cnt) {I tried to understand what this was supposed to check, but this test was there from day 1, so git archaeology didn't help :(
Anyway, it's perfectly fine to have any number of memblock reservations here or no at all.
early_init_devtree()is called beforemmu_init()and it sets up memblock.memory viaearly_init_dt_scan()and even allows memblock allocations. So the check for !memblock.reserved.cnt here seems wrong.Quoted 28 lines
arch/microblaze/mm/init.c +2
-0pr_emerg ("Error memory count\n" ); +#if 0 machine_restart (NULL ); +#endif }the log starts with:
random: crng init done
Ramdisk addr0x51923788,
FDT at0x51f43d88
Error memory count
MEMBLOCK configuration:
memory size =0x10000000reserved size =0x015bb600memory.cnt =0x1
memory[0x0] [0x50000000-0x5fffffff],0x10000000bytes flags:0x0
reserved.cnt =0x3reserved[0x0] [0x50000000-0x50f5cfff], 0x00f5d000 bytes flags: 0x0 reserved[0x1] [0x510c0000-0x510fffff], 0x00040000 bytes flags: 0x0 reserved[0x2] [0x51923788-0x51f41d87], 0x0061e600 bytes flags: 0x0Linux version 6.10.0-rc4-next-20240620-dirty ([email protected]) (microblaze-linux-gcc (GCC) 11.4.0, GNU ld (GNU Binutils) 2.40) #1 Fri Jun 21 21:00:40 PDT 2024
setup_memory:max_mapnr:0x10000setup_memory:min_low_pfn:0x50000setup_memory:max_low_pfn:0x60000setup_memory:max_pfn:0x60000memblock_alloc_try_nid: 4096 bytes align=0x1000 nid=-1 from=0x00000000 max_addr=0x51100000pte_alloc_one_kernel+0x50/0x64memblock_reserve: [0x510bf000-0x510bffff]memblock_alloc_range_nid+0x104/0x1d4Quoted 1 line
Guenter
I think simply removing the check for !memblock.reserved.cnt is the right thing to do here:
Quoted 1 line
From
975c5ba011330238444c82d0b171779c2156d2dcMon Sep 17 00:00:00 2001From: "Mike Rapoport (IBM)" <[email protected]>
Date: Sat, 22 Jun 2024 20:46:36 +0300
Subject: [PATCH] microblaze: don't treat zero reserved memory regions as errorBefore commit
721f4a6526da("mm/memblock: remove empty dummy entry") the check for non-zero of memblock.reserved.cnt inmmu_init()would always be true either because memblock.reserved.cnt is initialized to 1 or because there were memory reservations earlier.The removal of dummy empty entry in memblock caused this check to fail because now memblock.reserved.cnt is initialized to 0.
Quoted 6 lines
Remove the check for non-zero of memblock.reserved.cnt because it's perfectly fine to have an empty memblock.reserved array that early in boot.
Reported-by Guenter Roeck <[email protected]>Signed-off-by Mike Rapoport (IBM) <[email protected]>
Thanks Mike :-)
Quoted 27 lines
---
arch/microblaze/mm/init.c| 5 -----1 file changed, 5 deletions(-)arch/microblaze/mm/init.c +0
-5@@ -193,11 +193,6 @@ asmlinkage void __init mmu_init(void) {unsigned int kstart, ksize; -if (!memblock.reserved.cnt) { -pr_emerg ("Error memory count\n" ); -machine_restart (NULL ); - } -if ((u32 ) memblock.memory.regions[0 ].size <0x400000 ) {pr_emerg ("Memory must be greater than 4MB\n" );machine_restart (NULL );Signature · 6 lines
2.43.0 -- Sincerely yours, Mike.
Signature · 2 lines
Wei Yang Help you, Help me
Quoted 25 lines · Guenter Roeck
Hi,
Quoted 14 lines · Wei Yang
The dummy entry is introduced in the initial implementation of lmb in commit
7c8c6b9776fb("powerpc: Mergelmb.cand make MM initialization use it.").As the comment says the empty dummy entry is to simplify the code.
/* Create a dummy zero size LMB which will get coalesced away later. * This simplifies the lmb_add() code below... */While current code is reimplemented by Tejun in commit
784656f9c680("memblock: Reimplementmemblock_add_region()"). This empty dummy entry seems not benefit the code any more.Quoted 7 lines
Let's remove it.
Signed-off-by Wei Yang <[email protected]>CC Paul Mackerras <[email protected]>CC Tejun Heo <[email protected]>CC Mike Rapoport <[email protected]>
Quoted 5 lines
With this patch in linux-next, all microblaze qemu images fail to boot. Reverting it fixes the problem.
Bisect log is attached for reference.
Also, would you mind add kernel parameter memblock=debug and give me the log?
Quoted 31 lines
Guenter
---
# bad: [2102cb0d050d34d50b9642a3a50861787527e922] Add linux-next specific files for 20240619
# good: [6ba59ff4227927d3a8530fc2973b80e94b54d58f] Linux 6.10-rc4
git bisect start 'HEAD' 'v6.10-rc4'
# good: [a8fa5261ec87d5aafd3211548d93008d5739457d] Merge branch 'master' ofgit://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git
git bisect gooda8fa5261ec87d5aafd3211548d93008d5739457d
# good: [ee551f4db89753511a399b808db75654facec7c8] Merge branch 'for-linux-next' of https://gitlab.freedesktop.org/drm/i915/kernel
git bisect goodee551f4db89753511a399b808db75654facec7c8
# good: [ec3557f4b791d72d93bfb69702d441d2c9f8cd0d] Merge branch 'next' ofgit://git.kernel.org/pub/scm/virt/kvm/kvm.git
git bisect goodec3557f4b791d72d93bfb69702d441d2c9f8cd0d
# good: [48d51b3acbb237074014d498d76ea6b6ce5aed69] Merge branch 'next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/phy/linux-phy.git
git bisect good48d51b3acbb237074014d498d76ea6b6ce5aed69
# good: [59972b98583cd97febf9ecc576a706a7c5046278] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git
git bisect good59972b98583cd97febf9ecc576a706a7c5046278
# good: [49aa15d761ce8976bb131f06886e89bd10cdb9fd] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching
git bisect good49aa15d761ce8976bb131f06886e89bd10cdb9fd
# bad: [129b9b07cd69885a804319c3fac82ef79e012e07] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock.git
git bisect bad129b9b07cd69885a804319c3fac82ef79e012e07
# good: [344db92cbecc8da1f58d559926c61ceb72e72a03] Merge branch 'for-next' ofgit://git.kernel.org/pub/scm/linux/kernel/git/srini/nvmem.git
git bisect good344db92cbecc8da1f58d559926c61ceb72e72a03
# bad: [ce8ebb95439459f7e24b02c6943e278f46d2d328]mm/mm_init.c: get the highest zone directly
git bisect badce8ebb95439459f7e24b02c6943e278f46d2d328
# bad: [1a879671bdfd14698a839f30de8e6d76e1e858fd] memblock tests: addmemblock_overlaps_region_checks
git bisect bad1a879671bdfd14698a839f30de8e6d76e1e858fd
# bad: [3d3165193776ddacf59f101f0fa05cfab9f1a9ba] memblock tests: addmemblock_reserve_all_locations_check()
git bisect bad3d3165193776ddacf59f101f0fa05cfab9f1a9ba
# bad: [721f4a6526daafca15634f30c9865e880da3e1d1] mm/memblock: remove empty dummy entry
git bisect bad721f4a6526daafca15634f30c9865e880da3e1d1# first bad commit: [721f4a6526daafca15634f30c9865e880da3e1d1] mm/memblock: remove empty dummy entry
Signature · 2 lines
Wei Yang Help you, Help me