From patchwork Fri Dec 2 00:19:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Scott Branden X-Patchwork-Id: 9457475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2B2166074E for ; Fri, 2 Dec 2016 00:22:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1B7692852B for ; Fri, 2 Dec 2016 00:22:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E98728537; Fri, 2 Dec 2016 00:22:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ABCB62852B for ; Fri, 2 Dec 2016 00:22:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCbbK-0002T9-D9; Fri, 02 Dec 2016 00:21:18 +0000 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cCbal-0001Te-VV for linux-arm-kernel@lists.infradead.org; Fri, 02 Dec 2016 00:20:47 +0000 Received: by mail-pg0-x22a.google.com with SMTP id f188so100141853pgc.3 for ; Thu, 01 Dec 2016 16:20:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=twZ9MinU9jp//lRv5kInpnMcxYIGV0XN9zE0Laigya0=; b=NoPochTDpywAifMogHAN5skxoHZlBiPaVlDkHby27d+WNkZJ3GRjUnCPn+bS1tR7J4 CLvyAcIgRb1xP/pJibE7SE/tAqzA0sEIeU5nFW+uIqE4/AhFdVKGzBmsAIryfhKNucdd Jcm2PZ0nenOOGgV0bpz+EYIjSy8xJqxzs/0OU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=twZ9MinU9jp//lRv5kInpnMcxYIGV0XN9zE0Laigya0=; b=RTcwyWHc2RScLnMHBiTpzlmLBfIXghY+G6k0cMvzlDm47wnDUDjIMiYQRAVOWlW9gU s2/Hw0ZYvb8s4OTJS2Gcl3M/4UWP5gmk3KeAddxghBG7BqYKzAcxqDryyOLXMS4t6Otd l963faEwLfLk7NwgtYFRV6Rk3dfHstotBrArUxVrM5ifU1NxMTbnGFMofrg2E7fej6T7 Gq33CcUsVyANey2nWT7UVSxVOQ/mbaY5E8oCaj2x/Ow+sSaL8cDC+jakcv03MlRHLour SxfOtRNOH8Q3LsuOhqUq8ILOBwbe8p8/jpQ+I9xfCDyxhDoL2HetdD1VYg31wYYIkPZ+ CBQA== X-Gm-Message-State: AKaTC01qAgMI2GiE6gRhcpqT9OnYazXPtHL6f/gdRyLBYRAxELW/g9tYHeWPcYldAj3lbYyJ X-Received: by 10.99.66.198 with SMTP id p189mr74302093pga.30.1480638022247; Thu, 01 Dec 2016 16:20:22 -0800 (PST) Received: from lbrmn-lnxub113.ric.broadcom.com ([192.19.224.250]) by smtp.gmail.com with ESMTPSA id u23sm2570586pfg.86.2016.12.01.16.20.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Dec 2016 16:20:21 -0800 (PST) From: Scott Branden To: Arnd Bergmann , Russell King , Catalin Marinas , Will Deacon , Ard Biesheuvel , Mark Rutland , Xishi Qiu , bielski@fastmail.net Subject: [RFC PATCH 1/2] arm64: memory-hotplug: Add MEMORY_HOTPLUG, MEMORY_HOTREMOVE, MEMORY_PROBE Date: Thu, 1 Dec 2016 16:19:58 -0800 Message-Id: <1480637999-4320-2-git-send-email-scott.branden@broadcom.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1480637999-4320-1-git-send-email-scott.branden@broadcom.com> References: <1480637999-4320-1-git-send-email-scott.branden@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161201_162044_282868_27543487 X-CRM114-Status: GOOD ( 12.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Scott Branden , BCM Kernel Feedback , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Tang Chen MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Add memory-hotplug support for ARM64 platform. This requires addition of ARCH_ENABLE_MEMORY_HOTPLUG and ARCH_ENABLE_MEMORY_HOTREMOVE config options. MEMORY_PROBE config option is added to support /sys/devices/system/memory/probe functionality. In addition architecture specific arch_add_memory and arch_remove memory management functions are added. Signed-off-by: Scott Branden --- arch/arm64/Kconfig | 10 ++++++++++ arch/arm64/mm/init.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 969ef88..2482fdd 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -576,6 +576,12 @@ config HOTPLUG_CPU Say Y here to experiment with turning CPUs off and on. CPUs can be controlled through /sys/devices/system/cpu. +config ARCH_ENABLE_MEMORY_HOTPLUG + def_bool y + +config ARCH_ENABLE_MEMORY_HOTREMOVE + def_bool y + # Common NUMA Features config NUMA bool "Numa Memory Allocation and Scheduler Support" @@ -646,6 +652,10 @@ config ARCH_HAS_CACHE_LINE_SIZE source "mm/Kconfig" +config ARCH_MEMORY_PROBE + def_bool y + depends on MEMORY_HOTPLUG + config SECCOMP bool "Enable seccomp to safely compute untrusted bytecode" ---help--- diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 212c4d1..687d087 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -536,3 +536,45 @@ static int __init register_mem_limit_dumper(void) return 0; } __initcall(register_mem_limit_dumper); + +#ifdef CONFIG_MEMORY_HOTPLUG +int arch_add_memory(int nid, u64 start, u64 size, bool for_device) +{ + pg_data_t *pgdat; + struct zone *zone; + unsigned long start_pfn = start >> PAGE_SHIFT; + unsigned long nr_pages = size >> PAGE_SHIFT; + int ret; + + pgdat = NODE_DATA(nid); + + zone = pgdat->node_zones + + zone_for_memory(nid, start, size, ZONE_NORMAL, for_device); + ret = __add_pages(nid, zone, start_pfn, nr_pages); + + if (ret) + pr_warn("%s: Problem encountered in __add_pages() ret=%d\n", + __func__, ret); + + return ret; +} + +#ifdef CONFIG_MEMORY_HOTREMOVE +int arch_remove_memory(u64 start, u64 size) +{ + unsigned long start_pfn = start >> PAGE_SHIFT; + unsigned long nr_pages = size >> PAGE_SHIFT; + struct zone *zone; + int ret; + + zone = page_zone(pfn_to_page(start_pfn)); + ret = __remove_pages(zone, start_pfn, nr_pages); + if (ret) + pr_warn("%s: Problem encountered in __remove_pages() ret=%d\n", + __func__, ret); + + return ret; +} +#endif +#endif +