From patchwork Tue Nov 27 16:20:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oscar Salvador X-Patchwork-Id: 10700785 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 42955109C for ; Tue, 27 Nov 2018 16:20:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F9CF2C03C for ; Tue, 27 Nov 2018 16:20:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 233AA2C067; Tue, 27 Nov 2018 16:20:42 +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 752322C03C for ; Tue, 27 Nov 2018 16:20:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3112E6B48EE; Tue, 27 Nov 2018 11:20:39 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2964B6B48F0; Tue, 27 Nov 2018 11:20:39 -0500 (EST) 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 09B596B48F2; Tue, 27 Nov 2018 11:20:39 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id B28746B48EE for ; Tue, 27 Nov 2018 11:20:38 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id 75so12143345pfq.8 for ; Tue, 27 Nov 2018 08:20:38 -0800 (PST) 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=oiSRiDFO9E9QSI3x3EnPeiknaRm/sCPAKjOFlESNoe0=; b=iGq9OEQJjtDyNTMEsUQQFk8S7MtmbYOVPpB2JPnUDHh3UWNhiucI30Hbk3z/XA5zXt ffMvxBMp6rSmX1RtV5ghyvrKPBD+JS/iw5HGCAvYjIc7zyOt6Mhvufjv+1F+naHxSq/5 9658vUuwJ+3x/vZ2JqceXTHRWfKIwD4Q3djL2v1xFCjb44UxerZSuPciWRCGSXc/VvRu KWUQTf+jPo08wEFOlGN5jrILbbvIrPNsIP9pKtG996g/70fjRAzCdgMVvG+SGTs5Ngju 18krtQ0iUSg3HXYzUUr9JVJPhToaf8/kJSaeI0wxhz6HCYgcnlphk6cWmWOX8+UKaRf6 MfyA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de X-Gm-Message-State: AA+aEWYat3MRRhXWywTTKB0hLAk+DWlVhIn2+uVsQ6OEmjbub71sT5eu 8e7X79vKoZoXkprHNb9DMkjAFhwdSLJZ3AOuZmLVmAZS8ZBNvngbFHZWeyvrWm4a/hWS/odxFuA oEOahO92HDmB/MxqrH4TqIojC5/6lwiiAnZL6Gd1G1qN8CUhbmueUlA5pQ8iTD16dyw== X-Received: by 2002:a65:40c5:: with SMTP id u5mr28852664pgp.46.1543335637852; Tue, 27 Nov 2018 08:20:37 -0800 (PST) X-Google-Smtp-Source: AFSGD/UZ4svdVppLcxC+ITtdpE7mpWtqdPcvrEjcmL55iU2wIyZ9bquLrFpGDbKzx0+BSTaZN9KH X-Received: by 2002:a65:40c5:: with SMTP id u5mr28852619pgp.46.1543335636824; Tue, 27 Nov 2018 08:20:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543335636; cv=none; d=google.com; s=arc-20160816; b=h41vD7w1Qn8d8hAJ/mjExzoxl4igr5ncqKlMUz2TbQU9JmfS+bmevOITfpfqer1Rr0 8YfIMqcrgjHWyi2/Cxtfu/wgcBvbxiMFMMqXdd+5a4pAu4xvWe8m566F/fU72wGcQvUg mJaqtPUIbsan6hsaEOC89SML5sdGcyeEWs5I8yIdTFqj0Ea5Y/FLS49+cOAxpIG5bZ7F gq0nWkU6oqNH53f7UugrfJDAWZ1Lb1bc1wzmcjVnIb+D+bLw8M1urjZvns37WWD3+TcH l4CUbWHfl/i0Rp0QImV64fj3AbZbBJaBsBWxdPJHJ52+1jnhaE+UT3r/ZNtERyauQPHA HBwg== 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=oiSRiDFO9E9QSI3x3EnPeiknaRm/sCPAKjOFlESNoe0=; b=RTTDL51eEgAsBb/eIoG9JI8pSstS3fNsIkDQGjjq/7zQsU8+lTUZtUcBO5LgiNc94u YUgXu+avo4f2wr69Lrd9ll7zc0TvptSE793e886UW4g2w9WkAL5muKnANi+PATEBpiiv sLSXe2TF/7jyxypuhXG8KgJs1BRppRjM3KPxxQcdFo9O9Fw98c5q3+CmG22Jh7cVKCP9 1eE8tDoiEINB+TiwCuiQG+QvRsbcsfvjnYg4FYkp5Cx++9bJ9ZX/V5Moci24F3VEBdKq 644sQqEs56EzqM2LHVdpeBcA9FkaYn4dtjJChsCmZDj5+PvlZyYmENipPrgM0SWGT8Jo k9YA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de Received: from smtp.nue.novell.com (smtp.nue.novell.com. [195.135.221.5]) by mx.google.com with ESMTPS id c15si3960584pgg.446.2018.11.27.08.20.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 08:20:36 -0800 (PST) Received-SPF: pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) client-ip=195.135.221.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of osalvador@suse.de designates 195.135.221.5 as permitted sender) smtp.mailfrom=osalvador@suse.de Received: from emea4-mta.ukb.novell.com ([10.120.13.87]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Tue, 27 Nov 2018 17:20:34 +0100 Received: from d104.suse.de (nwb-a10-snat.microfocus.com [10.120.13.201]) by emea4-mta.ukb.novell.com with ESMTP (NOT encrypted); Tue, 27 Nov 2018 16:20:13 +0000 From: Oscar Salvador To: akpm@linux-foundation.org Cc: mhocko@suse.com, dan.j.williams@intel.com, pavel.tatashin@microsoft.com, jglisse@redhat.com, Jonathan.Cameron@huawei.com, rafael@kernel.org, david@redhat.com, linux-mm@kvack.org, Oscar Salvador , Oscar Salvador Subject: [PATCH v2 1/5] mm, memory_hotplug: Add nid parameter to arch_remove_memory Date: Tue, 27 Nov 2018 17:20:01 +0100 Message-Id: <20181127162005.15833-2-osalvador@suse.de> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181127162005.15833-1-osalvador@suse.de> References: <20181127162005.15833-1-osalvador@suse.de> 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 it will allow us to get rid of the zone parameter afterwards. 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 | 4 ++-- kernel/memremap.c | 5 ++++- mm/memory_hotplug.c | 2 +- 9 files changed, 15 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 0a64fffabee1..40feb262080e 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 50388190b393..3e82f66d5c61 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..3aedcd7929cd 100644 --- a/include/linux/memory_hotplug.h +++ b/include/linux/memory_hotplug.h @@ -107,8 +107,8 @@ static inline bool movable_node_is_enabled(void) } #ifdef CONFIG_MEMORY_HOTREMOVE -extern int arch_remove_memory(u64 start, u64 size, - struct vmem_altmap *altmap); +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); #endif /* CONFIG_MEMORY_HOTREMOVE */ diff --git a/kernel/memremap.c b/kernel/memremap.c index 3eef989ef035..0d5603d76c37 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; pgmap->kill(pgmap->ref); for_each_device_pfn(pfn, pgmap) @@ -97,13 +98,15 @@ static void devm_memremap_pages_release(void *data) align_size = ALIGN(res->start + resource_size(res), SECTION_SIZE) - align_start; + nid = page_to_nid(pfn_to_page(align_start >> PAGE_SHIFT)); + mem_hotplug_begin(); if (pgmap->type == MEMORY_DEVICE_PRIVATE) { pfn = align_start >> PAGE_SHIFT; __remove_pages(page_zone(pfn_to_page(pfn)), pfn, align_size >> PAGE_SHIFT, NULL); } else { - arch_remove_memory(align_start, align_size, + arch_remove_memory(nid, align_start, align_size, pgmap->altmap_valid ? &pgmap->altmap : NULL); kasan_remove_zero_shadow(__va(align_start), align_size); } diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c index 7b4317ae8318..849bcc55c5f1 100644 --- a/mm/memory_hotplug.c +++ b/mm/memory_hotplug.c @@ -1858,7 +1858,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);