openrisc: Reserve memblock for initrd
Stafford Horne
maintainerPATCH 1/1 openrisc: Reserve memblock for initrd
Recently OpenRISC added support for external initrd images, but I found some instability when using larger buildroot initrd images. It turned out that I forgot to reserve the memblock space for the initrd image.
This patch fixes the instability issue by reserving memblock space.
--- arch/openrisc/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)
arch/openrisc/kernel/setup.c +9 -0
@@ -80,6 +80,15 @@ static void __init setup_memory(void)*/ memblock_reserve (__pa (_stext), _end - _stext); +#ifdef CONFIG_BLK_DEV_INITRD +/* Then reserve the initrd, if any */ +if (initrd_start && (initrd_end > initrd_start)) { +memblock_reserve (ALIGN_DOWN (__pa (initrd_start),PAGE_SIZE ), +ALIGN (initrd_end,PAGE_SIZE ) - +ALIGN_DOWN (initrd_start,PAGE_SIZE )); + } +#endif /* CONFIG_BLK_DEV_INITRD */ +early_init_fdt_reserve_self ();early_init_fdt_scan_reserved_mem ();
Signature · 1 line
2.26.2
Quoted 17 lines · Stafford Horne
Recently OpenRISC added support for external initrd images, but I found some instability when using larger buildroot initrd images. It turned out that I forgot to reserve the memblock space for the initrd image.
This patch fixes the instability issue by reserving memblock space.
Fixes ff6c923dbec3 ("openrisc: Add support for external initrd images")Signed-off-by Stafford Horne <[email protected]>--- arch/openrisc/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/openrisc/kernel/setup.c +0
-0
arch/openrisc/kernel/setup.c static void __init setup_memory(void) · line 89
Quoted 10 lines
arch/openrisc/kernel/setup.c +7
-0@@ -80,6 +80,15 @@ static void __init setup_memory(void)*/ memblock_reserve (__pa (_stext), _end - _stext); +#ifdef CONFIG_BLK_DEV_INITRD +/* Then reserve the initrd, if any */ +if (initrd_start && (initrd_end > initrd_start)) { +memblock_reserve (ALIGN_DOWN (__pa (initrd_start),PAGE_SIZE ), +ALIGN (initrd_end,PAGE_SIZE ) - +ALIGN_DOWN (initrd_start,PAGE_SIZE )); + }
The core mm takes care of reserving the entrire pages for the memory reserved with memblock, so it is not necessary to do it here.
Quoted 8 lines
arch/openrisc/kernel/setup.c +2
-0+#endif /* CONFIG_BLK_DEV_INITRD */ +early_init_fdt_reserve_self ();early_init_fdt_scan_reserved_mem ();Signature · 1 line
2.26.2
Signature · 2 lines
Sincerely yours, Mike.
Stafford Horne
maintainerQuoted 21 lines · Mike Rapoport
Quoted 20 lines · Stafford Horne
Recently OpenRISC added support for external initrd images, but I found some instability when using larger buildroot initrd images. It turned out that I forgot to reserve the memblock space for the initrd image.
This patch fixes the instability issue by reserving memblock space.
Fixes ff6c923dbec3 ("openrisc: Add support for external initrd images")Signed-off-by Stafford Horne <[email protected]>--- arch/openrisc/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/openrisc/kernel/setup.c +0
-0@@ -80,6 +80,15 @@ static void __init setup_memory(void)*/ memblock_reserve (__pa (_stext), _end - _stext);
Quoted 10 lines
arch/openrisc/kernel/setup.c static void __init setup_memory(void) · line 89
Quoted 7 lines
arch/openrisc/kernel/setup.c +7
-0+#ifdef CONFIG_BLK_DEV_INITRD +/* Then reserve the initrd, if any */ +if (initrd_start && (initrd_end > initrd_start)) { +memblock_reserve (ALIGN_DOWN (__pa (initrd_start),PAGE_SIZE ), +ALIGN (initrd_end,PAGE_SIZE ) - +ALIGN_DOWN (initrd_start,PAGE_SIZE )); + }The core mm takes care of reserving the entrire pages for the memory reserved with memblock, so it is not necessary to do it here.
Thanks for the pointer
I guess what you mean is it is not required to do the page alignment. I used other architectures as an example and most do the alignment, I think for most architectures this can be pulled out to generic code.
-Stafford
Quoted 12 lines
Quoted 8 lines
arch/openrisc/kernel/setup.c +2
-0+#endif /* CONFIG_BLK_DEV_INITRD */ +early_init_fdt_reserve_self ();early_init_fdt_scan_reserved_mem ();Signature · 1 line
2.26.2Signature · 2 lines
Sincerely yours, Mike.
Quoted 33 lines · Stafford Horne
Quoted 21 lines · Mike Rapoport
Quoted 20 lines · Stafford Horne
Recently OpenRISC added support for external initrd images, but I found some instability when using larger buildroot initrd images. It turned out that I forgot to reserve the memblock space for the initrd image.
This patch fixes the instability issue by reserving memblock space.
Fixes ff6c923dbec3 ("openrisc: Add support for external initrd images")Signed-off-by Stafford Horne <[email protected]>--- arch/openrisc/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/openrisc/kernel/setup.c +0
-0@@ -80,6 +80,15 @@ static void __init setup_memory(void)*/ memblock_reserve (__pa (_stext), _end - _stext);Quoted 10 lines
arch/openrisc/kernel/setup.c static void __init setup_memory(void) · line 89
Quoted 7 lines
arch/openrisc/kernel/setup.c +7
-0+#ifdef CONFIG_BLK_DEV_INITRD +/* Then reserve the initrd, if any */ +if (initrd_start && (initrd_end > initrd_start)) { +memblock_reserve (ALIGN_DOWN (__pa (initrd_start),PAGE_SIZE ), +ALIGN (initrd_end,PAGE_SIZE ) - +ALIGN_DOWN (initrd_start,PAGE_SIZE )); + }The core mm takes care of reserving the entrire pages for the memory reserved with memblock, so it is not necessary to do it here.
Quoted 3 lines
Thanks for the pointer
I guess what you mean is it is not required to do the page alignment.
Right.
Quoted 2 lines
I used other architectures as an example and most do the alignment, I think for most architectures this can be pulled out to generic code.
You are more than welcome :)
We already have a generic free_initrd_mem(), maybe it's time to have a generic reserve_initrd_mem().
I'm ok with openrisc doing the alignment, but I think using local variables would make the core more readable, e.g
if (initd_start && (initrd_end)) {
unsigned long aligned_start = ALIGN_DOWN(initrd_start, PAGE_SIZE);
unsigned long aligned_end = ALIGN(end, PAGE_SIZE);
memblock_reserve(aligned_start, aligned_end);
}What do you say?
Quoted 14 lines
-Stafford
Quoted 12 lines
Quoted 8 lines
arch/openrisc/kernel/setup.c +2
-0+#endif /* CONFIG_BLK_DEV_INITRD */ +early_init_fdt_reserve_self ();early_init_fdt_scan_reserved_mem ();Signature · 1 line
2.26.2Signature · 2 lines
Sincerely yours, Mike.
Signature · 2 lines
Sincerely yours, Mike.
Stafford Horne
maintainerQuoted 50 lines · Mike Rapoport
Quoted 33 lines · Stafford Horne
Quoted 21 lines · Mike Rapoport
Quoted 20 lines · Stafford Horne
Recently OpenRISC added support for external initrd images, but I found some instability when using larger buildroot initrd images. It turned out that I forgot to reserve the memblock space for the initrd image.
This patch fixes the instability issue by reserving memblock space.
Fixes ff6c923dbec3 ("openrisc: Add support for external initrd images")Signed-off-by Stafford Horne <[email protected]>--- arch/openrisc/kernel/setup.c | 9 +++++++++ 1 file changed, 9 insertions(+)arch/openrisc/kernel/setup.c +0
-0@@ -80,6 +80,15 @@ static void __init setup_memory(void)*/ memblock_reserve (__pa (_stext), _end - _stext);Quoted 10 lines
arch/openrisc/kernel/setup.c static void __init setup_memory(void) · line 89
Quoted 7 lines
arch/openrisc/kernel/setup.c +7
-0+#ifdef CONFIG_BLK_DEV_INITRD +/* Then reserve the initrd, if any */ +if (initrd_start && (initrd_end > initrd_start)) { +memblock_reserve (ALIGN_DOWN (__pa (initrd_start),PAGE_SIZE ), +ALIGN (initrd_end,PAGE_SIZE ) - +ALIGN_DOWN (initrd_start,PAGE_SIZE )); + }The core mm takes care of reserving the entrire pages for the memory reserved with memblock, so it is not necessary to do it here.
Quoted 3 lines
Thanks for the pointer
I guess what you mean is it is not required to do the page alignment.
Right.
Quoted 2 lines
I used other architectures as an example and most do the alignment, I think for most architectures this can be pulled out to generic code.
You are more than welcome :)
We already have a genericfree_initrd_mem(), maybe it's time to have a genericreserve_initrd_mem().I'm ok with openrisc doing the alignment, but I think using local variables would make the core more readable, e.g
Quoted 8 lines
if (initd_start && (initrd_end)) { unsigned long aligned_start = ALIGN_DOWN(initrd_start, PAGE_SIZE); unsigned long aligned_end = ALIGN(end, PAGE_SIZE); memblock_reserve(aligned_start, aligned_end); }What do you say?
Well, if the alignment is not needed I rather not do it. That would make the code as simple as:
if (initrd_start && (initrd_end > initrd_start)) {
memblock_reserve(__pa(initrd_start), initrd_end - initrd_start);
}Let me look what is involved in making a reserve_initrd_mem().
-Stafford
Quoted 18 lines
Quoted 14 lines
-Stafford
Quoted 12 lines
Quoted 8 lines
arch/openrisc/kernel/setup.c +2
-0+#endif /* CONFIG_BLK_DEV_INITRD */ +early_init_fdt_reserve_self ();early_init_fdt_scan_reserved_mem ();Signature · 1 line
2.26.2Signature · 2 lines
Sincerely yours, Mike.Signature · 2 lines
Sincerely yours, Mike.