From patchwork Sun May 24 16:02:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jungseok Lee X-Patchwork-Id: 6472191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A92A69F38C for ; Sun, 24 May 2015 16:05:05 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1D56C20546 for ; Sun, 24 May 2015 16:05:02 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3223A2053D for ; Sun, 24 May 2015 16:05:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YwYMc-0000d2-NK; Sun, 24 May 2015 16:02:58 +0000 Received: from mail-pa0-x233.google.com ([2607:f8b0:400e:c03::233]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YwYMU-0000Tl-Ng for linux-arm-kernel@lists.infradead.org; Sun, 24 May 2015 16:02:54 +0000 Received: by pabru16 with SMTP id ru16so54649809pab.1 for ; Sun, 24 May 2015 09:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=vaD9v+5/IE70TDpcOtoRkaWnbn80zlPd0aXHg+q+W0Y=; b=KxIfvKkJnhTxzhB7Bf0iTmHzIbyiPA51NrQGnN+Rg4c2zncvw3ccpXTgd/AaJvgVBe l7ywgJgkSWz+Ukohxn5pjtQ2hjqsZnwsrb27wE78SVGHn0ELI/k0JGCZAshPfVG7tMZ6 Oau63WqrUCFdbfR+7VFypUieRlvfOnuYg0kRWX/YmuGBbFp82xO3rWY2b+zogbjGnMzM i/6TBMJwTx4U4JHZTl1iD788qx0LJNH8LWCl4FqqV6XotyLmRyAKQ+0Uq7dVhBvDLmL7 tms9hZxgS58ZcFMXjwLTCB5EjI14Lq4ufYiH4WWfetCJqlMvjkZS4+rD2treUyL8qS0J /wrw== X-Received: by 10.66.243.69 with SMTP id ww5mr32758902pac.106.1432483349527; Sun, 24 May 2015 09:02:29 -0700 (PDT) Received: from localhost.localdomain ([116.121.77.221]) by mx.google.com with ESMTPSA id jp10sm7532078pbb.9.2015.05.24.09.02.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 24 May 2015 09:02:29 -0700 (PDT) From: Jungseok Lee To: linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/2] arm64: Implement vmalloc based thread_info allocator Date: Mon, 25 May 2015 01:02:20 +0900 Message-Id: <1432483340-23157-1-git-send-email-jungseoklee85@gmail.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150524_090250_826301_400B251F X-CRM114-Status: GOOD ( 13.68 ) X-Spam-Score: -0.6 (/) Cc: Catalin Marinas , barami97@gmail.com, Will Deacon , linux-kernel@vger.kernel.org, linux-mm@kvack.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Fork-routine sometimes fails to get a physically contiguous region for thread_info on 4KB page system although free memory is enough. That is, a physically contiguous region, which is currently 16KB, is not available since system memory is fragmented. This patch tries to solve the problem as allocating thread_info memory from vmalloc space, not 1:1 mapping one. The downside is one additional page allocation in case of vmalloc. However, vmalloc space is large enough, around 240GB, under a combination of 39-bit VA and 4KB page. Thus, it is not a big tradeoff for fork-routine service. Suggested-by: Sungjinn Chung Signed-off-by: Jungseok Lee Cc: Catalin Marinas Cc: Will Deacon Cc: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org --- arch/arm64/Kconfig | 12 ++++++++++++ arch/arm64/include/asm/thread_info.h | 9 +++++++++ arch/arm64/kernel/process.c | 7 +++++++ 3 files changed, 28 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 99930cf..93c236a 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -536,6 +536,18 @@ config ARCH_SELECT_MEMORY_MODEL config HAVE_ARCH_PFN_VALID def_bool ARCH_HAS_HOLES_MEMORYMODEL || !SPARSEMEM +config ARCH_THREAD_INFO_ALLOCATOR + bool "Enable vmalloc based thread_info allocator (EXPERIMENTAL)" + depends on ARM64_4K_PAGES + default n + help + This feature enables vmalloc based thread_info allocator. It + prevents fork-routine from begin failed to obtain physically + contiguour region due to memory fragmentation on low system + memory platforms. + + If unsure, say N + config HW_PERF_EVENTS bool "Enable hardware performance counter support for perf events" depends on PERF_EVENTS diff --git a/arch/arm64/include/asm/thread_info.h b/arch/arm64/include/asm/thread_info.h index dcd06d1..e753e59 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -61,6 +61,15 @@ struct thread_info { #define init_thread_info (init_thread_union.thread_info) #define init_stack (init_thread_union.stack) +#ifdef CONFIG_ARCH_THREAD_INFO_ALLOCATOR +#define alloc_thread_info_node(tsk, node) \ +({ \ + __vmalloc_node_range(THREAD_SIZE, THREAD_SIZE, VMALLOC_START, \ + VMALLOC_END, GFP_KERNEL, PAGE_KERNEL, 0, \ + NUMA_NO_NODE, __builtin_return_address(0)); \ +}) +#define free_thread_info(ti) vfree(ti) +#endif /* * how to get the current stack pointer from C */ diff --git a/arch/arm64/kernel/process.c b/arch/arm64/kernel/process.c index c506bee..c4b6aae 100644 --- a/arch/arm64/kernel/process.c +++ b/arch/arm64/kernel/process.c @@ -238,6 +238,13 @@ int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) return 0; } +#ifdef CONFIG_ARCH_THREAD_INFO_ALLOCATOR +struct page *arch_thread_info_to_page(struct thread_info *ti) +{ + return vmalloc_to_page(ti); +} +#endif + asmlinkage void ret_from_fork(void) asm("ret_from_fork"); int copy_thread(unsigned long clone_flags, unsigned long stack_start,