From: Yi Wang <wang.yi59@zte.com.cn>
To: catalin.marinas@arm.com
Cc: will.deacon@arm.com, akpm@linux-foundation.org,
rppt@linux.vnet.ibm.com, f.fainelli@gmail.com,
logang@deltatee.com, robin.murphy@arm.com, ghackmann@android.com,
hannes@cmpxchg.org, david@redhat.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, xue.zhihong@zte.com.cn,
wang.yi59@zte.com.cn, jiang.xuexin@zte.com.cn,
Junhua Huang <huang.junhua@zte.com.cn>
Subject: [PATCH] arm64: mm: free the initrd reserved memblock in a aligned manner
Date: Thu, 4 Jul 2019 07:59:00 +0800 [thread overview]
Message-ID: <1562198340-19089-1-git-send-email-wang.yi59@zte.com.cn> (raw)
From: Junhua Huang <huang.junhua@zte.com.cn>
We should free the reserved memblock in an aligned manner
because the initrd reserves the memblock in an aligned manner
in arm64_memblock_init().
Otherwise there are some fragments in memblock_reserved regions. e.g.:
/sys/kernel/debug/memblock # cat reserved
0: 0x0000000080080000..0x00000000817fafff
1: 0x0000000083400000..0x0000000083ffffff
2: 0x0000000090000000..0x000000009000407f
3: 0x00000000b0000000..0x00000000b000003f
4: 0x00000000b26184ea..0x00000000b2618fff
The fragments like the ranges from b0000000 to b000003f and
from b26184ea to b2618fff should be freed.
And we can do free_reserved_area() after memblock_free(),
as free_reserved_area() calls __free_pages(), once we've done
that it could be allocated somewhere else,
but memblock and iomem still say this is reserved memory.
Signed-off-by: Junhua Huang <huang.junhua@zte.com.cn>
---
arch/arm64/mm/init.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index d2adffb81b5d..03774b8bd364 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -580,8 +580,13 @@ void free_initmem(void)
#ifdef CONFIG_BLK_DEV_INITRD
void __init free_initrd_mem(unsigned long start, unsigned long end)
{
+ unsigned long aligned_start, aligned_end;
+
+ aligned_start = __virt_to_phys(start) & PAGE_MASK;
+ aligned_end = PAGE_ALIGN(__virt_to_phys(end));
+ memblock_free(aligned_end, aligned_end - aligned_start);
free_reserved_area((void *)start, (void *)end, 0, "initrd");
- memblock_free(__virt_to_phys(start), end - start);
+
}
#endif
--
2.15.2
next reply other threads:[~2019-07-04 0:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-03 23:59 Yi Wang [this message]
2019-07-05 15:11 ` James Morse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1562198340-19089-1-git-send-email-wang.yi59@zte.com.cn \
--to=wang.yi59@zte.com.cn \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=david@redhat.com \
--cc=f.fainelli@gmail.com \
--cc=ghackmann@android.com \
--cc=hannes@cmpxchg.org \
--cc=huang.junhua@zte.com.cn \
--cc=jiang.xuexin@zte.com.cn \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=logang@deltatee.com \
--cc=robin.murphy@arm.com \
--cc=rppt@linux.vnet.ibm.com \
--cc=will.deacon@arm.com \
--cc=xue.zhihong@zte.com.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®