linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Toshi Kani <toshi.kani@hp.com>,
	Wen Congyang <wency@cn.fujitsu.com>,
	Tang Chen <tangchen@cn.fujitsu.com>,
	Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiang Liu <liuj97@gmail.com>,
	Vasilis Liaskovitis <vasilis.liaskovitis@profitbricks.com>,
	linux-mm@kvack.org
Subject: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code
Date: Sun, 19 May 2013 01:34:59 +0200	[thread overview]
Message-ID: <2228904.eTtCrFuSan@vostro.rjw.lan> (raw)
In-Reply-To: <2250271.rGYN6WlBxf@vostro.rjw.lan>

From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Now that the memory offlining should be taken care of by the
companion device offlining code in acpi_scan_hot_remove(), the
ACPI memory hotplug driver doesn't need to offline it in
acpi_memory_remove_memory() any more.  Consequently, it doesn't
need to call remove_memory() any more, which means that that
funtion may be dropped entirely, because acpi_memory_remove_memory()
is the only user of it.

Make the changes described above to get rid of the dead code.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
---
 drivers/acpi/acpi_memhotplug.c |   15 ------
 include/linux/memory_hotplug.h |    1 
 mm/memory_hotplug.c            |  102 -----------------------------------------
 3 files changed, 2 insertions(+), 116 deletions(-)

Index: linux-pm/drivers/acpi/acpi_memhotplug.c
===================================================================
--- linux-pm.orig/drivers/acpi/acpi_memhotplug.c
+++ linux-pm/drivers/acpi/acpi_memhotplug.c
@@ -271,31 +271,20 @@ static int acpi_memory_enable_device(str
 	return 0;
 }
 
-static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
+static void acpi_memory_remove_memory(struct acpi_memory_device *mem_device)
 {
 	acpi_handle handle = mem_device->device->handle;
-	int result = 0, nid;
 	struct acpi_memory_info *info, *n;
 
-	nid = acpi_get_node(handle);
-
 	list_for_each_entry_safe(info, n, &mem_device->res_list, list) {
 		if (!info->enabled)
 			continue;
 
-		if (nid < 0)
-			nid = memory_add_physaddr_to_nid(info->start_addr);
-
+		/* All of the memory blocks are offline at this point. */
 		acpi_unbind_memory_blocks(info, handle);
-		result = remove_memory(nid, info->start_addr, info->length);
-		if (result)
-			return result;
-
 		list_del(&info->list);
 		kfree(info);
 	}
-
-	return result;
 }
 
 static void acpi_memory_device_free(struct acpi_memory_device *mem_device)
