From patchwork Fri Aug 17 15:41:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10569085 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 C773E15E2 for ; Fri, 17 Aug 2018 15:41:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6D902BD7B for ; Fri, 17 Aug 2018 15:41:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AAB9A2BD7E; Fri, 17 Aug 2018 15:41:46 +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 660442BD7B for ; Fri, 17 Aug 2018 15:41:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 607126B08ED; Fri, 17 Aug 2018 11:41:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5652D6B08F0; Fri, 17 Aug 2018 11:41:40 -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 27E956B08ED; Fri, 17 Aug 2018 11:41:40 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id AE18D6B08EE for ; Fri, 17 Aug 2018 11:41:39 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id s25-v6so1341403wmh.1 for ; Fri, 17 Aug 2018 08:41:39 -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=iZlmTvhU0cDqGXWGlJNX2R9bE+JQXFCjRoVfJ72HKmY=; b=CTLnKZGlgYFsBdVLz+XR2C+NsVkPA6ogQSdpqB+QuSXGtHYKMyHxY/LRYlLYr5UdcQ Tx+8W5eGx2TXt0i0oHm69e4LtHsaF7D7nfU5GCFDeo3hUZXoWDmIhdinbMxX7zHnuVxT CcyNkmU4mLgtmdNGx4whK/2G0T7oIL/B4QOVUTTnJoXw1Ib51fa2Q/Mm+ox+Cqf7XoNM SoZgpjP2z325y5t89/t/FvKR5tWCpwrvgIMYWQUk6mO7+HkpsdzkKQd0c+76kS4jhBNW 4srLBmA8/Ske7lTJa0WzcnIcAVFE/r3cPxbGAsOGcUJciZu/Np7sNtIAVcWgeV1XcSjy 8SWw== 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: AOUpUlHF+clf7fIL8TTyvNvMSM4L0NyVkWotFeaKNzZ8+XD/4H+4d8cP MFa8PTnBYqHwbH5nmL42Bk+petmPIsP9+4IWnG/RGlME6ywvMHkY4JvJfv/6kfnfk9jX2kBf42e FAfx3nvSQHI+dkoSx4YHfvwm+MfHT7lg0eRMp6Y4oKEW5oIFsvK9/DIB37hqck2bQkUpp4IHJdi OkRmQtmJjwj46hDbeZivY2k54MzIKGrrjYDb+jqylMIBEWY1JrJTPdC0Rz/uJ/dD9NzpTWQoSrM BwGguoLBREiGjlH8BaWP3KT8/xZmX5LEG8SqM8mCGUVAx3Rfaj+JnKTIXg0XPR3o6o9HfALtkSj osllmGTHP1dAEu9/YTqv0D4M1Jr9awlYh1iO0y/Dw0o14SpFCDX4FnZ/OZlLb/4iOAbeyXn+Jw= = X-Received: by 2002:a1c:e3d5:: with SMTP id a204-v6mr18766573wmh.20.1534520499140; Fri, 17 Aug 2018 08:41:39 -0700 (PDT) X-Received: by 2002:a1c:e3d5:: with SMTP id a204-v6mr18766495wmh.20.1534520496786; Fri, 17 Aug 2018 08:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534520496; cv=none; d=google.com; s=arc-20160816; b=iGCMpqWfxlFlbPyl0jfM/L7JXVZd/dfPVebHiJjFXsZmKnTML5ZIaNC+W4dNNm+cFQ uBbDcuLUnV4DfaXWTrLu2Q7+ZD4EjHv3xDISdwNJN5AAUfrlBoBmLj/la+Mi5QK80/MI N+WLH0SPTOlCa3A8YrAw0Ff09stYQaYQUgLxjRznxG7BU9VWgLiAWO+iAlQOWz1CtZXL pQZ+7EMbCBNeX5h4l7qaR97EIV77TQYavck3SdmfulpaA0FgUtZ6hidWOigoJJz8+6fn eWebZ4HU8O67qhWN97asSi3czF4NsG64rpNrBy52uzd4NSk19iKTyzozlrdyBfWGhqly wPeg== 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=iZlmTvhU0cDqGXWGlJNX2R9bE+JQXFCjRoVfJ72HKmY=; b=xNF7r6RMM+1AraZjA4mIgWugnbirtHttwTXb+wKaBFC1FixWg8ueq/KgCzvtwq8Jkn ife4TNI1N31HVFeIxwD5/Q8T3biyv931mMgZu36C/eCxWAZGv2TTvlM8VuDWw41uJjtn AIwBWcd5eqIBjoj/LbszJPPu8UeHjPPS5spER3JYNu4VVJJrcOog3uyvvlUxt6+RKSbY DKBTxLjofg9SybCcSoo+dQEENxbBFCCa2nwWvBWRvchuvQ1kN2cI6VICziRSm49tuKct JKGikNPdSC8gEDL92Y6+HSrLsm/99Qb0IZf+cEu4VmvIO7SByt5tyVSTd9RmpUb9TCF1 LbTg== 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 66-v6sor967157wms.91.2018.08.17.08.41.36 for (Google Transport Security); Fri, 17 Aug 2018 08:41:36 -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+uWPwGAzXVAdxl0MbBEa+pyzwcBWyXqLOmn8lUAew8CjlWW+8t/S/FvxzRB5aA/kCLZxBk5afIWg== X-Received: by 2002:a1c:415:: with SMTP id 21-v6mr20265611wme.128.1534520496388; Fri, 17 Aug 2018 08:41:36 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id v124-v6sm6166755wma.18.2018.08.17.08.41.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Aug 2018 08:41:35 -0700 (PDT) Received: from d104.suse.de (nat.nue.novell.com [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 2A53C12494F; Fri, 17 Aug 2018 17:41:34 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, jglisse@redhat.com, david@redhat.com, jonathan.cameron@huawei.com, Pavel.Tatashin@microsoft.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 v2 1/2] mm/memory_hotplug: Add nid parameter to arch_remove_memory Date: Fri, 17 Aug 2018 17:41:26 +0200 Message-Id: <20180817154127.28602-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180817154127.28602-1-osalvador@techadventures.net> References: <20180817154127.28602-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 of passing the nid is that will allow us to get rid of the zone parameter in the patches that follow. 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 3b85c3ecac38..b54d0ee74b53 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -662,7 +662,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 7713c084d040..5c91bb6abc35 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -444,7 +444,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 dd519f372169..f90fa077b0c4 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);