From patchwork Tue Aug 7 13:37:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10558721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8B59413BB for ; Tue, 7 Aug 2018 13:38:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7918E29E12 for ; Tue, 7 Aug 2018 13:38:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CC5629E24; Tue, 7 Aug 2018 13:38:27 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B859429E12 for ; Tue, 7 Aug 2018 13:38:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F2D6E6B000A; Tue, 7 Aug 2018 09:38:23 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E8E006B000C; Tue, 7 Aug 2018 09:38:23 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDD766B000D; Tue, 7 Aug 2018 09:38:23 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f72.google.com (mail-wm0-f72.google.com [74.125.82.72]) by kanga.kvack.org (Postfix) with ESMTP id 739916B000A for ; Tue, 7 Aug 2018 09:38:23 -0400 (EDT) Received: by mail-wm0-f72.google.com with SMTP id z11-v6so10379758wma.4 for ; Tue, 07 Aug 2018 06:38:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=CPRN2w6qtUBwxTo39JZZYnJbZhBo7PZFu0H11s8wxkA=; b=tUsRSpCSI1avTrGWaZEyu1c0ktGxJmPQb+mwkDqlTRnsGXCHRAHpRTwVuSTGMl4pjM 2s3XKCdgF/iAaR+05Zp7fXoJm5PwFgtlwyUZN6VmPKuzZuTOSurwkwfbf6dnSR0rXXEI z1oCqEAAN/ds0bUzEC66bOTyzEksqAXtcQZCMzHIvyBLRtjoBRAi1RbbAC+5tSJzB/zP KCyPPx0BjHOt0i+KTAytQllXfCHNTXPmlhWjNaSxGQTLh54Xtv7tcynQvmXIO2kL73ui pdvK7vLQQI+7eHlGaBzqYfXl09CPXiHygEQ0f2hZc2sPuNn9TLL9TN1XjzTRgjI/v09r dfdw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Gm-Message-State: AOUpUlFvEDylRLqNHrbC62xQ4LJivPvw8FWebI4fHh8HWbT7zJtVC0M2 WmdZLXc2xT3A6N0dzQ/52brQooTNYIHhtfK5OyTAnFAVDwff/kbJCgDTycaxSVGbNF3KGiJPzXz 9RaghEDxkTv4KOeEVOY+17fDXrwcW4BGKGWJ/CHB07rmv29vCxRHWRsDrGbzAqaJGuuPIPoLTwZ A8mQ4E4Q6u7OljTx1mhb9hYqqQRYayQZD/9/5BiNoDLxuGdpxrsim1ipJrp979Fa5xnmwYA0pED /HJofjz5fWlnUFMzazNbFPA16pP6YT51mIG1ZqwsziXX/+bOjXdw3UXfGr8guZ/GPIbRKAMHZbP yYJvHoHedrzNviDDm9zc9m4KKzmQRD18VMCjKqAPgOGxF506cinC31CING2g+y83Wf/ELHEr2w= = X-Received: by 2002:adf:ba12:: with SMTP id o18-v6mr13532966wrg.249.1533649103012; Tue, 07 Aug 2018 06:38:23 -0700 (PDT) X-Received: by 2002:adf:ba12:: with SMTP id o18-v6mr13532935wrg.249.1533649102126; Tue, 07 Aug 2018 06:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533649102; cv=none; d=google.com; s=arc-20160816; b=VRtba6BJvWEGL9+astQIMz3QPWkTTbKszS6TSCh29bhnWTUTUkmNMYIGx3OYxO12XI 1UhHxQGVPiBi6q/svCs7Of7+XvPS3AzcAbqxJCku5CqxBUMFuf+Ff2DBcoUQPXdZV1TL JCmGr3AeLO4HeTfLFWW+VNl3O/nY9z8NWQ/dkXT9dNaVY0g0k9DwYbUlrzBNg8V0UaIl F0T0eHbjvJpxrr8ROljKdQ9yFQBhax7kkxuk3lKsLRRUXWkhv4aFZz1+2/GLwxEf93SG f95fCkPARVyzY16tBMa42P6Jw2iRhOMr+pMGLeGj0+xy/3BJPKGk9oXHP4pFzZ9wkQ0D 13AQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=CPRN2w6qtUBwxTo39JZZYnJbZhBo7PZFu0H11s8wxkA=; b=n5Tv0RQIjzhROIfzl6IMEux7x1bFSU8m0iLeQdsYtMLDwB4lgL4OMz0pu9IAF9K8C8 QGLOq9jKAQRNrQcLXB9IEXhjufom29i2pwHSudfFPQT3Rmg3GU9C5qfktFM96TfjNgSZ b7l6xDECjyWL5/m60f4r5iTqYbVnRwlDK76YwocTDsNSB37gEirFFentnoxUcO2ZcTvP g6zuUST2L08BP/vysqiHiKLXdO3CMiBpur2xLG9Rao0s3dV8O03zSOEJj6jdWMHKuBKW C8W9YY10JwkOuOL/Atpt2z06Lznn2Mo1Il8Gj2TVBp63kS6tMsXYxSimy3BpvXCTX9X+ paUQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n198-v6sor462844wmd.1.2018.08.07.06.38.21 for (Google Transport Security); Tue, 07 Aug 2018 06:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador.vilardaga@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=osalvador.vilardaga@gmail.com X-Google-Smtp-Source: AA+uWPzlbCizfcOneDjMSjyEEQQiUMYD0HdfiHaa4zEQOlkQlK9fAFpaWAdZxJLm2/6s/tUpZ6ms9w== X-Received: by 2002:a7b:c041:: with SMTP id u1-v6mr1766504wmc.53.1533649101731; Tue, 07 Aug 2018 06:38:21 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id w4-v6sm1999312wrl.46.2018.08.07.06.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Aug 2018 06:38:20 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id E77FF1246FB; Tue, 7 Aug 2018 15:38:19 +0200 (CEST) From: osalvador@techadventures.net To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, pasha.tatashin@oracle.com, jglisse@redhat.com, david@redhat.com, yasu.isimatu@gmail.com, logang@deltatee.com, dave.jiang@intel.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Oscar Salvador Subject: [RFC PATCH 1/3] mm/memory_hotplug: Add nid parameter to arch_remove_memory Date: Tue, 7 Aug 2018 15:37:55 +0200 Message-Id: <20180807133757.18352-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180807133757.18352-1-osalvador@techadventures.net> References: <20180807133757.18352-1-osalvador@techadventures.net> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Oscar Salvador This patch is only a preparation for the following-up patches. The idea is to remove the zone parameter and pass the nid instead. The zone parameter was needed because down the chain we call __remove_zone, which adjusts the spanned pages of a zone/node. online_pages() increments the spanned pages of a zone/node, so for consistency it is better if we move __remove_zone to offline_pages(). With that, remove_memory() will only take care of removing the sections and delete the mappings. Signed-off-by: Oscar Salvador --- arch/ia64/mm/init.c | 2 +- arch/powerpc/mm/mem.c | 2 +- arch/s390/mm/init.c | 2 +- arch/sh/mm/init.c | 2 +- arch/x86/mm/init_32.c | 2 +- arch/x86/mm/init_64.c | 2 +- include/linux/memory_hotplug.h | 2 +- kernel/memremap.c | 4 +++- mm/hmm.c | 4 +++- mm/memory_hotplug.c | 2 +- 10 files changed, 14 insertions(+), 10 deletions(-) diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index e6c6dfd98de2..bc5e15045cee 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -660,7 +660,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c index 5c8530d0c611..9e17d57a9948 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -139,7 +139,7 @@ int __meminit arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap * } #ifdef CONFIG_MEMORY_HOTREMOVE -int __meminit arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int __meminit arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; diff --git a/arch/s390/mm/init.c b/arch/s390/mm/init.c index 3fa3e5323612..bc49b560625e 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -240,7 +240,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { /* * There is no hardware or firmware interface which could trigger a diff --git a/arch/sh/mm/init.c b/arch/sh/mm/init.c index 4034035fbede..55c740ab861b 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -454,7 +454,7 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid); #endif #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { unsigned long start_pfn = PFN_DOWN(start); unsigned long nr_pages = size >> PAGE_SHIFT; diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c index 979e0a02cbe1..9fa503f2f56c 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -861,7 +861,7 @@ int arch_add_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap, } #ifdef CONFIG_MEMORY_HOTREMOVE -int arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c index 9b19f9a8948e..26728df07072 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1148,7 +1148,7 @@ kernel_physical_mapping_remove(unsigned long start, unsigned long end) remove_pagetable(start, end, true, NULL); } -int __ref arch_remove_memory(u64 start, u64 size, struct vmem_altmap *altmap) +int __ref arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap) { unsigned long start_pfn = start >> PAGE_SHIFT; unsigned long nr_pages = size >> PAGE_SHIFT; diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h index 34a28227068d..c68b03fd87bd 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -107,7 +107,7 @@ static inline bool movable_node_is_enabled(void) } #ifdef CONFIG_MEMORY_HOTREMOVE -extern int arch_remove_memory(u64 start, u64 size, +extern int arch_remove_memory(int nid, u64 start, u64 size, struct vmem_altmap *altmap); extern int __remove_pages(struct zone *zone, unsigned long start_pfn, unsigned long nr_pages, struct vmem_altmap *altmap); diff --git a/kernel/memremap.c b/kernel/memremap.c index 5b8600d39931..7a832b844f24 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -121,6 +121,7 @@ static void devm_memremap_pages_release(void *data) struct resource *res = &pgmap->res; resource_size_t align_start, align_size; unsigned long pfn; + int nid; for_each_device_pfn(pfn, pgmap) put_page(pfn_to_page(pfn)); @@ -134,9 +135,10 @@ static void devm_memremap_pages_release(void *data) align_start = res->start & ~(SECTION_SIZE - 1); align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) - align_start; + nid = dev_to_node(dev); mem_hotplug_begin(); - arch_remove_memory(align_start, align_size, pgmap->altmap_valid ? + arch_remove_memory(nid, align_start, align_size, pgmap->altmap_valid ? &pgmap->altmap : NULL); kasan_remove_zero_shadow(__va(align_start), align_size); mem_hotplug_done(); diff --git a/mm/hmm.c b/mm/hmm.c index c968e49f7a0c..21787e480b4a 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -995,6 +995,7 @@ static void hmm_devmem_release(struct device *dev, void *data) unsigned long start_pfn, npages; struct zone *zone; struct page *page; + int nid; if (percpu_ref_tryget_live(&devmem->ref)) { dev_WARN(dev, "%s: page mapping is still live!\n", __func__); @@ -1007,12 +1008,13 @@ static void hmm_devmem_release(struct device *dev, void *data) page = pfn_to_page(start_pfn); zone = page_zone(page); + nid = zone->zone_pgdat->node_id; mem_hotplug_begin(); if (resource->desc == IORES_DESC_DEVICE_PRIVATE_MEMORY) __remove_pages(zone, start_pfn, npages, NULL); else - arch_remove_memory(start_pfn << PAGE_SHIFT, + arch_remove_memory(nid, start_pfn << PAGE_SHIFT, npages << PAGE_SHIFT, NULL); mem_hotplug_done(); diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 9eea6e809a4e..9bd629944c91 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1895,7 +1895,7 @@ void __ref remove_memory(int nid, u64 start, u64 size) memblock_free(start, size); memblock_remove(start, size); - arch_remove_memory(start, size, NULL); + arch_remove_memory(nid, start, size, NULL); try_offline_node(nid);