Index: linux-pm/include/linux/memory_hotplug.h
===================================================================
--- linux-pm.orig/include/linux/memory_hotplug.h
+++ linux-pm/include/linux/memory_hotplug.h
@@ -252,7 +252,6 @@ extern int add_memory(int nid, u64 start
 extern int arch_add_memory(int nid, u64 start, u64 size);
 extern int offline_pages(unsigned long start_pfn, unsigned long nr_pages);
 extern bool is_memblock_offlined(struct memory_block *mem);
-extern int remove_memory(int nid, u64 start, u64 size);
 extern int sparse_add_one_section(struct zone *zone, unsigned long start_pfn,
 								int nr_pages);
 extern void sparse_remove_one_section(struct zone *zone, struct mem_section *ms);
Index: linux-pm/mm/memory_hotplug.c
===================================================================
--- linux-pm.orig/mm/memory_hotplug.c
+++ linux-pm/mm/memory_hotplug.c
@@ -1670,41 +1670,6 @@ int walk_memory_range(unsigned long star
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE
-/**
- * offline_memory_block_cb - callback function for offlining memory block
- * @mem: the memory block to be offlined
- * @arg: buffer to hold error msg
- *
- * Always return 0, and put the error msg in arg if any.
- */
-static int offline_memory_block_cb(struct memory_block *mem, void *arg)
-{
-	int *ret = arg;
-	int error = device_offline(&mem->dev);
-
-	if (error != 0 && *ret == 0)
-		*ret = error;
-
-	return 0;
-}
-
-static int is_memblock_offlined_cb(struct memory_block *mem, void *arg)
-{
-	int ret = !is_memblock_offlined(mem);
-
-	if (unlikely(ret)) {
-		phys_addr_t beginpa, endpa;
-
-		beginpa = PFN_PHYS(section_nr_to_pfn(mem->start_section_nr));
-		endpa = PFN_PHYS(section_nr_to_pfn(mem->end_section_nr + 1))-1;
-		pr_warn("removing memory fails, because memory "
-			"[%pa-%pa] is onlined\n",
-			&beginpa, &endpa);
-	}
-
-	return ret;
-}
-
 static int check_cpu_on_node(void *data)
 {
 	struct pglist_data *pgdat = data;
@@ -1812,76 +1777,9 @@ void try_offline_node(int nid)
 	memset(pgdat, 0, sizeof(*pgdat));
 }
 EXPORT_SYMBOL(try_offline_node);
-
-int __ref remove_memory(int nid, u64 start, u64 size)
-{
-	unsigned long start_pfn, end_pfn;
-	int ret = 0;
-	int retry = 1;
-
-	start_pfn = PFN_DOWN(start);
-	end_pfn = PFN_UP(start + size - 1);
-
-	/*
-	 * When CONFIG_MEMCG is on, one memory block may be used by other
-	 * blocks to store page cgroup when onlining pages. But we don't know
-	 * in what order pages are onlined. So we iterate twice to offline
-	 * memory:
-	 * 1st iterate: offline every non primary memory block.
-	 * 2nd iterate: offline primary (i.e. first added) memory block.
-	 */
-repeat:
-	walk_memory_range(start_pfn, end_pfn, &ret,
-			  offline_memory_block_cb);
-	if (ret) {
-		if (!retry)
-			return ret;
-
-		retry = 0;
-		ret = 0;
-		goto repeat;
-	}
-
-	lock_memory_hotplug();
-
-	/*
-	 * we have offlined all memory blocks like this:
-	 *   1. lock memory hotplug
-	 *   2. offline a memory block
-	 *   3. unlock memory hotplug
-	 *
-	 * repeat step1-3 to offline the memory block. All memory blocks
-	 * must be offlined before removing memory. But we don't hold the
-	 * lock in the whole operation. So we should check whether all
-	 * memory blocks are offlined.
-	 */
-
-	ret = walk_memory_range(start_pfn, end_pfn, NULL,
-				is_memblock_offlined_cb);
-	if (ret) {
-		unlock_memory_hotplug();
-		return ret;
-	}
-
-	/* remove memmap entry */
-	firmware_map_remove(start, start + size, "System RAM");
-
-	arch_remove_memory(start, size);
-
-	try_offline_node(nid);
-
-	unlock_memory_hotplug();
-
-	return 0;
-}
 #else
 int offline_pages(unsigned long start_pfn, unsigned long nr_pages)
 {
 	return -EINVAL;
 }
-int remove_memory(int nid, u64 start, u64 size)
-{
-	return -EINVAL;
-}
 #endif /* CONFIG_MEMORY_HOTREMOVE */
-EXPORT_SYMBOL_GPL(remove_memory);

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2013-05-18 23:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-18 23:29 [PATCH 0/5] ACPI / scan / memhotplug: ACPI hotplug rework followup changes Rafael J. Wysocki
2013-05-18 23:30 ` [PATCH 1/5] ACPI: Drop removal_type field from struct acpi_device Rafael J. Wysocki
2013-05-18 23:31 ` [PATCH 2/5] ACPI / processor: Pass processor object handle to acpi_bind_one() Rafael J. Wysocki
2013-05-18 23:33 ` [PATCH 3/5] Driver core / MM: Drop offline_memory_block() Rafael J. Wysocki
2013-05-19  1:23   ` Greg Kroah-Hartman
2013-05-18 23:34 ` [PATCH 4/5] ACPI / scan: Add second pass of companion offlining to hot-remove code Rafael J. Wysocki
2013-05-21  7:34   ` Xishi Qiu
2013-05-21 10:59     ` Rafael J. Wysocki
2013-05-18 23:34 ` Rafael J. Wysocki [this message]
2013-05-20 17:27   ` [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code Toshi Kani
2013-05-20 19:47     ` Rafael J. Wysocki
2013-05-20 19:55       ` Toshi Kani
2013-05-20 21:31         ` Toshi Kani
2013-05-22 22:09         ` [PATCH *5/5] Memory hotplug / ACPI: Simplify memory removal (was: Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code) Rafael J. Wysocki
2013-05-23 16:45           ` Toshi Kani

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2228904.eTtCrFuSan@vostro.rjw.lan \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=isimatu.yasuaki@jp.fujitsu.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuj97@gmail.com \
    --cc=tangchen@cn.fujitsu.com \
    --cc=toshi.kani@hp.com \
    --cc=vasilis.liaskovitis@profitbricks.com \
    --cc=wency@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox