Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753122AbcLFJNS (ORCPT ); Tue, 6 Dec 2016 04:13:18 -0500 Received: from mail-io0-f173.google.com ([209.85.223.173]:33103 "EHLO mail-io0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753080AbcLFJNL (ORCPT ); Tue, 6 Dec 2016 04:13:11 -0500 MIME-Version: 1.0 In-Reply-To: <1481012975-44478-1-git-send-email-maninder1.s@samsung.com> References: <1481012975-44478-1-git-send-email-maninder1.s@samsung.com> From: Ard Biesheuvel Date: Tue, 6 Dec 2016 09:13:10 +0000 Message-ID: Subject: Re: [PATCH 1/1] arm/module: maximum utilization of module area. To: Maninder Singh Cc: Russell King , Nicolas Pitre , ssantosh@kernel.org, Pratyush Anand , Arnd Bergmann , Chris Brandt , Vaneet Narang , "linux-kernel@vger.kernel.org" , ajeet.y@samsung.com, "linux-arm-kernel@lists.infradead.org" , pankaj.m@samsung.com Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3262 Lines: 91 On 6 December 2016 at 08:29, Maninder Singh wrote: > This patch defines new macro MODULE_START to ensure kernel text > and module remains within 32 MB of address range. > > Tried this patch by inserting 20 MB size module on 4.1 kernel:- > > Earlier:- > ========== > sh# insmod size.ko > .... > insmod: ERROR: could not insert module size.ko: Cannot allocate memory > sh# > > With this patch > =============== > sh# insmod size.ko > ... > sh# lsmod > Module Size Used by > size 20972425 0 > > Signed-off-by: Vaneet Narang > Signed-off-by: Maninder Singh > Reviewed-by: Ajeet Yadav > --- > arch/arm/include/asm/memory.h | 4 ++-- > arch/arm/kernel/module.c | 9 ++++++++- > 2 files changed, 10 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h > index 76cbd9c..1a0a6e5 100644 > --- a/arch/arm/include/asm/memory.h > +++ b/arch/arm/include/asm/memory.h > @@ -37,7 +37,7 @@ > * TASK_SIZE - the maximum size of a user space task. > * TASK_UNMAPPED_BASE - the lower boundary of the mmap VM area > */ > -#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_16M)) > +#define TASK_SIZE (UL(CONFIG_PAGE_OFFSET) - UL(SZ_32M)) > #define TASK_UNMAPPED_BASE ALIGN(TASK_SIZE / 3, SZ_16M) > > /* > @@ -50,7 +50,7 @@ > * and PAGE_OFFSET - it must be within 32MB of the kernel text. > */ > #ifndef CONFIG_THUMB2_KERNEL > -#define MODULES_VADDR (PAGE_OFFSET - SZ_16M) > +#define MODULES_VADDR (PAGE_OFFSET - SZ_32M) > #else > /* smaller range for Thumb-2 symbols relocation (2^24)*/ > #define MODULES_VADDR (PAGE_OFFSET - SZ_8M) > diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c > index 4f14b5c..b8e1f9c 100644 > --- a/arch/arm/kernel/module.c > +++ b/arch/arm/kernel/module.c > @@ -35,12 +35,19 @@ > */ > #undef MODULES_VADDR > #define MODULES_VADDR (((unsigned long)_exiprom + ~PMD_MASK) & PMD_MASK) > +#define MODULES_START MODULES_VADDR > +#else > +#ifndef CONFIG_THUMB2_KERNEL > +#define MODULES_START ALIGN((unsigned long)_etext - SZ_32M, PAGE_SIZE) On a multi_v7_defconfig kernel, the text size is >8 MB, which means you are only adding ~7 MB to the module area, while consuming 16 MB of additional address space. Given that 20 MB modules are very uncommon, I think it is better to enable CONFIG_ARM_MODULE_PLTS instead. That way, there is no need to update these defaults for everyone. > +#else > +#define MODULES_START MODULES_VADDR > +#endif > #endif > > #ifdef CONFIG_MMU > void *module_alloc(unsigned long size) > { > - void *p = __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END, > + void *p = __vmalloc_node_range(size, 1, MODULES_START, MODULES_END, > GFP_KERNEL, PAGE_KERNEL_EXEC, 0, NUMA_NO_NODE, > __builtin_return_address(0)); > if (!IS_ENABLED(CONFIG_ARM_MODULE_PLTS) || p) > -- > 1.9.1 > > > _______________________________________________ > linux-arm-kernel mailing list > linux-arm-kernel@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel