ACPI / scan / memhotplug: ACPI hotplug rework followup changes
Subsystems (5)
cover ACPI / scan / memhotplug: ACPI hotplug rework followup changes
Hi,
This series contains changes that are possible on top of the linux-pm.git tree's acpi-hotplug branch. They touch ACPI, driver core and the core memory hotplug code and the majority of them are about removing code that's not necessary any more.
Please review and let me know if there's anything wrong with any of them.
[1/5] Drop the struct acpi_device's removal_type field that's not used any more. [2/5] Pass processor object handle to acpi_bind_one()
[3/5] Replace offline_memory_block() with device_offline().
[4/5] Add second pass of companion offlining to acpi_scan_hot_remove(). [5/5] Drop ACPI memory hotplug code that's not necessary any more.
Thanks,
Rafael
Signature · 8 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/5 ACPI: Drop removal_type field from struct acpi_device
From: Rafael J. Wysocki <[email protected]>
The ACPI processor driver was the only user of the removal_type field in struct acpi_device, but it doesn't use that field any more after recent changes. Thus, removal_type has no more users, so drop it along with the associated data type.
--- drivers/acpi/scan.c | 2 -- include/acpi/acpi_bus.h | 8 -------- 2 files changed, 10 deletions(-)
include/acpi/acpi_bus.h +0 -8
@@ -63,13 +63,6 @@ acpi_get_physical_device_location(acpi_h#define ACPI_BUS_FILE_ROOT "acpi"extern struct proc_dir_entry *acpi_root_dir; -enum acpi_bus_removal_type { -ACPI_BUS_REMOVAL_NORMAL =0 , -ACPI_BUS_REMOVAL_EJECT , -ACPI_BUS_REMOVAL_SUPRISE , -ACPI_BUS_REMOVAL_TYPE_COUNT -}; -enum acpi_bus_device_type {ACPI_BUS_TYPE_DEVICE =0 ,ACPI_BUS_TYPE_POWER ,
@@ -311,7 +304,6 @@ struct acpi_device {struct acpi_driver *driver;void *driver_data;struct device dev; -enum acpi_bus_removal_type removal_type;/* indicate for different removal type */ u8 physical_node_count;struct list_head physical_node_list;struct mutex physical_node_lock;
drivers/acpi/scan.c +0 -2
@@ -1036,7 +1036,6 @@ int acpi_device_add(struct acpi_device * printk(KERN_ERR PREFIX "Error creating sysfs interface for device %s\n", dev_name(&device->dev)); - device->removal_type =ACPI_BUS_REMOVAL_NORMAL ;return 0 ; err:
@@ -2026,7 +2025,6 @@ static acpi_status acpi_bus_device_detacif (!acpi_bus_get_device (handle, &device)) {struct acpi_scan_handler *dev_handler = device->handler; - device->removal_type =ACPI_BUS_REMOVAL_EJECT ;if (dev_handler) {if (dev_handler->detach) dev_handler->detach (device);
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 2/5 ACPI / processor: Pass processor object handle to acpi_bind_one()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Make acpi_processor_add() pass the ACPI handle of the processor namespace object to acpi_bind_one() instead of setting it directly to allow acpi_bind_one() to catch possible bugs causing the ACPI handle of the processor device to be set earlier.
--- drivers/acpi/acpi_processor.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/acpi/acpi_processor.c +1 -2
@@ -389,8 +389,7 @@ static int __cpuinit acpi_processor_add(per_cpu (processor_device_array, pr->id) = device; dev =get_cpu_device (pr->id); -ACPI_HANDLE_SET (dev, pr->handle); - result =acpi_bind_one (dev,NULL ); + result =acpi_bind_one (dev, pr->handle);if (result) goto err;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 3/5 Driver core / MM: Drop offline_memory_block()
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
Since offline_memory_block(mem) is functionally equivalent to device_offline(&mem->dev), make the only caller of the former use the latter instead and drop offline_memory_block() entirely.
--- drivers/base/memory.c | 21 --------------------- include/linux/memory_hotplug.h | 1 - mm/memory_hotplug.c | 2 +- 3 files changed, 1 insertion(+), 23 deletions(-)
drivers/base/memory.c +0 -21
@@ -735,27 +735,6 @@ int unregister_memory_section(struct mem }#endif /* CONFIG_MEMORY_HOTREMOVE */ -/* -* offline one memory block. If the memory block has been offlined, do nothing. -* -* Call under device_hotplug_lock. -*/ -int offline_memory_block (struct memory_block *mem) -{ -int ret =0 ; - -mutex_lock (&mem->state_mutex); -if (mem->state !=MEM_OFFLINE ) { - ret =__memory_block_change_state_uevent (mem,MEM_OFFLINE , -MEM_ONLINE ,-1 ); -if (!ret) - mem->dev.offline = true; - } -mutex_unlock (&mem->state_mutex); - -return ret; -} -/* return true if the memory block is offlined, otherwise, return false */ bool is_memblock_offlined (struct memory_block *mem) {
include/linux/memory_hotplug.h +0 -1
@@ -251,7 +251,6 @@ extern int mem_online_node(int nid);extern int add_memory (int nid,u64 start,u64 size);extern int arch_add_memory (int nid,u64 start,u64 size);extern int offline_pages (unsigned long start_pfn,unsigned long nr_pages); -extern int offline_memory_block (struct memory_block *mem);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,
mm/memory_hotplug.c +1 -1
@@ -1680,7 +1680,7 @@ int walk_memory_range(unsigned long starstatic int offline_memory_block_cb (struct memory_block *mem,void *arg) {int *ret = arg; -int error =offline_memory_block (mem); +int error =device_offline (&mem->dev);if (error !=0 && *ret ==0 ) *ret = error;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 3/5] Driver core / MM: Drop offline_memory_block()
Quoted 7 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
Since
offline_memory_block(mem)is functionally equivalent todevice_offline(&mem->dev), make the only caller of the former use the latter instead and dropoffline_memory_block()entirely.Signed-off-by Rafael J. Wysocki <[email protected]>
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 4/5 ACPI / scan: Add second pass of companion offlining to hot-remove code
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
As indicated by comments in mm/memory_hotplug.c:remove_memory(), if CONFIG_MEMCG is set, it may not be possible to offline all of the memory blocks held by one module (FRU) in one pass (because one of them may be used by the others to store page cgroup in that case and that block has to be offlined before the other ones).
To handle that arguably corner case, add a second pass of companion device offlining to acpi_scan_hot_remove() and make it ignore errors returned in the first pass (and make it skip the second pass if the first one is successful).
--- drivers/acpi/scan.c | 67 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 17 deletions(-)
drivers/acpi/scan.c +50 -17
@@ -131,6 +131,7 @@ static acpi_status acpi_bus_offline_comp {struct acpi_device *device =NULL ;struct acpi_device_physical_node *pn; +bool second_pass = (bool )data;acpi_status status =AE_OK ;if (acpi_bus_get_device (handle, &device))
@@ -141,15 +142,26 @@ static acpi_status acpi_bus_offline_complist_for_each_entry (pn, &device->physical_node_list, node) {int ret; +if (second_pass) { +/* Skip devices offlined by the first pass. */ +if (pn->put_online) +continue ; + }else { + pn->put_online = false; + } ret =device_offline (pn->dev);if (acpi_force_hot_remove)continue ; -if (ret <0 ) { - status =AE_ERROR ; -break ; +if (ret >=0 ) { + pn->put_online = !ret; + }else { + *ret_p = pn->dev; +if (second_pass) { + status =AE_ERROR ; +break ; + } } - pn->put_online = !ret; }mutex_unlock (&device->physical_node_lock);
@@ -185,6 +197,7 @@ static int acpi_scan_hot_remove(struct aacpi_handle not_used;struct acpi_object_list arg_list;union acpi_object arg; +struct device *errdev;acpi_status status;unsigned long long sta;
@@ -197,22 +210,42 @@ static int acpi_scan_hot_remove(struct alock_device_hotplug (); - status =acpi_walk_namespace (ACPI_TYPE_ANY , handle,ACPI_UINT32_MAX , -NULL , acpi_bus_offline_companions,NULL , -NULL ); -if (ACPI_SUCCESS (status) || acpi_force_hot_remove) - status =acpi_bus_offline_companions (handle,0 ,NULL ,NULL ); - -if (ACPI_FAILURE (status) && !acpi_force_hot_remove) { -acpi_bus_online_companions (handle,0 ,NULL ,NULL ); +/* +* Carry out two passes here and ignore errors in the first pass, +* because if the devices in question are memory blocks and +* CONFIG_MEMCG is set, one of the blocks may hold data structures +* that the other blocks depend on, but it is not known in advance which +* block holds them. +* +* If the first pass is successful, the second one isn't needed, though. +*/ + errdev =NULL ; +acpi_walk_namespace (ACPI_TYPE_ANY , handle,ACPI_UINT32_MAX , +NULL , acpi_bus_offline_companions, + (void *)false, (void **)&errdev); +acpi_bus_offline_companions (handle,0 , (void *)false, (void **)&errdev); +if (errdev) { + errdev =NULL ;acpi_walk_namespace (ACPI_TYPE_ANY , handle,ACPI_UINT32_MAX , - acpi_bus_online_companions,NULL ,NULL , -NULL ); +NULL , acpi_bus_offline_companions, + (void *)true , (void **)&errdev); +if (!errdev || acpi_force_hot_remove) +acpi_bus_offline_companions (handle,0 , (void *)true, + (void **)&errdev); + +if (errdev && !acpi_force_hot_remove) { +dev_warn (errdev,"Offline failed.\n" ); +acpi_bus_online_companions (handle,0 ,NULL ,NULL ); +acpi_walk_namespace (ACPI_TYPE_ANY , handle, +ACPI_UINT32_MAX , + acpi_bus_online_companions,NULL , +NULL ,NULL ); -unlock_device_hotplug (); +unlock_device_hotplug (); -put_device (&device->dev); -return -EBUSY ; +put_device (&device->dev); +return -EBUSY ; + } } ACPI_DEBUG_PRINT((ACPI_DB_INFO,
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 4/5] ACPI / scan: Add second pass of companion offlining to hot-remove code
Quoted 31 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
As indicated by comments in mm/memory_hotplug.c:remove_memory(), if
CONFIG_MEMCGis set, it may not be possible to offline all of the memory blocks held by one module (FRU) in one pass (because one of them may be used by the others to store page cgroup in that case and that block has to be offlined before the other ones).To handle that arguably corner case, add a second pass of companion device offlining to
acpi_scan_hot_remove()and make it ignore errors returned in the first pass (and make it skip the second pass if the first one is successful).Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/scan.c | 67 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 17 deletions(-)Index:
linux-pm/drivers/acpi/scan.c
===================================================================drivers/acpi/scan.c +1
-0@@ -131,6 +131,7 @@ static acpi_status acpi_bus_offline_comp {struct acpi_device *device =NULL ;struct acpi_device_physical_node *pn; +bool second_pass = (bool )data;acpi_status status =AE_OK ;if (acpi_bus_get_device (handle, &device))
drivers/acpi/scan.c static acpi_status acpi_bus_offline_comp · line 147
Quoted 6 lines
drivers/acpi/scan.c +3
-0@@ -141,15 +142,26 @@ static acpi_status acpi_bus_offline_complist_for_each_entry (pn, &device->physical_node_list, node) {int ret; +if (second_pass) { +/* Skip devices offlined by the first pass. */ +if (pn->put_online)
should it be "if (!pn->put_online)" ?
Thanks
Xishi Qiu
Quoted 24 lines
drivers/acpi/scan.c +12
-4+continue ; + }else { + pn->put_online = false; + } ret =device_offline (pn->dev);if (acpi_force_hot_remove)continue ; -if (ret <0 ) { - status =AE_ERROR ; -break ; +if (ret >=0 ) { + pn->put_online = !ret; + }else { + *ret_p = pn->dev; +if (second_pass) { + status =AE_ERROR ; +break ; + } } - pn->put_online = !ret; }mutex_unlock (&device->physical_node_lock);
Re: [PATCH 4/5] ACPI / scan: Add second pass of companion offlining to hot-remove code
Quoted 36 lines · Xishi Qiu
Quoted 34 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
As indicated by comments in mm/memory_hotplug.c:remove_memory(), if
CONFIG_MEMCGis set, it may not be possible to offline all of the memory blocks held by one module (FRU) in one pass (because one of them may be used by the others to store page cgroup in that case and that block has to be offlined before the other ones).To handle that arguably corner case, add a second pass of companion device offlining to
acpi_scan_hot_remove()and make it ignore errors returned in the first pass (and make it skip the second pass if the first one is successful).Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/scan.c | 67 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 50 insertions(+), 17 deletions(-)Index:
linux-pm/drivers/acpi/scan.c
===================================================================drivers/acpi/scan.c +1
-0@@ -131,6 +131,7 @@ static acpi_status acpi_bus_offline_comp {struct acpi_device *device =NULL ;struct acpi_device_physical_node *pn; +bool second_pass = (bool )data;acpi_status status =AE_OK ;if (acpi_bus_get_device (handle, &device))@@ -141,15 +142,26 @@ static acpi_status acpi_bus_offline_complist_for_each_entry (pn, &device->physical_node_list, node) {int ret;
Quoted 5 lines
drivers/acpi/scan.c static acpi_status acpi_bus_offline_comp · line 147
Quoted 3 lines
drivers/acpi/scan.c +3
-0+if (second_pass) { +/* Skip devices offlined by the first pass. */ +if (pn->put_online)should it be "if (!pn->put_online)" ?
No, I don't think so.
pn->put_online set means that the device has been offlined by the first pass, so we don't need to try it in the second one.
Thanks,
Rafael
Quoted 27 lines
Quoted 24 lines
drivers/acpi/scan.c +12
-4+continue ; + }else { + pn->put_online = false; + } ret =device_offline (pn->dev);if (acpi_force_hot_remove)continue ; -if (ret <0 ) { - status =AE_ERROR ; -break ; +if (ret >=0 ) { + pn->put_online = !ret; + }else { + *ret_p = pn->dev; +if (second_pass) { + status =AE_ERROR ; +break ; + } } - pn->put_online = !ret; }mutex_unlock (&device->physical_node_lock);
Signature · 8 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 5/5 ACPI / memhotplug: Drop unnecessary code
In reply to Rafael J. WysockiFrom: Rafael J. Wysocki <[email protected]>
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.
--- drivers/acpi/acpi_memhotplug.c | 15 ------ include/linux/memory_hotplug.h | 1 mm/memory_hotplug.c | 102 ----------------------------------------- 3 files changed, 2 insertions(+), 116 deletions(-)
drivers/acpi/acpi_memhotplug.c +2 -13
@@ -271,31 +271,20 @@ static int acpi_memory_enable_device(strreturn 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)
include/linux/memory_hotplug.h +0 -1
@@ -252,7 +252,6 @@ extern int add_memory(int nid, u64 startextern 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);
mm/memory_hotplug.c +0 -102
117 lines not on this page · raw message
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
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 inacpi_memory_remove_memory()any more. Consequently, it doesn't need to callremove_memory()any more, which means that that funtion may be dropped entirely, becauseacpi_memory_remove_memory()is the only user of it.
The off-lining part of remove_memory() can be removed, but not the hot-delete part. Please see my comments below.
Quoted 26 lines
Make the changes described above to get rid of the dead code.
Signed-off-by Rafael J. Wysocki <[email protected]>--- 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
===================================================================drivers/acpi/acpi_memhotplug.c +1
-4@@ -271,31 +271,20 @@ static int acpi_memory_enable_device(strreturn 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); -
drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(str · line 290
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +1
-4list_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);
We still need to call remove_memory().
Quoted 28 lines
drivers/acpi/acpi_memhotplug.c +0
-5-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
===================================================================include/linux/memory_hotplug.h +0
-1@@ -252,7 +252,6 @@ extern int add_memory(int nid, u64 startextern 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
===================================================================
mm/memory_hotplug.c int walk_memory_range(unsigned long star · line 1670
Quoted 1 line
mm/memory_hotplug.c +0
-0@@ -1670,41 +1670,6 @@ int walk_memory_range(unsigned long star }
:
Quoted 19 lines
mm/memory_hotplug.c +0
-19- -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:
mm/memory_hotplug.c void try_offline_node(int nid) · line 1843
Quoted 10 lines
mm/memory_hotplug.c +0
-10-walk_memory_range (start_pfn, end_pfn, &ret, - offline_memory_block_cb); -if (ret) { -if (!retry) -return ret; - - retry =0 ; - ret =0 ; - goto repeat; - }
The above procedure can be removed as it is for off-lining.
Quoted 11 lines
mm/memory_hotplug.c +0
-11-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
mm/memory_hotplug.c void try_offline_node(int nid) · line 1865
Quoted 10 lines
mm/memory_hotplug.c +0
-10-* memory blocks are offlined. -*/ - - ret =walk_memory_range (start_pfn, end_pfn,NULL , - is_memblock_offlined_cb); -if (ret) { -unlock_memory_hotplug (); -return ret; - } -
I think the above procedure is still useful for safe guard.
mm/memory_hotplug.c void try_offline_node(int nid) · line 1871
Quoted 6 lines
mm/memory_hotplug.c +0
-6-/* remove memmap entry */ -firmware_map_remove (start, start + size,"System RAM" ); - -arch_remove_memory (start, size); - -try_offline_node (nid);
The above procedure performs memory hot-delete specific operations and is necessary.
Thanks,
-Toshi
mm/memory_hotplug.c void try_offline_node(int nid) · line 1876
Quoted 4 lines
mm/memory_hotplug.c +0
-4-unlock_memory_hotplug (); - -return 0 ; -}
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code
Quoted 132 lines · Toshi Kani
Quoted 9 lines · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
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 inacpi_memory_remove_memory()any more. Consequently, it doesn't need to callremove_memory()any more, which means that that funtion may be dropped entirely, becauseacpi_memory_remove_memory()is the only user of it.The off-lining part of
remove_memory()can be removed, but not the hot-delete part. Please see my comments below.Quoted 26 lines
Make the changes described above to get rid of the dead code.
Signed-off-by Rafael J. Wysocki <[email protected]>--- 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
===================================================================drivers/acpi/acpi_memhotplug.c +1
-4@@ -271,31 +271,20 @@ static int acpi_memory_enable_device(strreturn 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); -drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(str · line 290
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +1
-4list_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);We still need to call
remove_memory().Quoted 28 lines
drivers/acpi/acpi_memhotplug.c +0
-5-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
===================================================================include/linux/memory_hotplug.h +0
-1@@ -252,7 +252,6 @@ extern int add_memory(int nid, u64 startextern 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
===================================================================mm/memory_hotplug.c int walk_memory_range(unsigned long star · line 1670
Quoted 1 line
mm/memory_hotplug.c +0
-0@@ -1670,41 +1670,6 @@ int walk_memory_range(unsigned long star }:
Quoted 19 lines
mm/memory_hotplug.c +0
-19- -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:mm/memory_hotplug.c void try_offline_node(int nid) · line 1843
Quoted 10 lines
mm/memory_hotplug.c +0
-10-walk_memory_range (start_pfn, end_pfn, &ret, - offline_memory_block_cb); -if (ret) { -if (!retry) -return ret; - - retry =0 ; - ret =0 ; - goto repeat; - }The above procedure can be removed as it is for off-lining.
Quoted 15 lines
mm/memory_hotplug.c +0
-15-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,
Quoted 8 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1865
Quoted 6 lines
mm/memory_hotplug.c +0
-6- is_memblock_offlined_cb); -if (ret) { -unlock_memory_hotplug (); -return ret; - } -I think the above procedure is still useful for safe guard.
But then it shoud to BUG_ON() instead of returning an error (which isn't very useful for anything now).
Quoted 9 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1871
Quoted 6 lines
mm/memory_hotplug.c +0
-6-/* remove memmap entry */ -firmware_map_remove (start, start + size,"System RAM" ); - -arch_remove_memory (start, size); - -try_offline_node (nid);The above procedure performs memory hot-delete specific operations and is necessary.
OK, I see. I'll replace this patch with something simpler, then.
What about the other patches in the series?
Thanks,
Rafael
Signature · 8 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Toshi Kani
Quoted 1 line · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
:
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
mm/memory_hotplug.c +0
-15-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,Quoted 8 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1865
Quoted 6 lines
mm/memory_hotplug.c +0
-6- is_memblock_offlined_cb); -if (ret) { -unlock_memory_hotplug (); -return ret; - } -I think the above procedure is still useful for safe guard.
Quoted 2 lines
But then it shoud to
BUG_ON()instead of returning an error (which isn't very useful for anything now).
Right since we cannot fail at that state.
Quoted 11 lines
Quoted 9 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1871
Quoted 6 lines
mm/memory_hotplug.c +0
-6-/* remove memmap entry */ -firmware_map_remove (start, start + size,"System RAM" ); - -arch_remove_memory (start, size); - -try_offline_node (nid);The above procedure performs memory hot-delete specific operations and is necessary.
OK, I see. I'll replace this patch with something simpler, then.
Thanks.
Quoted 1 line
What about the other patches in the series?
I will send you my comments later (a bit interrupted for other thing now).
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Toshi Kani
Acked-byRe: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code
Quoted 46 lines · Toshi Kani
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Toshi Kani
Quoted 1 line · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
:
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
mm/memory_hotplug.c +0
-15-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,Quoted 8 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1865
Quoted 6 lines
mm/memory_hotplug.c +0
-6- is_memblock_offlined_cb); -if (ret) { -unlock_memory_hotplug (); -return ret; - } -I think the above procedure is still useful for safe guard.
Quoted 2 lines
But then it shoud to
BUG_ON()instead of returning an error (which isn't very useful for anything now).Right since we cannot fail at that state.
Quoted 10 lines
Quoted 9 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1871
Quoted 6 lines
mm/memory_hotplug.c +0
-6-/* remove memmap entry */ -firmware_map_remove (start, start + size,"System RAM" ); - -arch_remove_memory (start, size); - -try_offline_node (nid);The above procedure performs memory hot-delete specific operations and is necessary.
Quoted 8 lines
Quoted 1 line
OK, I see. I'll replace this patch with something simpler, then.
Thanks.
Quoted 1 line
What about the other patches in the series?
I will send you my comments later (a bit interrupted for other thing now).
Other patches look good. For patch 1/5 to 4/5:
Thanks,
-Toshi
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
PATCH 1/1 Memory hotplug / ACPI: Simplify memory removal (was: Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code)
In reply to Toshi KaniQuoted 46 lines · Toshi Kani
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Toshi Kani
Quoted 1 line · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
:
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
(quoted diff) +0
-15- 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,Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +0
-6- is_memblock_offlined_cb); - if (ret) { - unlock_memory_hotplug(); - return ret; - } -I think the above procedure is still useful for safe guard.
Quoted 2 lines
But then it shoud to
BUG_ON()instead of returning an error (which isn't very useful for anything now).Right since we cannot fail at that state.
Quoted 10 lines
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +0
-6- /* remove memmap entry */ - firmware_map_remove(start, start + size, "System RAM"); - - arch_remove_memory(start, size); - - try_offline_node(nid);The above procedure performs memory hot-delete specific operations and is necessary.
Quoted 3 lines
Quoted 1 line
OK, I see. I'll replace this patch with something simpler, then.
Thanks.
The replacement patch is appended.
Thanks,
Rafael
---
From: Rafael J. Wysocki <[email protected]>
Subject: Memory hotplug / ACPI: Simplify memory removal
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 remove_memory() any more. Moreover, since the return value of remove_memory() is not used, it's better to make it be a void function and trigger a BUG() if the memory scheduled for removal is not offline.
Change the code in accordance with the above observations.
--- drivers/acpi/acpi_memhotplug.c | 13 +------ include/linux/memory_hotplug.h | 2 - mm/memory_hotplug.c | 71 ++++------------------------------------- 3 files changed, 12 insertions(+), 74 deletions(-)
include/linux/memory_hotplug.h +1 -1
@@ -252,7 +252,7 @@ extern int add_memory(int nid, u64 startextern 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 void 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);
drivers/acpi/acpi_memhotplug.c +3 -10
@@ -271,13 +271,11 @@ static int acpi_memory_enable_device(strreturn 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); +int nid =acpi_get_node (handle);list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (!info->enabled)
@@ -287,15 +285,10 @@ static int acpi_memory_remove_memory(str nid =memory_add_physaddr_to_nid (info->start_addr);acpi_unbind_memory_blocks (info, handle); - result =remove_memory (nid, info->start_addr, info->length); -if (result) -return result; - +remove_memory (nid, info->start_addr, info->length);list_del (&info->list);kfree (info); } - -return result; }static void acpi_memory_device_free (struct acpi_memory_device *mem_device)
mm/memory_hotplug.c +8 -63
103 lines not on this page · raw message
Re: [PATCH *5/5] Memory hotplug / ACPI: Simplify memory removal (was: Re: [PATCH 5/5] ACPI / memhotplug: Drop unnecessary code)
Quoted 47 lines · Rafael J. Wysocki
Quoted 46 lines · Toshi Kani
Quoted 3 lines · Rafael J. Wysocki
Quoted 2 lines · Toshi Kani
Quoted 1 line · Rafael J. Wysocki
From: Rafael J. Wysocki <[email protected]>
:
Quoted 24 lines
Quoted 15 lines
Quoted 15 lines
mm/memory_hotplug.c +0
-15-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,Quoted 8 lines
mm/memory_hotplug.c void try_offline_node(int nid) · line 1858
Quoted 6 lines
mm/memory_hotplug.c +0
-6- is_memblock_offlined_cb); -if (ret) { -unlock_memory_hotplug (); -return ret; - } -I think the above procedure is still useful for safe guard.
Quoted 2 lines
But then it shoud to
BUG_ON()instead of returning an error (which isn't very useful for anything now).Right since we cannot fail at that state.
Quoted 10 lines
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +0
-6- /* remove memmap entry */ - firmware_map_remove(start, start + size, "System RAM"); - - arch_remove_memory(start, size); - - try_offline_node(nid);The above procedure performs memory hot-delete specific operations and is necessary.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
OK, I see. I'll replace this patch with something simpler, then.
Thanks.
The replacement patch is appended.
The updated patch looks good.
Thanks,
-Toshi
Quoted 24 lines
Thanks,
Rafael---
From: Rafael J. Wysocki <[email protected]>
Subject: Memory hotplug / ACPI: Simplify memory removalNow 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 inremove_memory()any more. Moreover, since the return value ofremove_memory()is not used, it's better to make it be a void function and trigger aBUG()if the memory scheduled for removal is not offline.Change the code in accordance with the above observations.
Signed-off-by Rafael J. Wysocki <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 13 +------ include/linux/memory_hotplug.h | 2 - mm/memory_hotplug.c | 71 ++++------------------------------------- 3 files changed, 12 insertions(+), 74 deletions(-)