Message ID | 1454718288-31374-3-git-send-email-labbott@fedoraproject.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Feb 05, 2016 at 04:24:47PM -0800, Laura Abbott wrote: > --- a/arch/arm64/mm/mmu.c > +++ b/arch/arm64/mm/mmu.c > @@ -149,6 +149,19 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd) > } while (pmd++, i++, i < PTRS_PER_PMD); > } > > +bool block_mappings_allowed(phys_addr_t (*pgtable_alloc)(void)) > +{ > + > + /* > + * If debug_page_alloc is enabled we must map the linear map > + * using pages. However, other mappings created by > + * create_mapping_noalloc must use sections in some cases. Allow > + * sections to be used in those cases, where no pgtable_alloc > + * function is provided. > + */ > + return !pgtable_alloc || !debug_pagealloc_enabled(); > +} This breaks the build when CONFIG_DEBUG_PAGEALLOC is not enabled (defconfig) since debug_pagealloc_enabled() is not defined. A fix went in next/master as commit 0987684b855c ("mm-slab-clean-up-debug_pagealloc-processing-code-fix"). I need to track it down and merge it via the arm64 tree, otherwise I'll add some #ifdefs in this function. BTW, shouldn't the block_mappings_allowed() function be static?
On 10 February 2016 at 11:38, Catalin Marinas <catalin.marinas@arm.com> wrote: > On Fri, Feb 05, 2016 at 04:24:47PM -0800, Laura Abbott wrote: >> --- a/arch/arm64/mm/mmu.c >> +++ b/arch/arm64/mm/mmu.c >> @@ -149,6 +149,19 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd) >> } while (pmd++, i++, i < PTRS_PER_PMD); >> } >> >> +bool block_mappings_allowed(phys_addr_t (*pgtable_alloc)(void)) >> +{ >> + >> + /* >> + * If debug_page_alloc is enabled we must map the linear map >> + * using pages. However, other mappings created by >> + * create_mapping_noalloc must use sections in some cases. Allow >> + * sections to be used in those cases, where no pgtable_alloc >> + * function is provided. >> + */ >> + return !pgtable_alloc || !debug_pagealloc_enabled(); >> +} > > This breaks the build when CONFIG_DEBUG_PAGEALLOC is not enabled > (defconfig) since debug_pagealloc_enabled() is not defined. A fix went > in next/master as commit 0987684b855c > ("mm-slab-clean-up-debug_pagealloc-processing-code-fix"). I need to > track it down and merge it via the arm64 tree, otherwise I'll add some > #ifdefs in this function. > > BTW, shouldn't the block_mappings_allowed() function be static? > Yes, it should.
On Wed, Feb 10, 2016 at 10:38:14AM +0000, Catalin Marinas wrote: > On Fri, Feb 05, 2016 at 04:24:47PM -0800, Laura Abbott wrote: > > --- a/arch/arm64/mm/mmu.c > > +++ b/arch/arm64/mm/mmu.c > > @@ -149,6 +149,19 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd) > > } while (pmd++, i++, i < PTRS_PER_PMD); > > } > > > > +bool block_mappings_allowed(phys_addr_t (*pgtable_alloc)(void)) > > +{ > > + > > + /* > > + * If debug_page_alloc is enabled we must map the linear map > > + * using pages. However, other mappings created by > > + * create_mapping_noalloc must use sections in some cases. Allow > > + * sections to be used in those cases, where no pgtable_alloc > > + * function is provided. > > + */ > > + return !pgtable_alloc || !debug_pagealloc_enabled(); > > +} > > This breaks the build when CONFIG_DEBUG_PAGEALLOC is not enabled > (defconfig) since debug_pagealloc_enabled() is not defined. A fix went > in next/master as commit 0987684b855c > ("mm-slab-clean-up-debug_pagealloc-processing-code-fix"). I need to > track it down and merge it via the arm64 tree, otherwise I'll add some > #ifdefs in this function. In the cover for v2 [1], it was mentioend that we needed a patch [2] "mm: provide debug_pagealloc_enabled() without CONFIG_DEBUG_PAGEALLOC". I assumed that was already queued via the mm tree. > BTW, shouldn't the block_mappings_allowed() function be static? That would make sense to me, yes. Mark. [1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/403439.html [2] http://article.gmane.org/gmane.linux.kernel.mm/1452
On Wed, Feb 10, 2016 at 10:38:14AM +0000, Catalin Marinas wrote: > On Fri, Feb 05, 2016 at 04:24:47PM -0800, Laura Abbott wrote: > > --- a/arch/arm64/mm/mmu.c > > +++ b/arch/arm64/mm/mmu.c > > @@ -149,6 +149,19 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd) > > } while (pmd++, i++, i < PTRS_PER_PMD); > > } > > > > +bool block_mappings_allowed(phys_addr_t (*pgtable_alloc)(void)) > > +{ > > + > > + /* > > + * If debug_page_alloc is enabled we must map the linear map > > + * using pages. However, other mappings created by > > + * create_mapping_noalloc must use sections in some cases. Allow > > + * sections to be used in those cases, where no pgtable_alloc > > + * function is provided. > > + */ > > + return !pgtable_alloc || !debug_pagealloc_enabled(); > > +} > > This breaks the build when CONFIG_DEBUG_PAGEALLOC is not enabled > (defconfig) since debug_pagealloc_enabled() is not defined. A fix went > in next/master as commit 0987684b855c > ("mm-slab-clean-up-debug_pagealloc-processing-code-fix"). I need to > track it down and merge it via the arm64 tree, otherwise I'll add some > #ifdefs in this function. It seems that there are other patches in the mm tree requiring this change. I'll fix it locally (#ifdefs) and revert the change after -rc1.
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 8cc6228..0f33218 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -537,6 +537,9 @@ config HOTPLUG_CPU source kernel/Kconfig.preempt source kernel/Kconfig.hz +config ARCH_SUPPORTS_DEBUG_PAGEALLOC + def_bool y + config ARCH_HAS_HOLES_MEMORYMODEL def_bool y if SPARSEMEM diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c index ef0d66c..29dcc83 100644 --- a/arch/arm64/mm/mmu.c +++ b/arch/arm64/mm/mmu.c @@ -149,6 +149,19 @@ static void split_pud(pud_t *old_pud, pmd_t *pmd) } while (pmd++, i++, i < PTRS_PER_PMD); } +bool block_mappings_allowed(phys_addr_t (*pgtable_alloc)(void)) +{ + + /* + * If debug_page_alloc is enabled we must map the linear map + * using pages. However, other mappings created by + * create_mapping_noalloc must use sections in some cases. Allow + * sections to be used in those cases, where no pgtable_alloc + * function is provided. + */ + return !pgtable_alloc || !debug_pagealloc_enabled(); +} + static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, phys_addr_t phys, pgprot_t prot, phys_addr_t (*pgtable_alloc)(void)) @@ -181,7 +194,8 @@ static void alloc_init_pmd(pud_t *pud, unsigned long addr, unsigned long end, do { next = pmd_addr_end(addr, end); /* try section mapping first */ - if (((addr | next | phys) & ~SECTION_MASK) == 0) { + if (((addr | next | phys) & ~SECTION_MASK) == 0 && + block_mappings_allowed(pgtable_alloc)) { pmd_t old_pmd =*pmd; set_pmd(pmd, __pmd(phys | pgprot_val(mk_sect_prot(prot)))); @@ -241,7 +255,8 @@ static void alloc_init_pud(pgd_t *pgd, unsigned long addr, unsigned long end, /* * For 4K granule only, attempt to put down a 1GB block */ - if (use_1G_block(addr, next, phys)) { + if (use_1G_block(addr, next, phys) && + block_mappings_allowed(pgtable_alloc)) { pud_t old_pud = *pud; set_pud(pud, __pud(phys | pgprot_val(mk_sect_prot(prot)))); diff --git a/arch/arm64/mm/pageattr.c b/arch/arm64/mm/pageattr.c index 1360a02..7ba87c4 100644 --- a/arch/arm64/mm/pageattr.c +++ b/arch/arm64/mm/pageattr.c @@ -37,14 +37,31 @@ static int change_page_range(pte_t *ptep, pgtable_t token, unsigned long addr, return 0; } +/* + * This function assumes that the range is mapped with PAGE_SIZE pages. + */ +static int __change_memory_common(unsigned long start, unsigned long size, + pgprot_t set_mask, pgprot_t clear_mask) +{ + struct page_change_data data; + int ret; + + data.set_mask = set_mask; + data.clear_mask = clear_mask; + + ret = apply_to_page_range(&init_mm, start, size, change_page_range, + &data); + + flush_tlb_kernel_range(start, start + size); + return ret; +} + static int change_memory_common(unsigned long addr, int numpages, pgprot_t set_mask, pgprot_t clear_mask) { unsigned long start = addr; unsigned long size = PAGE_SIZE*numpages; unsigned long end = start + size; - int ret; - struct page_change_data data; struct vm_struct *area; if (!PAGE_ALIGNED(addr)) { @@ -72,14 +89,7 @@ static int change_memory_common(unsigned long addr, int numpages, !(area->flags & VM_ALLOC)) return -EINVAL; - data.set_mask = set_mask; - data.clear_mask = clear_mask; - - ret = apply_to_page_range(&init_mm, start, size, change_page_range, - &data); - - flush_tlb_kernel_range(start, end); - return ret; + return __change_memory_common(start, size, set_mask, clear_mask); } int set_memory_ro(unsigned long addr, int numpages) @@ -111,3 +121,19 @@ int set_memory_x(unsigned long addr, int numpages) __pgprot(PTE_PXN)); } EXPORT_SYMBOL_GPL(set_memory_x); + +#ifdef CONFIG_DEBUG_PAGEALLOC +void __kernel_map_pages(struct page *page, int numpages, int enable) +{ + unsigned long addr = (unsigned long) page_address(page); + + if (enable) + __change_memory_common(addr, PAGE_SIZE * numpages, + __pgprot(PTE_VALID), + __pgprot(0)); + else + __change_memory_common(addr, PAGE_SIZE * numpages, + __pgprot(0), + __pgprot(PTE_VALID)); +} +#endif