From: James Morse <james.morse@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Robert Richter <rrichter@cavium.com>,
Will Deacon <will.deacon@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
David Daney <david.daney@cavium.com>,
Mark Rutland <mark.rutland@arm.com>,
Hanjun Guo <hanjun.guo@linaro.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] arm64: mm: Mark nomap regions with the PG_reserved flag
Date: Fri, 2 Dec 2016 14:49:08 +0000 [thread overview]
Message-ID: <20161202144909.18405-2-james.morse@arm.com> (raw)
In-Reply-To: <20161202144909.18405-1-james.morse@arm.com>
linux/page-flags.h has a flag for describing special pages:
> PG_reserved is set for special pages, which can never be swapped out.
> Some of them might not even exist (eg empty_bad_page)...
memblock nomap pages fall in the 'might not even exist' category,
set this bit on all the struct pages in the nomap regions.
This gives pfn walkers the necessary hint that the page might not
be accessible, allowing pfn_valid()s meaning to change slightly.
Signed-off-by: James Morse <james.morse@arm.com>
---
arch/arm64/mm/init.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 166911f4a2e6..5da9ff7d20f5 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -31,6 +31,7 @@
#include <linux/memblock.h>
#include <linux/sort.h>
#include <linux/of_fdt.h>
+#include <linux/page-flags.h>
#include <linux/dma-mapping.h>
#include <linux/dma-contiguous.h>
#include <linux/efi.h>
@@ -401,6 +402,8 @@ static void __init free_unused_memmap(void)
*/
void __init mem_init(void)
{
+ struct memblock_region *region;
+
if (swiotlb_force || max_pfn > (arm64_dma_phys_limit >> PAGE_SHIFT))
swiotlb_init(1);
@@ -479,6 +482,17 @@ void __init mem_init(void)
*/
sysctl_overcommit_memory = OVERCOMMIT_ALWAYS;
}
+
+ /* Mark struct pages for the memblock:nomap regions as reserved */
+ for_each_memblock(memory, region) {
+ u64 pfn;
+ u64 start_pfn = memblock_region_memory_base_pfn(region);
+ u64 end_pfn = memblock_region_memory_end_pfn(region);
+
+ if (memblock_is_nomap(region))
+ for (pfn = start_pfn; pfn < end_pfn; pfn++)
+ SetPageReserved(pfn_to_page(pfn));
+ }
}
void free_initmem(void)
--
2.10.1
next prev parent reply other threads:[~2016-12-02 14:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 18:21 [PATCH v2] arm64: mm: Fix memmap to be initialized for the entire section Robert Richter
2016-12-01 16:45 ` Will Deacon
2016-12-01 17:26 ` James Morse
2016-12-02 7:11 ` Robert Richter
2016-12-02 14:48 ` James Morse
2016-12-02 14:49 ` [PATCH 0/2] Hibernate fixes for 'Fix memmap to be initialized for the entire section' James Morse
2016-12-02 14:49 ` James Morse [this message]
2016-12-02 14:49 ` [PATCH 2/2] arm64: hibernate: report nomap regions as being pfn_nosave James Morse
2016-12-05 15:42 ` [PATCH 0/2] Hibernate fixes for 'Fix memmap to be initialized for the entire section' Ard Biesheuvel
2016-12-06 17:38 ` Will Deacon
2016-12-07 9:06 ` Robert Richter
2016-12-07 14:32 ` Will Deacon
2016-12-09 12:14 ` [PATCH v2] arm64: mm: Fix memmap to be initialized for the entire section Yisheng Xie
2016-12-09 12:19 ` Ard Biesheuvel
2016-12-09 12:23 ` Hanjun Guo
2016-12-09 13:15 ` Yisheng Xie
2016-12-09 14:52 ` Robert Richter
2016-12-12 12:02 ` Ard Biesheuvel
2016-12-09 14:51 ` Robert Richter
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=20161202144909.18405-2-james.morse@arm.com \
--to=james.morse@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=catalin.marinas@arm.com \
--cc=david.daney@cavium.com \
--cc=hanjun.guo@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rrichter@cavium.com \
--cc=will.deacon@arm.com \
/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