* [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant
@ 2016-05-05 6:24 Oliver O'Halloran
2016-05-05 6:24 ` [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
2016-05-05 7:04 ` [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Balbir Singh
0 siblings, 2 replies; 4+ messages in thread
From: Oliver O'Halloran @ 2016-05-05 6:24 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Oliver O'Halloran
The zone that contains the top of memory will be either ZONE_NORMAL
or ZONE_HIGHMEM depending on the kernel config. There are two functions
in that require this information and both of them use an #ifdef to set
a local variable (top_zone). This is a little silly so lets just make it
a constant.
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
arch/powerpc/mm/mem.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index ac79dbde1015..8f4c19789a38 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -68,12 +68,15 @@ pte_t *kmap_pte;
EXPORT_SYMBOL(kmap_pte);
pgprot_t kmap_prot;
EXPORT_SYMBOL(kmap_prot);
+#define TOP_ZONE ZONE_HIGHMEM
static inline pte_t *virt_to_kpte(unsigned long vaddr)
{
return pte_offset_kernel(pmd_offset(pud_offset(pgd_offset_k(vaddr),
vaddr), vaddr), vaddr);
}
+#else
+#define TOP_ZONE ZONE_NORMAL
#endif
int page_is_ram(unsigned long pfn)
@@ -267,14 +270,9 @@ void __init limit_zone_pfn(enum zone_type zone, unsigned long pfn_limit)
*/
int dma_pfn_limit_to_zone(u64 pfn_limit)
{
- enum zone_type top_zone = ZONE_NORMAL;
int i;
-#ifdef CONFIG_HIGHMEM
- top_zone = ZONE_HIGHMEM;
-#endif
-
- for (i = top_zone; i >= 0; i--) {
+ for (i = TOP_ZONE; i >= 0; i--) {
if (max_zone_pfns[i] <= pfn_limit)
return i;
}
@@ -289,7 +287,6 @@ void __init paging_init(void)
{
unsigned long long total_ram = memblock_phys_mem_size();
phys_addr_t top_of_ram = memblock_end_of_DRAM();
- enum zone_type top_zone;
#ifdef CONFIG_PPC32
unsigned long v = __fix_to_virt(__end_of_fixed_addresses - 1);
@@ -313,13 +310,9 @@ void __init paging_init(void)
(long int)((top_of_ram - total_ram) >> 20));
#ifdef CONFIG_HIGHMEM
- top_zone = ZONE_HIGHMEM;
limit_zone_pfn(ZONE_NORMAL, lowmem_end_addr >> PAGE_SHIFT);
-#else
- top_zone = ZONE_NORMAL;
#endif
-
- limit_zone_pfn(top_zone, top_of_ram >> PAGE_SHIFT);
+ limit_zone_pfn(TOP_ZONE, top_of_ram >> PAGE_SHIFT);
zone_limits_final = true;
free_area_init_nodes(max_zone_pfns);
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty
2016-05-05 6:24 [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
@ 2016-05-05 6:24 ` Oliver O'Halloran
2016-05-05 7:05 ` Balbir Singh
2016-05-05 7:04 ` [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Balbir Singh
1 sibling, 1 reply; 4+ messages in thread
From: Oliver O'Halloran @ 2016-05-05 6:24 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Oliver O'Halloran
The mm zone mechanism was traditionally used by arch specific code to
partition memory into allocation zones. However there are several zones
that are managed by the mm subsystem rather than the architecture. Most
architectures set the max PFN of these special zones to zero, however on
powerpc we set them to ~0ul. This, in conjunction with a bug in
free_area_init_nodes() results in all of system memory being placed
being placed in ZONE_DEVICE when enabled. Device memory cannot be used
for regular kernel memory allocations so this will cause a kernel panic at
boot.
Given the planned addition of more mm managed zones (ZONE_CMA) we should
aim to be consistent with every other architecture and set the max PFN
for these zones to zero
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
arch/powerpc/mm/mem.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
index 8f4c19789a38..f0a058ebb6d7 100644
--- a/arch/powerpc/mm/mem.c
+++ b/arch/powerpc/mm/mem.c
@@ -239,8 +239,14 @@ static int __init mark_nonram_nosave(void)
static bool zone_limits_final;
+/*
+ * The memory zones past TOP_ZONE are managed by the generic
+ * mm subsystem which expects the max PFN for these zones
+ * to be set to zero.
+ */
static unsigned long max_zone_pfns[MAX_NR_ZONES] = {
- [0 ... MAX_NR_ZONES - 1] = ~0UL
+ [0 ... TOP_ZONE - 1] = ~0UL,
+ [TOP_ZONE ... MAX_NR_ZONES - 1] = 0
};
/*
--
2.5.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant
2016-05-05 6:24 [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
2016-05-05 6:24 ` [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
@ 2016-05-05 7:04 ` Balbir Singh
1 sibling, 0 replies; 4+ messages in thread
From: Balbir Singh @ 2016-05-05 7:04 UTC (permalink / raw)
To: Oliver O'Halloran; +Cc: linuxppc-dev
On Thu, May 5, 2016 at 4:24 PM, Oliver O'Halloran <oohall@gmail.com> wrote:
> The zone that contains the top of memory will be either ZONE_NORMAL
> or ZONE_HIGHMEM depending on the kernel config. There are two functions
> in that require this information and both of them use an #ifdef to set
> a local variable (top_zone). This is a little silly so lets just make it
> a constant.
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
I reviewed the previous version and there are no changes hence
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty
2016-05-05 6:24 ` [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
@ 2016-05-05 7:05 ` Balbir Singh
0 siblings, 0 replies; 4+ messages in thread
From: Balbir Singh @ 2016-05-05 7:05 UTC (permalink / raw)
To: Oliver O'Halloran; +Cc: linuxppc-dev
On Thu, May 5, 2016 at 4:24 PM, Oliver O'Halloran <oohall@gmail.com> wrote:
> The mm zone mechanism was traditionally used by arch specific code to
> partition memory into allocation zones. However there are several zones
> that are managed by the mm subsystem rather than the architecture. Most
> architectures set the max PFN of these special zones to zero, however on
> powerpc we set them to ~0ul. This, in conjunction with a bug in
> free_area_init_nodes() results in all of system memory being placed
> being placed in ZONE_DEVICE when enabled. Device memory cannot be used
> for regular kernel memory allocations so this will cause a kernel panic at
> boot.
>
> Given the planned addition of more mm managed zones (ZONE_CMA) we should
> aim to be consistent with every other architecture and set the max PFN
> for these zones to zero
>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>
Reviewed-by: Balbir Singh <bsingharora@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-05-05 7:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-05 6:24 [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Oliver O'Halloran
2016-05-05 6:24 ` [PATCH 2/2] powerpc/mm: Ensure "special" zones are empty Oliver O'Halloran
2016-05-05 7:05 ` Balbir Singh
2016-05-05 7:04 ` [PATCH 1/2] powerpc/mm: define TOP_ZONE as a constant Balbir Singh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.