Received: by 10.223.164.202 with SMTP id h10csp3747274wrb; Tue, 28 Nov 2017 16:50:56 -0800 (PST) X-Google-Smtp-Source: AGs4zMYQeg90y7KZOv8S9CR7jZMhOWRfNWleazSl2ZWg1iHrxca/wGUJuXqFDHlzYWaxqgtwjb3T X-Received: by 10.84.168.132 with SMTP id f4mr1086889plb.234.1511916655958; Tue, 28 Nov 2017 16:50:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511916655; cv=none; d=google.com; s=arc-20160816; b=FrbuOPxmkUCxLS3U8takwx6hI89Pl8iZo2/pL0tHlyhaWLA64VMoX8/jVG2HCSjDC4 t+QkF7yVdw0ZuNn0l65Fn4gU5IMEopdhti2ehZk6bdCAKLcTAM1H/CT6CAZVSaRzXFBV /1oXA7zYnoAm1o1dwr7a9fu7eI7UjK6nsfwvZq1uhsGuOaBc01s9Dm4IKuoYrP2Ukmhu WP1T/8pKJaLHU6DCyLxwVjz07KsfepGWwKtjSb7cYoCUdB3/7MxhewFp4DXH78f3oEBZ 4N7vrJLr6S8yW+wkOjHBsyMOuVLkAldRLzlGVX/tyM6BPRDjsDMq77ztUeRqu5ZJ6Ret IaKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=G2yEfhYcML/+iQ9jbLyosAgSmhwup4BeWHIlxfTzgqM=; b=cqRNPh2cnYKg34YY9jboeZbU1Z2bxlgaNuJogMyKxcDTEaOBG78zCp/+PF7NEjHMeT GXo/nrqiiK1j+c2FKl9gCBZUpbOQep3wfFsaJ0YSUgrBnd6vVvUtsGqvcKq91z5wf8om lUxZt4t1FL4vvXfe7sdI1PZhDyav+1isXYwCeWzrDHOJF8tnpXvCtIbCYnBsJ+i5kMze euHSqrmOsviAMAu4zcltPvs6aDojjCqfLWiLNzAIJfWK9osnBq2rbo2Ycqb5TMio/zD4 MsyR1eRt7xFVL8IHP4y1+GwygWyeZA4vpS1H9y4yn8Uqcw7FFzgxQ5orp+3BwRdn6V4Q sXkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si346959plb.2.2017.11.28.16.50.44; Tue, 28 Nov 2017 16:50:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752554AbdK2AuA (ORCPT + 70 others); Tue, 28 Nov 2017 19:50:00 -0500 Received: from smtp.nue.novell.com ([195.135.221.5]:33066 "EHLO smtp.nue.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751833AbdK2At7 (ORCPT ); Tue, 28 Nov 2017 19:49:59 -0500 Received: from linux-l9pv.suse (124-11-22-254.static.tfn.net.tw [124.11.22.254]) by smtp.nue.novell.com with ESMTP (TLS encrypted); Wed, 29 Nov 2017 01:49:47 +0100 Date: Wed, 29 Nov 2017 08:49:13 +0800 From: joeyli To: Andrea Reale Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, m.bielski@virtualopensystems.com, arunks@qti.qualcomm.com, mark.rutland@arm.com, scott.branden@broadcom.com, will.deacon@arm.com, qiuxishi@huawei.com, catalin.marinas@arm.com, mhocko@suse.com, rafael.j.wysocki@intel.com, linux-acpi@vger.kernel.org Subject: Re: [PATCH v2 2/5] mm: memory_hotplug: Remove assumption on memory state before hotremove Message-ID: <20171129004913.GB1469@linux-l9pv.suse> References: <4e21a27570f665793debf167c8567c6752116d0a.1511433386.git.ar@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4e21a27570f665793debf167c8567c6752116d0a.1511433386.git.ar@linux.vnet.ibm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrea, On Fri, Nov 24, 2017 at 10:22:35AM +0000, Andrea Reale wrote: > Resending the patch adding linux-acpi in CC, as suggested by Rafael. > Everyone else: apologies for the noise. > > Commit 242831eb15a0 ("Memory hotplug / ACPI: Simplify memory removal") > introduced an assumption whereas when control > reaches remove_memory the corresponding memory has been already > offlined. In that case, the acpi_memhotplug was making sure that > the assumption held. > This assumption, however, is not necessarily true if offlining > and removal are not done by the same "controller" (for example, > when first offlining via sysfs). > > Removing this assumption for the generic remove_memory code > and moving it in the specific acpi_memhotplug code. This is > a dependency for the software-aided arm64 offlining and removal > process. > > Signed-off-by: Andrea Reale > Signed-off-by: Maciej Bielski > --- > drivers/acpi/acpi_memhotplug.c | 2 +- > include/linux/memory_hotplug.h | 9 ++++++--- > mm/memory_hotplug.c | 13 +++++++++---- > 3 files changed, 16 insertions(+), 8 deletions(-) > > diff --git a/drivers/acpi/acpi_memhotplug.c b/drivers/acpi/acpi_memhotplug.c > index 6b0d3ef..b0126a0 100644 > --- a/drivers/acpi/acpi_memhotplug.c > +++ b/drivers/acpi/acpi_memhotplug.c > @@ -282,7 +282,7 @@ static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device) > nid = memory_add_physaddr_to_nid(info->start_addr); > > acpi_unbind_memory_blocks(info); > - remove_memory(nid, info->start_addr, info->length); > + BUG_ON(remove_memory(nid, info->start_addr, info->length)); > list_del(&info->list); > kfree(info); > } > diff --git a/include/linux/memory_hotplug.h b/include/linux/memory_hotplug.h > index 58e110a..1a9c7b2 100644 > --- a/include/linux/memory_hotplug.h > +++ b/include/linux/memory_hotplug.h > @@ -295,7 +295,7 @@ static inline bool movable_node_is_enabled(void) > extern bool is_mem_section_removable(unsigned long pfn, unsigned long nr_pages); > extern void try_offline_node(int nid); > extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); > -extern void remove_memory(int nid, u64 start, u64 size); > +extern int remove_memory(int nid, u64 start, u64 size); > > #else > static inline bool is_mem_section_removable(unsigned long pfn, > @@ -311,7 +311,10 @@ static inline int offline_pages(unsigned long start_pfn, unsigned long nr_pages) > return -EINVAL; > } > > -static inline void remove_memory(int nid, u64 start, u64 size) {} > +static inline int remove_memory(int nid, u64 start, u64 size) > +{ > + return -EINVAL; > +} > #endif /* CONFIG_MEMORY_HOTREMOVE */ > > extern int walk_memory_range(unsigned long start_pfn, unsigned long end_pfn, > @@ -323,7 +326,7 @@ extern void move_pfn_range_to_zone(struct zone *zone, unsigned long start_pfn, > unsigned long nr_pages); > extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages); > extern bool is_memblock_offlined(struct memory_block *mem); > -extern void remove_memory(int nid, u64 start, u64 size); > +extern int remove_memory(int nid, u64 start, u64 size); > extern int sparse_add_one_section(struct pglist_data *pgdat, unsigned long start_pfn); > extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms, > unsigned long map_offset); > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index d4b5f29..d5f15af 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -1892,7 +1892,7 @@ EXPORT_SYMBOL(try_offline_node); > * and online/offline operations before this call, as required by > * try_offline_node(). > */ > -void __ref remove_memory(int nid, u64 start, u64 size) > +int __ref remove_memory(int nid, u64 start, u64 size) > { > int ret; > > @@ -1908,18 +1908,23 @@ void __ref remove_memory(int nid, u64 start, u64 size) > ret = walk_memory_range(PFN_DOWN(start), PFN_UP(start + size - 1), NULL, > check_memblock_offlined_cb); > if (ret) > - BUG(); > + goto end_remove; > + > + ret = arch_remove_memory(start, size); > + > + if (ret) > + goto end_remove; The original code triggers BUG() when any memblock is not offlined. Why the new logic includes the result of arch_remove_memory()? But I agreed the we don't need BUG(). Returning a error is better. > > /* remove memmap entry */ > firmware_map_remove(start, start + size, "System RAM"); > memblock_free(start, size); > memblock_remove(start, size); > > - arch_remove_memory(start, size); > - > try_offline_node(nid); > > +end_remove: > mem_hotplug_done(); > + return ret; > } > EXPORT_SYMBOL_GPL(remove_memory); > #endif /* CONFIG_MEMORY_HOTREMOVE */ > -- > 2.7.4 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html From 1585242329280123354@xxx Mon Nov 27 17:48:14 +0000 2017 X-GM-THRID: 1584855244310557114 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread