From patchwork Mon Oct 15 15:30:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10642051 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 B0618925 for ; Mon, 15 Oct 2018 15:31:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A048529AF4 for ; Mon, 15 Oct 2018 15:31:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 94BA929B16; Mon, 15 Oct 2018 15:31:00 +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 DEA2D29AF4 for ; Mon, 15 Oct 2018 15:30:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B76D6B0006; Mon, 15 Oct 2018 11:30:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 923486B000D; Mon, 15 Oct 2018 11:30:56 -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 7B3356B000C; Mon, 15 Oct 2018 11:30:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by kanga.kvack.org (Postfix) with ESMTP id 1EBB46B0006 for ; Mon, 15 Oct 2018 11:30:56 -0400 (EDT) Received: by mail-wr1-f70.google.com with SMTP id c16-v6so15959968wrr.8 for ; Mon, 15 Oct 2018 08:30:56 -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=M/8yrxlW200FJawa7Woj1EViIDZtaPHRv0p62rhek+A=; b=My+kZRhBXDzaBpDmo05cvfK6JQHB8phPOeNQZZbrMjNHtB8TF+nb57vVNBxBrj4MCw 1+B9w4U2ZSDozkTnr52pwpGGr7qlpPz4X0rF+Oq53qOQmslum6xmJrls6ubzM7l60Akt jcFP0OmI0z5J2Ok0SJMaSFpULMHOEAGMkDGmkF1ug/a0gYvW91Ht8KDGrbG2FCqCzZWJ e4gLm684HdHZwJAIFzpgVTiULhSM10bl8r/BFb0u5jWM7ukjvjIbDqsjbXcip+tKr8Ge CEXbOEIKbf0JxF4vsV0SnhlD5PLv51HExVycUJlcF3ZrgxAxwrwzCrCak3pzHZcsKnyv EdwA== 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: ABuFfohh2gPvHzR6Nbew7RAKKy4LrO7nkeoX29O9QtdXQ1OTMygbo7rF 6HwDPCGCpDDyXajwDVxmxWxvBjC1uS8CI2m8SDTd+mRYAQGJXrHrsN8taKA8FW42iaMj83KTziG /gdr9LPWHQd3snfgaWcUsYJXKT4mV0XNIJza6VoWAasdFzRn7uHJh+dD1JKlZvlhS2nqVlVZDs4 YkgrWeobKY/zvvuH2ccNmTRiJSFKFa/ZtJePdPsDdwGKnyZAWG/ieYNxedrfLJ8n9z8s1aaYM71 r0Jem3F1r7suyaO6d44Ck2o3c1bHzVfmf3RovNUsn9DjWEK8xYfQ0XRLUyAbV1doKoULnlVrqRT jw3TztAbh5oTdIDPN0JzHmjhDIjs9GAgmL7pjhS55zXMsaU3+DMcjLbLYoV8iGYVMx6eE/fafg= = X-Received: by 2002:a1c:4b15:: with SMTP id y21-v6mr13309264wma.122.1539617455598; Mon, 15 Oct 2018 08:30:55 -0700 (PDT) X-Received: by 2002:a1c:4b15:: with SMTP id y21-v6mr13309183wma.122.1539617454033; Mon, 15 Oct 2018 08:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539617454; cv=none; d=google.com; s=arc-20160816; b=DmLZ5X75RLiYVoNEzn0TVtLJ90uQDNtGLgn2WxRrCWVcCFuv0pC3ZlBkAJGqa66SJi Lxz8qJNlozLk84ZxEgXkmhWSOPCcMwlLYjA/BdkML/GGAe+AUNgS3BUEPY2S5A4XzHB3 Zj+1exiv/JLqTsjUADjts9eN1Aon4wIdb0zjR9hWSltAuxNe5baVNJ223hpUmvmsVNo1 1IqVkdcFQ/nA3qHvXK/Urt9RGN5nPVbKx8ak3y9r7k6Hw9VHDv9/VACBjkpW3GVMaQWg BLmYgjLLLjmRMwYEd1kDmCzQBCZ0wASJTd7zMl1Zonl9Psi5XLh7FpNbxsZSKKYyDft2 6YFA== 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; bh=M/8yrxlW200FJawa7Woj1EViIDZtaPHRv0p62rhek+A=; b=teX33KRPrlLL5/WSTeD6xaSdEQCEPHgLPzPn0cST+f2QIL7ZFP5dmmRMkt63a5YMrw G/ZWy441FMU/rf2XF/A8EUHVlhbCGz4qHUtVpfMTqxYmpSlbcv4/cplOm3HAOSdheZ4b l6iBvhb44UMnuHd7l6/AmKyhMyKX/8DLPRR3pDmNS9PITjpDBL0FWwDcStsFCzUOGo2g z301YUURjNWGMJFDsPUVRn/4Nn9ukxINH3uPygMSjtkcYjFqZ51NMvS+41qTRSmoveNB ySkqFypyHuJqKMC/xYpB0gtXXHETs0HFSX+vFaixuINEasw5MgItuqPUaPIjGwVUkVaL guJg== 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 g4-v6sor6191617wru.17.2018.10.15.08.30.53 for (Google Transport Security); Mon, 15 Oct 2018 08:30:54 -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: ACcGV61Sm2BdNFDcCsz9hkSq0WPBtQuZFEC6+homGWRGv1XYJryBQrZu8b6IVh+k03STncx/NJ4Vow== X-Received: by 2002:a05:6000:11c1:: with SMTP id i1mr15300270wrx.310.1539617453584; Mon, 15 Oct 2018 08:30:53 -0700 (PDT) Received: from techadventures.net (techadventures.net. [62.201.165.239]) by smtp.gmail.com with ESMTPSA id e133-v6sm11353053wma.42.2018.10.15.08.30.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 08:30:52 -0700 (PDT) Received: from d104.suse.de (charybdis-ext.suse.de [195.135.221.2]) by techadventures.net (Postfix) with ESMTPA id 88CEF1259A6; Mon, 15 Oct 2018 17:30:51 +0200 (CEST) From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, yasu.isimatu@gmail.com, rppt@linux.vnet.ibm.com, malat@debian.org, linux-kernel@vger.kernel.org, pavel.tatashin@microsoft.com, jglisse@redhat.com, Jonathan.Cameron@huawei.com, rafael@kernel.org, david@redhat.com, dave.jiang@intel.com, linux-mm@kvack.org, alexander.h.duyck@linux.intel.com, Oscar Salvador Subject: [PATCH 1/5] mm/memory_hotplug: Add nid parameter to arch_remove_memory Date: Mon, 15 Oct 2018 17:30:30 +0200 Message-Id: <20181015153034.32203-2-osalvador@techadventures.net> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181015153034.32203-1-osalvador@techadventures.net> References: <20181015153034.32203-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 Reviewed-by: David Hildenbrand Reviewed-by: Pavel Tatashin --- arch/ia64/mm/init.c | 2 +- arch/powerpc/mm/mem.c | 3 ++- 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 | 3 ++- include/linux/memory_hotplug.h | 2 +- kernel/memremap.c | 4 +++- mm/hmm.c | 4 +++- mm/memory_hotplug.c | 2 +- 10 files changed, 16 insertions(+), 10 deletions(-) diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c index d5e12ff1d73c..904fe55e10fc 100644 --- a/arch/ia64/mm/init.c +++ b/arch/ia64/mm/init.c @@ -661,7 +661,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 5551f5870dcc..6db8f527babb 100644 --- a/arch/powerpc/mm/mem.c +++ b/arch/powerpc/mm/mem.c @@ -139,7 +139,8 @@ 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 76d0708438e9..b7503f8b7725 100644 --- a/arch/s390/mm/init.c +++ b/arch/s390/mm/init.c @@ -242,7 +242,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 c8c13c777162..a8e5c0e00fca 100644 --- a/arch/sh/mm/init.c +++ b/arch/sh/mm/init.c @@ -443,7 +443,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 49ecf5ecf6d3..85c94f9a87f8 100644 --- a/arch/x86/mm/init_32.c +++ b/arch/x86/mm/init_32.c @@ -860,7 +860,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 5fab264948c2..449958da97a4 100644 --- a/arch/x86/mm/init_64.c +++ b/arch/x86/mm/init_64.c @@ -1147,7 +1147,8 @@ 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 84e9ae205930..786cdfc9a974 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 9eced2cc9f94..c95df6ed2d4a 100644 --- a/kernel/memremap.c +++ b/kernel/memremap.c @@ -87,6 +87,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)); @@ -100,9 +101,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 774d684fa2b4..42d79bcc8aab 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 dbbb94547ad0..33d448314b3f 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1875,7 +1875,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);