acpi,memory-hotplug: implement framework for hot removing memory
Subsystems (2)
v5 cover acpi,memory-hotplug: implement framework for hot removing memory
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
In the 1st case, acpi_memory_disable_device() will be called. In the 2nd case, acpi_memory_device_remove() will be called. acpi_memory_device_remove() will also be called when we unbind the memory device from the driver acpi_memhotplug or a driver initialization fails.
acpi_memory_disable_device() has already implemented a code which offlines memory and releases acpi_memory_info struct . But acpi_memory_device_remove() has not implemented it yet.
So the patch prepares the framework for hot removing memory and adds the framework into acpi_memory_device_remove().
We may hotremove the memory device by this 2 ways at the same time. So we remove the function acpi_memory_disable_device(), and use acpi_bus_hot_remove_device() which is used by 2nd case to implement it. We lock device in acpi_bus_hot_remove_device(), so there is no need to add lock in acpi_memhotplug.
The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121
Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):
54c4c7db6cb94d7d1217df6d7fca6847c61744ab
2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225
Changes from v4 to v5:
1. patch2: new patch. use acpi_bus_hot_remove_device() to implement memory device hotremove.
Changes from v3 to v4:
1. patch1: unlock list_lock when removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.
Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queue acpi_memhotplug.c: fix memory leak when memory device is unbound from
the module acpi_memhotplug
acpi_memhotplug.c: free memory device if acpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loaded
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()
drivers/acpi/acpi_memhotplug.c | 206 ++++++++++++++++++++++------------------- 1 file changed, 109 insertions(+), 97 deletions(-)
Signature · 7 lines
1.8.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>
PATCH v5 1/7 acpi,memory-hotplug : add memory offline code to acpi_memory_device_remove()
From: Yasuaki Ishimatsu <[email protected]>
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
In the 1st case, acpi_memory_disable_device() will be called. In the 2nd case, acpi_memory_device_remove() will be called. acpi_memory_device_remove() will also be called when we unbind the memory device from the driver acpi_memhotplug or a driver initialization fails.
acpi_memory_disable_device() has already implemented a code which offlines memory and releases acpi_memory_info struct. But acpi_memory_device_remove() has not implemented it yet.
So the patch move offlining memory and releasing acpi_memory_info struct codes to a new function acpi_memory_remove_memory(). And it is used by both acpi_memory_device_remove() and acpi_memory_disable_device().
--- drivers/acpi/acpi_memhotplug.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-)
drivers/acpi/acpi_memhotplug.c +24 -7
@@ -306,25 +306,37 @@ static int acpi_memory_powerdown_device(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) +static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) {int result;struct acpi_memory_info *info, *n; - -/* -* Ask the VM to offline this memory range. -* Note: Assume that this function returns zero on success -*/ list_for_each_entry_safe (info, n, &mem_device->res_list, list) {if (info->enabled) { result =remove_memory (info->start_addr, info->length);if (result)return result; } + +list_del (&info->list);kfree (info); } +return 0 ; +} + +static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) +{ +int result; + +/* +* Ask the VM to offline this memory range. +* Note: Assume that this function returns zero on success +*/ + result =acpi_memory_remove_memory (mem_device); +if (result) +return result; +/* Power-off and eject the device */ result =acpi_memory_powerdown_device (mem_device);if (result) {
@@ -473,12 +485,17 @@ static int acpi_memory_device_add(struct acpi_device *device)static int acpi_memory_device_remove (struct acpi_device *device,int type) {struct acpi_memory_device *mem_device =NULL ; - +int result;if (!device || !acpi_driver_data (device))return -EINVAL ; mem_device =acpi_driver_data (device); + + result =acpi_memory_remove_memory (mem_device); +if (result) +return result; +kfree (mem_device);return 0 ;
Signature · 7 lines
1.8.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 v5 1/7] acpi,memory-hotplug : add memory offline code to acpi_memory_device_remove()
Quoted 20 lines · Wen Congyang
From: Yasuaki Ishimatsu <[email protected]>
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct. Butacpi_memory_device_remove()has not implemented it yet.So the patch move offlining memory and releasing
acpi_memory_infostruct codes to a new functionacpi_memory_remove_memory(). And it is used by bothacpi_memory_device_remove()andacpi_memory_disable_device().
Quoted 13 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Yasuaki Ishimatsu <[email protected]>Signed-off-by Wen Congyang <[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 v5 2/7 acpi,memory-hotplug: deal with eject request in hotplug queue
In reply to Wen CongyangThe memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
We handle the 1st case in the module acpi_memhotplug, and handle the 2nd case in ACPI eject notification. This 2 events may happen at the same time, so we may touch acpi_memory_device.res_list at the same time. This patch reimplements memory-hotremove support through an ACPI eject notification. Now the memory device is offlined and hotremoved only in the function acpi_memory_device_remove() which is protected by device_lock().
--- drivers/acpi/acpi_memhotplug.c | 87 +++++------------------------------------- 1 file changed, 9 insertions(+), 78 deletions(-)
drivers/acpi/acpi_memhotplug.c +9 -78
@@ -272,40 +272,6 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_powerdown_device (struct acpi_memory_device *mem_device) -{ -acpi_status status; -struct acpi_object_list arg_list; -union acpi_object arg; -unsigned long long current_status; - - -/* Issue the _EJ0 command */ - arg_list.count =1 ; - arg_list.pointer = &arg; - arg.type =ACPI_TYPE_INTEGER ; - arg.integer.value =1 ; - status =acpi_evaluate_object (mem_device->device->handle, -"_EJ0" , &arg_list,NULL ); -/* Return on _EJ0 failure */ -if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"_EJ0 failed" )); -return -ENODEV ; - } - -/* Evalute _STA to check if the device is disabled */ - status =acpi_evaluate_integer (mem_device->device->handle,"_STA" , -NULL , ¤t_status); -if (ACPI_FAILURE (status)) -return -ENODEV ; - -/* Check for device status. Device should be disabled */ -if (current_status &ACPI_STA_DEVICE_ENABLED ) -return -EINVAL ; - -return 0 ; -} -static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) {int result;
@@ -325,34 +291,11 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) -{ -int result; - -/* -* Ask the VM to offline this memory range. -* Note: Assume that this function returns zero on success -*/ - result =acpi_memory_remove_memory (mem_device); -if (result) -return result; - -/* Power-off and eject the device */ - result =acpi_memory_powerdown_device (mem_device); -if (result) { -/* Set the status of the device to invalid */ - mem_device->state =MEMORY_INVALID_STATE ; -return result; - } - - mem_device->state =MEMORY_POWER_OFF_STATE ; -return result; -} -static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data) {struct acpi_memory_device *mem_device;struct acpi_device *device; +struct acpi_eject_event *ej_event =NULL ;u32 ost_code =ACPI_OST_SC_NON_SPECIFIC_FAILURE ;/* default */ switch (event) {
@@ -394,31 +337,19 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)break ; } -/* -* Currently disabling memory device from kernel mode -* TBD: Can also be disabled from user mode scripts -* TBD: Can also be disabled by Callback registration -* with generic sysfs driver -*/ -if (acpi_memory_disable_device (mem_device)) { - printk(KERN_ERR PREFIX "Disable memory device\n"); -/* -* If _EJ0 was called but failed, _OST is not -* necessary. -*/ -if (mem_device->state ==MEMORY_INVALID_STATE ) -return ; - + ej_event =kmalloc (sizeof (*ej_event),GFP_KERNEL ); +if (!ej_event) { +pr_err (PREFIX "No memory, dropping EJECT\n" );break ; } -/* -* TBD: Invoke acpi_bus_remove to cleanup data structures -*/ + ej_event->handle = handle; + ej_event->event =ACPI_NOTIFY_EJECT_REQUEST ; +acpi_os_hotplug_execute (acpi_bus_hot_remove_device, + (void *)ej_event); -/* _EJ0 succeeded; _OST is not necessary */ +/* eject is performed asynchronously */ return ; -default :ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Unsupported event [0x%x]\n" , event));
Signature · 7 lines
1.8.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 v5 2/7] acpi,memory-hotplug: deal with eject request in hotplug queue
Quoted 25 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectWe handle the 1st case in the module
acpi_memhotplug, and handle the 2nd case in ACPI eject notification. This 2 events may happen at the same time, so we may touch acpi_memory_device.res_list at the same time. This patch reimplements memory-hotremove support through an ACPI eject notification. Now the memory device is offlined and hotremoved only in the functionacpi_memory_device_remove()which is protected bydevice_lock().CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 115 lines
drivers/acpi/acpi_memhotplug.c | 87 +++++------------------------------------- 1 file changed, 9 insertions(+), 78 deletions(-)drivers/acpi/acpi_memhotplug.c +6
-76@@ -272,40 +272,6 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_powerdown_device (struct acpi_memory_device *mem_device) -{ -acpi_status status; -struct acpi_object_list arg_list; -union acpi_object arg; -unsigned long long current_status; - - -/* Issue the _EJ0 command */ - arg_list.count =1 ; - arg_list.pointer = &arg; - arg.type =ACPI_TYPE_INTEGER ; - arg.integer.value =1 ; - status =acpi_evaluate_object (mem_device->device->handle, -"_EJ0" , &arg_list,NULL ); -/* Return on _EJ0 failure */ -if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"_EJ0 failed" )); -return -ENODEV ; - } - -/* Evalute _STA to check if the device is disabled */ - status =acpi_evaluate_integer (mem_device->device->handle,"_STA" , -NULL , ¤t_status); -if (ACPI_FAILURE (status)) -return -ENODEV ; - -/* Check for device status. Device should be disabled */ -if (current_status &ACPI_STA_DEVICE_ENABLED ) -return -EINVAL ; - -return 0 ; -} -static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) {int result;@@ -325,34 +291,11 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) -{ -int result; - -/* -* Ask the VM to offline this memory range. -* Note: Assume that this function returns zero on success -*/ - result =acpi_memory_remove_memory (mem_device); -if (result) -return result; - -/* Power-off and eject the device */ - result =acpi_memory_powerdown_device (mem_device); -if (result) { -/* Set the status of the device to invalid */ - mem_device->state =MEMORY_INVALID_STATE ; -return result; - } - - mem_device->state =MEMORY_POWER_OFF_STATE ; -return result; -} -static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data) {struct acpi_memory_device *mem_device;struct acpi_device *device; +struct acpi_eject_event *ej_event =NULL ;u32 ost_code =ACPI_OST_SC_NON_SPECIFIC_FAILURE ;/* default */ switch (event) {@@ -394,31 +337,19 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)break ; } -/* -* Currently disabling memory device from kernel mode -* TBD: Can also be disabled from user mode scripts -* TBD: Can also be disabled by Callback registration -* with generic sysfs driver -*/ -if (acpi_memory_disable_device (mem_device)) { - printk(KERN_ERR PREFIX "Disable memory device\n"); -/* -* If _EJ0 was called but failed, _OST is not -* necessary. -*/ -if (mem_device->state ==MEMORY_INVALID_STATE ) -return ; - + ej_event =kmalloc (sizeof (*ej_event),GFP_KERNEL ); +if (!ej_event) { +pr_err (PREFIX "No memory, dropping EJECT\n" );break ; } -/* -* TBD: Invoke acpi_bus_remove to cleanup data structures -*/ + ej_event->handle = handle; + ej_event->event =ACPI_NOTIFY_EJECT_REQUEST ;
drivers/acpi/acpi_memhotplug.c static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data) · line 355
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +3
-2+acpi_os_hotplug_execute (acpi_bus_hot_remove_device, + (void *)ej_event); -/* _EJ0 succeeded; _OST is not necessary */ +/* eject is performed asynchronously */ return ; -default :ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Unsupported event [0x%x]\n" , event));
--
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 v5 2/7] acpi,memory-hotplug: deal with eject request in hotplug queue
In reply to Wen CongyangQuoted 12 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectWe handle the 1st case in the module
acpi_memhotplug, and handle the 2nd case in ACPI eject notification. This 2 events may happen at the same time, so we may touch acpi_memory_device.res_list at the same time. This patch reimplements memory-hotremove support through an ACPI eject notification. Now the memory device is offlined and hotremoved only in the functionacpi_memory_device_remove()which is protected bydevice_lock().
Quoted 13 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Thanks for the update. It looks good.
-Toshi
Re: [Patch v5 2/7] acpi,memory-hotplug: deal with eject request in hotplug queue
In reply to Wen CongyangQuoted 4 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/eject
Quoted 8 lines
We handle the 1st case in the module
acpi_memhotplug, and handle the 2nd case in ACPI eject notification. This 2 events may happen at the same time, so we may touch acpi_memory_device.res_list at the same time. This patch reimplements memory-hotremove support through an ACPI eject notification. Now the memory device is offlined and hotremoved only in the functionacpi_memory_device_remove()which is protected bydevice_lock().
You mean it's protected by device_lock() before calling the remove() function for eject?
Quoted 138 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 87 +++++------------------------------------- 1 file changed, 9 insertions(+), 78 deletions(-)drivers/acpi/acpi_memhotplug.c +9
-78@@ -272,40 +272,6 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_powerdown_device (struct acpi_memory_device *mem_device) -{ -acpi_status status; -struct acpi_object_list arg_list; -union acpi_object arg; -unsigned long long current_status; - - -/* Issue the _EJ0 command */ - arg_list.count =1 ; - arg_list.pointer = &arg; - arg.type =ACPI_TYPE_INTEGER ; - arg.integer.value =1 ; - status =acpi_evaluate_object (mem_device->device->handle, -"_EJ0" , &arg_list,NULL ); -/* Return on _EJ0 failure */ -if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"_EJ0 failed" )); -return -ENODEV ; - } - -/* Evalute _STA to check if the device is disabled */ - status =acpi_evaluate_integer (mem_device->device->handle,"_STA" , -NULL , ¤t_status); -if (ACPI_FAILURE (status)) -return -ENODEV ; - -/* Check for device status. Device should be disabled */ -if (current_status &ACPI_STA_DEVICE_ENABLED ) -return -EINVAL ; - -return 0 ; -} -static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) {int result;@@ -325,34 +291,11 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) -{ -int result; - -/* -* Ask the VM to offline this memory range. -* Note: Assume that this function returns zero on success -*/ - result =acpi_memory_remove_memory (mem_device); -if (result) -return result; - -/* Power-off and eject the device */ - result =acpi_memory_powerdown_device (mem_device); -if (result) { -/* Set the status of the device to invalid */ - mem_device->state =MEMORY_INVALID_STATE ; -return result; - } - - mem_device->state =MEMORY_POWER_OFF_STATE ; -return result; -} -static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data) {struct acpi_memory_device *mem_device;struct acpi_device *device; +struct acpi_eject_event *ej_event =NULL ;u32 ost_code =ACPI_OST_SC_NON_SPECIFIC_FAILURE ;/* default */ switch (event) {@@ -394,31 +337,19 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)break ; } -/* -* Currently disabling memory device from kernel mode -* TBD: Can also be disabled from user mode scripts -* TBD: Can also be disabled by Callback registration -* with generic sysfs driver -*/ -if (acpi_memory_disable_device (mem_device)) { - printk(KERN_ERR PREFIX "Disable memory device\n"); -/* -* If _EJ0 was called but failed, _OST is not -* necessary. -*/ -if (mem_device->state ==MEMORY_INVALID_STATE ) -return ; - + ej_event =kmalloc (sizeof (*ej_event),GFP_KERNEL ); +if (!ej_event) { +pr_err (PREFIX "No memory, dropping EJECT\n" );break ; } -/* -* TBD: Invoke acpi_bus_remove to cleanup data structures -*/ + ej_event->handle = handle; + ej_event->event =ACPI_NOTIFY_EJECT_REQUEST ; +acpi_os_hotplug_execute (acpi_bus_hot_remove_device, + (void *)ej_event); -/* _EJ0 succeeded; _OST is not necessary */ +/* eject is performed asynchronously */ return ; -default :ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Unsupported event [0x%x]\n" , event));
Re: [Patch v5 2/7] acpi,memory-hotplug: deal with eject request in hotplug queue
At 11/16/2012 07:32 AM, David Rientjes Wrote:
Quoted 15 lines · Wen Congyang
Quoted 5 lines
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectQuoted 8 lines
We handle the 1st case in the module
acpi_memhotplug, and handle the 2nd case in ACPI eject notification. This 2 events may happen at the same time, so we may touch acpi_memory_device.res_list at the same time. This patch reimplements memory-hotremove support through an ACPI eject notification. Now the memory device is offlined and hotremoved only in the functionacpi_memory_device_remove()which is protected bydevice_lock().
Quoted 2 lines
You mean it's protected by
device_lock()before calling theremove()function for eject?
Yes. We call device_release_driver() to unbind the device from the driver (the memory will be offlined/removed when it is unbound from the driver).
we call device_lock() in device_release_driver(), so we only unbind it from the driver once.
Thanks
Wen Congyang
Quoted 140 lines
Quoted 139 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 87 +++++------------------------------------- 1 file changed, 9 insertions(+), 78 deletions(-)drivers/acpi/acpi_memhotplug.c +9
-78@@ -272,40 +272,6 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_powerdown_device (struct acpi_memory_device *mem_device) -{ -acpi_status status; -struct acpi_object_list arg_list; -union acpi_object arg; -unsigned long long current_status; - - -/* Issue the _EJ0 command */ - arg_list.count =1 ; - arg_list.pointer = &arg; - arg.type =ACPI_TYPE_INTEGER ; - arg.integer.value =1 ; - status =acpi_evaluate_object (mem_device->device->handle, -"_EJ0" , &arg_list,NULL ); -/* Return on _EJ0 failure */ -if (ACPI_FAILURE (status)) { -ACPI_EXCEPTION ((AE_INFO , status,"_EJ0 failed" )); -return -ENODEV ; - } - -/* Evalute _STA to check if the device is disabled */ - status =acpi_evaluate_integer (mem_device->device->handle,"_STA" , -NULL , ¤t_status); -if (ACPI_FAILURE (status)) -return -ENODEV ; - -/* Check for device status. Device should be disabled */ -if (current_status &ACPI_STA_DEVICE_ENABLED ) -return -EINVAL ; - -return 0 ; -} -static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) {int result;@@ -325,34 +291,11 @@ static int acpi_memory_remove_memory(struct acpi_memory_device *mem_device)return 0 ; } -static int acpi_memory_disable_device (struct acpi_memory_device *mem_device) -{ -int result; - -/* -* Ask the VM to offline this memory range. -* Note: Assume that this function returns zero on success -*/ - result =acpi_memory_remove_memory (mem_device); -if (result) -return result; - -/* Power-off and eject the device */ - result =acpi_memory_powerdown_device (mem_device); -if (result) { -/* Set the status of the device to invalid */ - mem_device->state =MEMORY_INVALID_STATE ; -return result; - } - - mem_device->state =MEMORY_POWER_OFF_STATE ; -return result; -} -static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data) {struct acpi_memory_device *mem_device;struct acpi_device *device; +struct acpi_eject_event *ej_event =NULL ;u32 ost_code =ACPI_OST_SC_NON_SPECIFIC_FAILURE ;/* default */ switch (event) {@@ -394,31 +337,19 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)break ; } -/* -* Currently disabling memory device from kernel mode -* TBD: Can also be disabled from user mode scripts -* TBD: Can also be disabled by Callback registration -* with generic sysfs driver -*/ -if (acpi_memory_disable_device (mem_device)) { - printk(KERN_ERR PREFIX "Disable memory device\n"); -/* -* If _EJ0 was called but failed, _OST is not -* necessary. -*/ -if (mem_device->state ==MEMORY_INVALID_STATE ) -return ; - + ej_event =kmalloc (sizeof (*ej_event),GFP_KERNEL ); +if (!ej_event) { +pr_err (PREFIX "No memory, dropping EJECT\n" );break ; } -/* -* TBD: Invoke acpi_bus_remove to cleanup data structures -*/ + ej_event->handle = handle; + ej_event->event =ACPI_NOTIFY_EJECT_REQUEST ; +acpi_os_hotplug_execute (acpi_bus_hot_remove_device, + (void *)ej_event); -/* _EJ0 succeeded; _OST is not necessary */ +/* eject is performed asynchronously */ return ; -default :ACPI_DEBUG_PRINT ((ACPI_DB_INFO ,"Unsupported event [0x%x]\n" , event));
PATCH v5 3/7 acpi_memhotplug.c: fix memory leak when memory device is unbound from the module acpi_memhotplug
In reply to Wen CongyangWe allocate memory to store acpi_memory_info, so we should free it before freeing mem_device.
--- drivers/acpi/acpi_memhotplug.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)
drivers/acpi/acpi_memhotplug.c +21 -6
@@ -125,12 +125,20 @@ acpi_memory_get_resource(struct acpi_resource *resource, void *context)return AE_OK ; } +static void +acpi_memory_free_device_resources (struct acpi_memory_device *mem_device) +{ +struct acpi_memory_info *info, *n; + +list_for_each_entry_safe (info, n, &mem_device->res_list, list) +kfree (info); +INIT_LIST_HEAD (&mem_device->res_list); +} +static int acpi_memory_get_device_resources (struct acpi_memory_device *mem_device) {acpi_status status; -struct acpi_memory_info *info, *n; -if (!list_empty (&mem_device->res_list))return 0 ;
@@ -138,9 +146,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) status =acpi_walk_resources (mem_device->device->handle,METHOD_NAME__CRS , acpi_memory_get_resource, mem_device);if (ACPI_FAILURE (status)) { -list_for_each_entry_safe (info, n, &mem_device->res_list, list) -kfree (info); -INIT_LIST_HEAD (&mem_device->res_list); +acpi_memory_free_device_resources (mem_device);return -EINVAL ; }
@@ -363,6 +369,15 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)return ; } +static void acpi_memory_device_free (struct acpi_memory_device *mem_device) +{ +if (!mem_device) +return ; + +acpi_memory_free_device_resources (mem_device); +kfree (mem_device); +} +static int acpi_memory_device_add (struct acpi_device *device) {int result;
@@ -427,7 +442,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)if (result)return result; -kfree (mem_device); +acpi_memory_device_free (mem_device);return 0 ; }
Signature · 7 lines
1.8.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 v5 3/7] acpi_memhotplug.c: fix memory leak when memory device is unbound from the module acpi_memhotplug
Quoted 16 lines · Wen Congyang
We allocate memory to store
acpi_memory_info, so we should free it before freeingmem_device.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 59 lines
drivers/acpi/acpi_memhotplug.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-)drivers/acpi/acpi_memhotplug.c +20
-5@@ -125,12 +125,20 @@ acpi_memory_get_resource(struct acpi_resource *resource, void *context)return AE_OK ; } +static void +acpi_memory_free_device_resources (struct acpi_memory_device *mem_device) +{ +struct acpi_memory_info *info, *n; + +list_for_each_entry_safe (info, n, &mem_device->res_list, list) +kfree (info); +INIT_LIST_HEAD (&mem_device->res_list); +} +static int acpi_memory_get_device_resources (struct acpi_memory_device *mem_device) {acpi_status status; -struct acpi_memory_info *info, *n; -if (!list_empty (&mem_device->res_list))return 0 ;@@ -138,9 +146,7 @@ acpi_memory_get_device_resources(struct acpi_memory_device *mem_device) status =acpi_walk_resources (mem_device->device->handle,METHOD_NAME__CRS , acpi_memory_get_resource, mem_device);if (ACPI_FAILURE (status)) { -list_for_each_entry_safe (info, n, &mem_device->res_list, list) -kfree (info); -INIT_LIST_HEAD (&mem_device->res_list); +acpi_memory_free_device_resources (mem_device);return -EINVAL ; }@@ -363,6 +369,15 @@ static void acpi_memory_device_notify(acpi_handle handle, u32 event, void *data)return ; } +static void acpi_memory_device_free (struct acpi_memory_device *mem_device) +{ +if (!mem_device) +return ; + +acpi_memory_free_device_resources (mem_device); +kfree (mem_device); +} +static int acpi_memory_device_add (struct acpi_device *device) {int result;
drivers/acpi/acpi_memhotplug.c static int acpi_memory_device_remove(struct acpi_device *device, int type) · line 448
Quoted 8 lines
drivers/acpi/acpi_memhotplug.c +1
-1@@ -427,7 +442,7 @@ static int acpi_memory_device_remove(struct acpi_device *device, int type)if (result)return result; -kfree (mem_device); +acpi_memory_device_free (mem_device);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 v5 3/7] acpi_memhotplug.c: fix memory leak when memory device is unbound from the module acpi_memhotplug
In reply to Wen CongyangQuoted 16 lines · Wen Congyang
We allocate memory to store
acpi_memory_info, so we should free it before freeingmem_device.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
It's a little strange to be re-initializing mem_device->res_list right before freeing mem_device in acpi_memory_device_free(), though. Owell :)
PATCH v5 4/7 acpi_memhotplug.c: free memory device if acpi_memory_enable_device() failed
In reply to Wen CongyangIf acpi_memory_enable_device() fails, acpi_memory_enable_device() will return a non-zero value, which means we fail to bind the memory device to this driver. So we should free memory device before acpi_memory_device_add() returns.
--- drivers/acpi/acpi_memhotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/acpi/acpi_memhotplug.c +3 -1
@@ -421,9 +421,11 @@ static int acpi_memory_device_add(struct acpi_device *device)if (!acpi_memory_check_device (mem_device)) {/* call add_memory func */ result =acpi_memory_enable_device (mem_device); -if (result) +if (result) { printk(KERN_ERR PREFIX "Error in acpi_memory_enable_device\n"); +acpi_memory_device_free (mem_device); + } }return result; }
Signature · 7 lines
1.8.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 v5 4/7] acpi_memhotplug.c: free memory device if acpi_memory_enable_device() failed
Quoted 18 lines · Wen Congyang
If
acpi_memory_enable_device()fails,acpi_memory_enable_device()will return a non-zero value, which means we fail to bind the memory device to this driver. So we should free memory device beforeacpi_memory_device_add()returns.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 21 lines
drivers/acpi/acpi_memhotplug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/acpi/acpi_memhotplug.c +3
-1@@ -421,9 +421,11 @@ static int acpi_memory_device_add(struct acpi_device *device)if (!acpi_memory_check_device (mem_device)) {/* call add_memory func */ result =acpi_memory_enable_device (mem_device); -if (result) +if (result) { printk(KERN_ERR PREFIX "Error in acpi_memory_enable_device\n"); +acpi_memory_device_free (mem_device); + } }return result; }
Re: [Patch v5 4/7] acpi_memhotplug.c: free memory device if acpi_memory_enable_device() failed
In reply to Wen CongyangQuoted 5 lines · Wen Congyang
If
acpi_memory_enable_device()fails,acpi_memory_enable_device()will return a non-zero value, which means we fail to bind the memory device to this driver. So we should free memory device beforeacpi_memory_device_add()returns.
Quoted 13 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
PATCH v5 5/7 acpi_memhotplug.c: don't allow to eject the memory device if it is being used
In reply to Wen CongyangWe eject the memory device even if it is in use. It is very dangerous, and it will cause the kernel to be panicked.
--- drivers/acpi/acpi_memhotplug.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-)
drivers/acpi/acpi_memhotplug.c +33 -9
@@ -78,6 +78,7 @@ struct acpi_memory_info {unsigned short caching;/* memory cache attribute */ unsigned short write_protect;/* memory read/write attribute */ unsigned int enabled:1; + unsigned int failed:1; };struct acpi_memory_device {
@@ -257,9 +258,23 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) node =memory_add_physaddr_to_nid (info->start_addr); result =add_memory (node, info->start_addr, info->length); -if (result) + +/* +* If the memory block has been used by the kernel, add_memory() +* returns -EEXIST. If add_memory() returns the other error, it +* means that this memory block is not used by the kernel. +*/ +if (result && result != -EEXIST ) { + info->failed =1 ;continue ; - info->enabled =1 ; + } + +if (!result) + info->enabled =1 ; +/* +* Add num_enable even if add_memory() returns -EEXIST, so the +* device is bound to this driver. +*/ num_enabled++; }if (!num_enabled) {
@@ -280,21 +295,30 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) { -int result; +int result =0 ;struct acpi_memory_info *info, *n;list_for_each_entry_safe (info, n, &mem_device->res_list, list) { -if (info->enabled) { - result =remove_memory (info->start_addr, info->length); -if (result) -return result; - } +if (info->failed) +/* The kernel does not use this memory block */ +continue ; + +if (!info->enabled) +/* +* The kernel uses this memory block, but it may be not +* managed by us. +*/ +return -EBUSY ; + + result =remove_memory (info->start_addr, info->length); +if (result) +return result;list_del (&info->list);kfree (info); } -return 0 ; +return result; }static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data)
Signature · 7 lines
1.8.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 v5 5/7] acpi_memhotplug.c: don't allow to eject the memory device if it is being used
Quoted 16 lines · Wen Congyang
We eject the memory device even if it is in use. It is very dangerous, and it will cause the kernel to be panicked.
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 70 lines
drivers/acpi/acpi_memhotplug.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-)drivers/acpi/acpi_memhotplug.c +32
-8@@ -78,6 +78,7 @@ struct acpi_memory_info {unsigned short caching;/* memory cache attribute */ unsigned short write_protect;/* memory read/write attribute */ unsigned int enabled:1; + unsigned int failed:1; };struct acpi_memory_device {@@ -257,9 +258,23 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) node =memory_add_physaddr_to_nid (info->start_addr); result =add_memory (node, info->start_addr, info->length); -if (result) + +/* +* If the memory block has been used by the kernel, add_memory() +* returns -EEXIST. If add_memory() returns the other error, it +* means that this memory block is not used by the kernel. +*/ +if (result && result != -EEXIST ) { + info->failed =1 ;continue ; - info->enabled =1 ; + } + +if (!result) + info->enabled =1 ; +/* +* Add num_enable even if add_memory() returns -EEXIST, so the +* device is bound to this driver. +*/ num_enabled++; }if (!num_enabled) {@@ -280,21 +295,30 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) { -int result; +int result =0 ;struct acpi_memory_info *info, *n;list_for_each_entry_safe (info, n, &mem_device->res_list, list) { -if (info->enabled) { - result =remove_memory (info->start_addr, info->length); -if (result) -return result; - } +if (info->failed) +/* The kernel does not use this memory block */ +continue ; + +if (!info->enabled) +/* +* The kernel uses this memory block, but it may be not +* managed by us. +*/ +return -EBUSY ; + + result =remove_memory (info->start_addr, info->length); +if (result) +return result;
drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) · line 324
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +1
-1list_del (&info->list);kfree (info); } -return 0 ; +return result; }static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data)
--
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 v5 5/7] acpi_memhotplug.c: don't allow to eject the memory device if it is being used
In reply to Wen CongyangQuoted 16 lines · Wen Congyang
We eject the memory device even if it is in use. It is very dangerous, and it will cause the kernel to be panicked.
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Thanks for adding the comment about why num_enabled is incremented for -EEXIST.
Re: [Patch v5 5/7] acpi_memhotplug.c: don't allow to eject the memory device if it is being used
In reply to Wen Congyang2012/11/15 Wen Congyang <[email protected]>
Quoted 42 lines
We eject the memory device even if it is in use. It is very dangerous, and it will cause the kernel to be panicked.
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-)drivers/acpi/acpi_memhotplug.c +5
-1@@ -78,6 +78,7 @@ struct acpi_memory_info {unsigned short caching;/* memory cache attribute */ unsigned short write_protect;/* memory read/write attribute */ unsigned int enabled:1; + unsigned int failed:1; };struct acpi_memory_device {@@ -257,9 +258,23 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) node =memory_add_physaddr_to_nid (info->start_addr); result =add_memory (node, info->start_addr, info->length); -if (result) + +/* +* If the memory block has been used by the kernel, add_memory() +* returns -EEXIST. If add_memory() returns the other error, it
drivers/acpi/acpi_memhotplug.c static int acpi_memory_enable_device(struct acpi_memory_device *mem_device) · line 273
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +8
-1+* means that this memory block is not used by the kernel. +*/ +if (result && result != -EEXIST ) { + info->failed =1 ;continue ; - info->enabled =1 ; + } + +if (!result) + info->enabled =1 ;
Hi Congyang,
If a memory device booting with the system, the info->enable will equal to 0, and can not be hot-removed in acpi_memory_remove_memory(), right?
Thanks,
Jianguo Wu
Quoted 54 lines
drivers/acpi/acpi_memhotplug.c +20
-8+/* +* Add num_enable even if add_memory() returns -EEXIST, so the +* device is bound to this driver. +*/ num_enabled++; }if (!num_enabled) {@@ -280,21 +295,30 @@ static int acpi_memory_enable_device(struct acpi_memory_device *mem_device)static int acpi_memory_remove_memory (struct acpi_memory_device *mem_device) { -int result; +int result =0 ;struct acpi_memory_info *info, *n;list_for_each_entry_safe (info, n, &mem_device->res_list, list) { -if (info->enabled) { - result =remove_memory (info->start_addr, info->length); -if (result) -return result; - } +if (info->failed) +/* The kernel does not use this memory block */ +continue ; + +if (!info->enabled) +/* +* The kernel uses this memory block, but it may be not +* managed by us. +*/ +return -EBUSY ; + + result =remove_memory (info->start_addr, info->length); +if (result) +return result;list_del (&info->list);kfree (info); } -return 0 ; +return result; }static void acpi_memory_device_notify (acpi_handle handle,u32 event,void *data) --1.8.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>
PATCH v5 6/7 acpi_memhotplug.c: bind the memory device when the driver is being loaded
In reply to Wen CongyangWe had introduced acpi_hotmem_initialized to avoid strange add_memory fail message. But the memory device may not be used by the kernel, and the device should be bound when the driver is being loaded. Remove acpi_hotmem_initialized to allow that the device can be bound when the driver is being loaded.
--- drivers/acpi/acpi_memhotplug.c | 12 ------------ 1 file changed, 12 deletions(-)
drivers/acpi/acpi_memhotplug.c +0 -12
@@ -87,8 +87,6 @@ struct acpi_memory_device {struct list_head res_list; }; -static int acpi_hotmem_initialized; -static acpi_status acpi_memory_get_resource (struct acpi_resource *resource,void *context) {
@@ -433,15 +431,6 @@ static int acpi_memory_device_add(struct acpi_device *device)printk (KERN_DEBUG "%s \n" ,acpi_device_name (device)); -/* -* Early boot code has recognized memory area by EFI/E820. -* If DSDT shows these memory devices on boot, hotplug is not necessary -* for them. So, it just returns until completion of this driver's -* start up. -*/ -if (!acpi_hotmem_initialized) -return 0 ; -if (!acpi_memory_check_device (mem_device)) {/* call add_memory func */ result =acpi_memory_enable_device (mem_device);
@@ -557,7 +546,6 @@ static int __init acpi_memory_device_init(void)return -ENODEV ; } - acpi_hotmem_initialized =1 ;return 0 ; }
Signature · 7 lines
1.8.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 v5 6/7] acpi_memhotplug.c: bind the memory device when the driver is being loaded
Quoted 19 lines · Wen Congyang
We had introduced
acpi_hotmem_initializedto avoid strangeadd_memoryfail message. But the memory device may not be used by the kernel, and the device should be bound when the driver is being loaded. Removeacpi_hotmem_initializedto allow that the device can be bound when the driver is being loaded.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 41 lines
drivers/acpi/acpi_memhotplug.c | 12 ------------ 1 file changed, 12 deletions(-)drivers/acpi/acpi_memhotplug.c +0
-12@@ -87,8 +87,6 @@ struct acpi_memory_device {struct list_head res_list; }; -static int acpi_hotmem_initialized; -static acpi_status acpi_memory_get_resource (struct acpi_resource *resource,void *context) {@@ -433,15 +431,6 @@ static int acpi_memory_device_add(struct acpi_device *device)printk (KERN_DEBUG "%s \n" ,acpi_device_name (device)); -/* -* Early boot code has recognized memory area by EFI/E820. -* If DSDT shows these memory devices on boot, hotplug is not necessary -* for them. So, it just returns until completion of this driver's -* start up. -*/ -if (!acpi_hotmem_initialized) -return 0 ; -if (!acpi_memory_check_device (mem_device)) {/* call add_memory func */ result =acpi_memory_enable_device (mem_device);@@ -557,7 +546,6 @@ static int __init acpi_memory_device_init(void)return -ENODEV ; } - acpi_hotmem_initialized =1 ;return 0 ; }
Re: [Patch v5 6/7] acpi_memhotplug.c: bind the memory device when the driver is being loaded
In reply to Wen CongyangQuoted 6 lines · Wen Congyang
We had introduced
acpi_hotmem_initializedto avoid strangeadd_memoryfail message. But the memory device may not be used by the kernel, and the device should be bound when the driver is being loaded. Removeacpi_hotmem_initializedto allow that the device can be bound when the driver is being loaded.
Quoted 13 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[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 v5 7/7 acpi_memhotplug.c: auto bind the memory device which is hotplugged before the driver is loaded
In reply to Wen CongyangIf the memory device is hotplugged before the driver is loaded, the user cannot see this device under the directory /sys/bus/acpi/devices/, and the user cannot bind it by hand after the driver is loaded. This patch introduces a new feature to bind such device when the driver is being loaded.
--- drivers/acpi/acpi_memhotplug.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)
drivers/acpi/acpi_memhotplug.c +36 -1
@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");#define MEMORY_POWER_ON_STATE 1#define MEMORY_POWER_OFF_STATE 2 +static bool auto_probe; +module_param (auto_probe, bool,S_IRUGO |S_IWUSR ); +static int acpi_memory_device_add (struct acpi_device *device);static int acpi_memory_device_remove (struct acpi_device *device,int type);
@@ -494,12 +497,44 @@ acpi_memory_register_notify_handler(acpi_handle handle, u32 level, void *ctxt, void **retv) { acpi_status status; - +struct acpi_memory_device *mem_device =NULL ; +unsigned long long current_status; status =is_memory_device (handle);if (ACPI_FAILURE (status))return AE_OK ;/* continue */ +if (auto_probe) { +/* Get device present/absent information from the _STA */ + status =acpi_evaluate_integer (handle,"_STA" ,NULL , + ¤t_status); +if (ACPI_FAILURE (status)) + goto install; + +/* +* Check for device status. Device should be +* present/enabled/functioning. +*/ +if (!(current_status & + (ACPI_STA_DEVICE_PRESENT |ACPI_STA_DEVICE_ENABLED | +ACPI_STA_DEVICE_FUNCTIONING ))) + goto install; + +if (acpi_memory_get_device (handle, &mem_device)) + goto install; + +/* We have bound this device while we register the driver */ +if (mem_device->state ==MEMORY_POWER_ON_STATE ) + goto install; + +ACPI_DEBUG_PRINT ((ACPI_DB_INFO , +"\nauto probe memory device\n" )); + +if (acpi_memory_enable_device (mem_device)) +pr_err (PREFIX "Cannot enable memory device\n" ); + } + +install: status =acpi_install_notify_handler (handle,ACPI_SYSTEM_NOTIFY , acpi_memory_device_notify,NULL );/* continue */
Signature · 7 lines
1.8.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 v5 7/7] acpi_memhotplug.c: auto bind the memory device which is hotplugged before the driver is loaded
Quoted 19 lines · Wen Congyang
If the memory device is hotplugged before the driver is loaded, the user cannot see this device under the directory
/sys/bus/acpi/devices/, and the user cannot bind it by hand after the driver is loaded. This patch introduces a new feature to bind such device when the driver is being loaded.CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>
Quoted 1 line
---
Thanks,
Yasuaki Ishimatsu
Quoted 54 lines
drivers/acpi/acpi_memhotplug.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)drivers/acpi/acpi_memhotplug.c +29
-1@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");#define MEMORY_POWER_ON_STATE 1#define MEMORY_POWER_OFF_STATE 2 +static bool auto_probe; +module_param (auto_probe, bool,S_IRUGO |S_IWUSR ); +static int acpi_memory_device_add (struct acpi_device *device);static int acpi_memory_device_remove (struct acpi_device *device,int type);@@ -494,12 +497,44 @@ acpi_memory_register_notify_handler(acpi_handle handle, u32 level, void *ctxt, void **retv) { acpi_status status; - +struct acpi_memory_device *mem_device =NULL ; +unsigned long long current_status; status =is_memory_device (handle);if (ACPI_FAILURE (status))return AE_OK ;/* continue */ +if (auto_probe) { +/* Get device present/absent information from the _STA */ + status =acpi_evaluate_integer (handle,"_STA" ,NULL , + ¤t_status); +if (ACPI_FAILURE (status)) + goto install; + +/* +* Check for device status. Device should be +* present/enabled/functioning. +*/ +if (!(current_status & + (ACPI_STA_DEVICE_PRESENT |ACPI_STA_DEVICE_ENABLED | +ACPI_STA_DEVICE_FUNCTIONING ))) + goto install; + +if (acpi_memory_get_device (handle, &mem_device)) + goto install; + +/* We have bound this device while we register the driver */ +if (mem_device->state ==MEMORY_POWER_ON_STATE ) + goto install; + + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
drivers/acpi/acpi_memhotplug.c acpi_memory_register_notify_handler(acpi_handle handle, · line 540
Quoted 10 lines
drivers/acpi/acpi_memhotplug.c +7
-0+ "\nauto probe memory device\n")); + +if (acpi_memory_enable_device (mem_device)) +pr_err (PREFIX "Cannot enable memory device\n" ); + } + +install: status =acpi_install_notify_handler (handle,ACPI_SYSTEM_NOTIFY , acpi_memory_device_notify,NULL );/* continue */
--
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 v5 7/7] acpi_memhotplug.c: auto bind the memory device which is hotplugged before the driver is loaded
In reply to Wen CongyangQuoted 5 lines · Wen Congyang
If the memory device is hotplugged before the driver is loaded, the user cannot see this device under the directory
/sys/bus/acpi/devices/, and the user cannot bind it by hand after the driver is loaded. This patch introduces a new feature to bind such device when the driver is being loaded.
Hi Wen,
While I can see the problem, I am a little concerned about this approach. If we go this way, all ACPI hotplug drivers need to do it on their own way and walk the entire ACPI namespace when they are installed. Such common issue should be dealt by ACPI core. I am wondering if we can simply set MEMORY_HOTPLUG to default y for now. Processor and Container are already set to y by default.
Thanks,
-Toshi
Quoted 77 lines
CC David Rientjes <[email protected]>CC Jiang Liu <[email protected]>CC Len Brown <[email protected]>CC Benjamin Herrenschmidt <[email protected]>CC Paul Mackerras <[email protected]>CC Christoph Lameter <[email protected]>Cc Minchan Kim <[email protected]>CC Andrew Morton <[email protected]>CC KOSAKI Motohiro <[email protected]>CC Yasuaki Ishimatsu <[email protected]>CC Rafael J. Wysocki <[email protected]>CC Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Wen Congyang <[email protected]>--- drivers/acpi/acpi_memhotplug.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-)drivers/acpi/acpi_memhotplug.c +36
-1@@ -52,6 +52,9 @@ MODULE_LICENSE("GPL");#define MEMORY_POWER_ON_STATE 1#define MEMORY_POWER_OFF_STATE 2 +static bool auto_probe; +module_param (auto_probe, bool,S_IRUGO |S_IWUSR ); +static int acpi_memory_device_add (struct acpi_device *device);static int acpi_memory_device_remove (struct acpi_device *device,int type);@@ -494,12 +497,44 @@ acpi_memory_register_notify_handler(acpi_handle handle, u32 level, void *ctxt, void **retv) { acpi_status status; - +struct acpi_memory_device *mem_device =NULL ; +unsigned long long current_status; status =is_memory_device (handle);if (ACPI_FAILURE (status))return AE_OK ;/* continue */ +if (auto_probe) { +/* Get device present/absent information from the _STA */ + status =acpi_evaluate_integer (handle,"_STA" ,NULL , + ¤t_status); +if (ACPI_FAILURE (status)) + goto install; + +/* +* Check for device status. Device should be +* present/enabled/functioning. +*/ +if (!(current_status & + (ACPI_STA_DEVICE_PRESENT |ACPI_STA_DEVICE_ENABLED | +ACPI_STA_DEVICE_FUNCTIONING ))) + goto install; + +if (acpi_memory_get_device (handle, &mem_device)) + goto install; + +/* We have bound this device while we register the driver */ +if (mem_device->state ==MEMORY_POWER_ON_STATE ) + goto install; + +ACPI_DEBUG_PRINT ((ACPI_DB_INFO , +"\nauto probe memory device\n" )); + +if (acpi_memory_enable_device (mem_device)) +pr_err (PREFIX "Cannot enable memory device\n" ); + } + +install: status =acpi_install_notify_handler (handle,ACPI_SYSTEM_NOTIFY , acpi_memory_device_notify,NULL );/* continue */
Quoted 7 lines · Wen Congyang
Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):54c4c7db6cb94d7d1217df6d7fca6847c61744ab2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225
So this is based on the acpi-general branch of git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git correct?
And the branch's HEAD commit 54c4c7db6cb9 ("ACPI / memory-hotplug: call acpi_bus_trim() to remove memory device") can be reverted before this series is applied?
Quoted 10 lines · David Rientjes
Quoted 7 lines · Wen Congyang
Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):54c4c7db6cb94d7d1217df6d7fca6847c61744ab2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225
Quoted 2 lines
So this is based on the acpi-general branch of git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git correct?
It should be based on that, yes.
Quoted 3 lines
And the branch's HEAD commit
54c4c7db6cb9("ACPI / memory-hotplug: callacpi_bus_trim()to remove memory device") can be reverted before this series is applied?
Why?
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 14 lines · Rafael J. Wysocki
Quoted 10 lines · David Rientjes
Quoted 7 lines · Wen Congyang
Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):54c4c7db6cb94d7d1217df6d7fca6847c61744ab2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225Quoted 2 lines
So this is based on the acpi-general branch of git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git correct?
Quoted 7 lines
It should be based on that, yes.
Quoted 3 lines
And the branch's HEAD commit
54c4c7db6cb9("ACPI / memory-hotplug: callacpi_bus_trim()to remove memory device") can be reverted before this series is applied?Why?
Ah, because of patch [2/7]. I wonder what tree this one is supposed to apply to. Surely not to linux-pm.git/acpi-general.
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>
Quoted 57 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct . Butacpi_memory_device_remove()has not implemented it yet.So the patch prepares the framework for hot removing memory and adds the framework into
acpi_memory_device_remove().We may hotremove the memory device by this 2 ways at the same time. So we remove the function
acpi_memory_disable_device(), and useacpi_bus_hot_remove_device()which is used by 2nd case to implement it. We lock device inacpi_bus_hot_remove_device(), so there is no need to add lock inacpi_memhotplug.The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):54c4c7db6cb94d7d1217df6d7fca6847c61744ab2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225Changes from v4 to v5:
1. patch2: new patch. useacpi_bus_hot_remove_device()to implement memory device hotremove.Changes from v3 to v4:
1. patch1: unlocklist_lockwhen removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queueacpi_memhotplug.c: fix memory leak when memory device is unbound from
the moduleacpi_memhotplug
acpi_memhotplug.c: free memory device ifacpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loaded
Quoted 3 lines
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next. I needed to fix up almost all of them so that they applied, so please check if my fixups make sense (and let me know ASAP if that's not the case).
If they are OK, please rebase the rest of the series on top of linux-pm.git/linux-next and repost. I'm not going to take any more patches that don't apply from you.
Moreover, I'm not going to take any more ACPI memory hotplug patches for v3.8 except for the [5-7/7] from this series (after they have been rebased and _if_ they apply), so please don't submit any until the v3.8 merge window closes (of course, you're free to post RFCs, but I will ignore them).
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Quoted 74 lines · Rafael J. Wysocki
Quoted 57 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct . Butacpi_memory_device_remove()has not implemented it yet.So the patch prepares the framework for hot removing memory and adds the framework into
acpi_memory_device_remove().We may hotremove the memory device by this 2 ways at the same time. So we remove the function
acpi_memory_disable_device(), and useacpi_bus_hot_remove_device()which is used by 2nd case to implement it. We lock device inacpi_bus_hot_remove_device(), so there is no need to add lock inacpi_memhotplug.The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):54c4c7db6cb94d7d1217df6d7fca6847c61744ab2. This patchset requires the following patch(It is in pm tree now)
https://lkml.org/lkml/2012/11/1/225Changes from v4 to v5:
1. patch2: new patch. useacpi_bus_hot_remove_device()to implement memory device hotremove.Changes from v3 to v4:
1. patch1: unlocklist_lockwhen removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queueacpi_memhotplug.c: fix memory leak when memory device is unbound from
the moduleacpi_memhotplug
acpi_memhotplug.c: free memory device ifacpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loadedQuoted 3 lines
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next. I needed to fix up almost all of them so that they applied, so please check if my fixups make sense (and let me know ASAP if that's not the case).
If they are OK, please rebase the rest of the series on top of linux-pm.git/linux-next and repost. I'm not going to take any more patches that don't apply from you.
Quoted 5 lines
Moreover, I'm not going to take any more ACPI memory hotplug patches for v3.8 except for the [5-7/7] from this series (after they have been rebased and _if_ they apply), so please don't submit any until the v3.8 merge window closes (of course, you're free to post RFCs, but I will ignore them).
And by the way, if someone gives a "Reviewed-by" to a patch that _obviously_ doesn't apply, I will ignore any "Reviewed-by" from that person going forward, because that quite obviously means you haven't even compared the patch with the existing code and thus your "review" is worthless.
If you just want to say you agree with the patch, use "Acked-by".
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>
Quoted 18 lines
Quoted 12 lines
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next. I needed to fix up almost all of them so that they applied, so please check if my fixups make sense (and let me know ASAP if that's not the case).
If they are OK, please rebase the rest of the series on top of linux-pm.git/linux-next and repost. I'm not going to take any more patches that don't apply from you.
Quoted 5 lines
Moreover, I'm not going to take any more ACPI memory hotplug patches for v3.8 except for the [5-7/7] from this series (after they have been rebased and _if_ they apply), so please don't submit any until the v3.8 merge window closes (of course, you're free to post RFCs, but I will ignore them).
Quoted 4 lines
And by the way, if someone gives a "Reviewed-by" to a patch that _obviously_ doesn't apply, I will ignore any "Reviewed-by" from that person going forward, because that quite obviously means you haven't even compared the patch with the existing code and thus your "review" is worthless.
I was able to apply all his patches on top of the Linus's tree...
Quoted 1 line
If you just want to say you agree with the patch, use "Acked-by".
Got it.
Thanks,
-Toshi
Quoted 4 lines
Thanks,
Rafael
Quoted 18 lines · Toshi Kani
Quoted 18 lines
Quoted 17 lines
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next. I needed to fix up almost all of them so that they applied, so please check if my fixups make sense (and let me know ASAP if that's not the case).
If they are OK, please rebase the rest of the series on top of linux-pm.git/linux-next and repost. I'm not going to take any more patches that don't apply from you.
Moreover, I'm not going to take any more ACPI memory hotplug patches for v3.8 except for the [5-7/7] from this series (after they have been rebased and _if_ they apply), so please don't submit any until the v3.8 merge window closes (of course, you're free to post RFCs, but I will ignore them).
Quoted 6 lines
Quoted 4 lines
And by the way, if someone gives a "Reviewed-by" to a patch that _obviously_ doesn't apply, I will ignore any "Reviewed-by" from that person going forward, because that quite obviously means you haven't even compared the patch with the existing code and thus your "review" is worthless.
I was able to apply all his patches on top of the Linus's tree...
Ah, that may be because of my mistake. Sorry about that.
I'll try again and see if that works (sigh).
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Hi Rafael,
Quoted 62 lines · Rafael J. Wysocki
Quoted 57 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct . Butacpi_memory_device_remove()has not implemented it yet.So the patch prepares the framework for hot removing memory and adds the framework into
acpi_memory_device_remove().We may hotremove the memory device by this 2 ways at the same time. So we remove the function
acpi_memory_disable_device(), and useacpi_bus_hot_remove_device()which is used by 2nd case to implement it. We lock device inacpi_bus_hot_remove_device(), so there is no need to add lock inacpi_memhotplug.The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):
54c4c7db6cb94d7d1217df6d7fca6847c61744ab
2. This patchset requires the following patch(It is in pm tree now)https://lkml.org/lkml/2012/11/1/225Changes from v4 to v5:
1. patch2: new patch. useacpi_bus_hot_remove_device()to implement memory device hotremove.Changes from v3 to v4:
1. patch1: unlocklist_lockwhen removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queueacpi_memhotplug.c: fix memory leak when memory device is unbound from
the moduleacpi_memhotplug
acpi_memhotplug.c: free memory device ifacpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loadedQuoted 3 lines
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()
Quoted 5 lines
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next.
I checked your tree and found a mistake.
You merged a following patch into your tree.
commitid:2ba281f1
ACPI / memory-hotplug: introduce a mutex lock to protect the list in acpi_memory_device
But it is wrong.
[1/7] patch is "acpi,memory-hotplug : add memory offline code to acpi_memory_device_remove()". So we would like you to merge it instead of commitid:2ba281f1.
Thanks,
Yasuaki Ishimatsu
Quoted 17 lines
I needed to fix up almost all of them so that they applied, so please check if my fixups make sense (and let me know ASAP if that's not the case).
If they are OK, please rebase the rest of the series on top of linux-pm.git/linux-next and repost. I'm not going to take any more patches that don't apply from you.
Moreover, I'm not going to take any more ACPI memory hotplug patches for v3.8 except for the [5-7/7] from this series (after they have been rebased and _if_ they apply), so please don't submit any until the v3.8 merge window closes (of course, you're free to post RFCs, but I will ignore them).
Thanks,
Rafael
Quoted 78 lines · Yasuaki Ishimatsu
Hi Rafael,
Quoted 62 lines · Rafael J. Wysocki
Quoted 57 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct . Butacpi_memory_device_remove()has not implemented it yet.So the patch prepares the framework for hot removing memory and adds the framework into
acpi_memory_device_remove().We may hotremove the memory device by this 2 ways at the same time. So we remove the function
acpi_memory_disable_device(), and useacpi_bus_hot_remove_device()which is used by 2nd case to implement it. We lock device inacpi_bus_hot_remove_device(), so there is no need to add lock inacpi_memhotplug.The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):
54c4c7db6cb94d7d1217df6d7fca6847c61744ab
2. This patchset requires the following patch(It is in pm tree now)https://lkml.org/lkml/2012/11/1/225Changes from v4 to v5:
1. patch2: new patch. useacpi_bus_hot_remove_device()to implement memory device hotremove.Changes from v3 to v4:
1. patch1: unlocklist_lockwhen removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queueacpi_memhotplug.c: fix memory leak when memory device is unbound from
the moduleacpi_memhotplug
acpi_memhotplug.c: free memory device ifacpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loadedQuoted 3 lines
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()Quoted 5 lines
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next.
I checked your tree and found a mistake.
You merged a following patch into your tree.commitid:2ba281f1
ACPI / memory-hotplug: introduce a mutex lock to protect the list inacpi_memory_device
Quoted 5 lines
But it is wrong.
[1/7] patch is "acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()". So we would like you to merge it instead of commitid:2ba281f1.
Yes, I've found it too.
Now applied patches [1-6/7], because I agree with Toshi Kani that patch [7/7] goes too far, so I'm not going to apply it.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Hi Rafael,
Quoted 81 lines · Rafael J. Wysocki
Quoted 80 lines · Yasuaki Ishimatsu
Hi Rafael,
Quoted 62 lines · Rafael J. Wysocki
Quoted 57 lines · Wen Congyang
The memory device can be removed by 2 ways:
1. send eject request by SCI
2. echo 1 >/sys/bus/pci/devices/PNP0C80:XX/ejectIn the 1st case,
acpi_memory_disable_device()will be called. In the 2nd case,acpi_memory_device_remove()will be called.acpi_memory_device_remove()will also be called when we unbind the memory device from the driveracpi_memhotplugor a driver initialization fails.
acpi_memory_disable_device()has already implemented a code which offlines memory and releasesacpi_memory_infostruct . Butacpi_memory_device_remove()has not implemented it yet.So the patch prepares the framework for hot removing memory and adds the framework into
acpi_memory_device_remove().We may hotremove the memory device by this 2 ways at the same time. So we remove the function
acpi_memory_disable_device(), and useacpi_bus_hot_remove_device()which is used by 2nd case to implement it. We lock device inacpi_bus_hot_remove_device(), so there is no need to add lock inacpi_memhotplug.The last version of this patchset is here:
https://lkml.org/lkml/2012/11/8/121Note:
1. The following commit in pm tree can be dropped now(The other two patches are already dropped):
54c4c7db6cb94d7d1217df6d7fca6847c61744ab
2. This patchset requires the following patch(It is in pm tree now)https://lkml.org/lkml/2012/11/1/225Changes from v4 to v5:
1. patch2: new patch. useacpi_bus_hot_remove_device()to implement memory device hotremove.Changes from v3 to v4:
1. patch1: unlocklist_lockwhen removing memory fails.
2. patch2: just rebase them
3. patch3-7: these patches are in -mm tree, and they conflict with this patchset, so Adrew Morton drop them from -mm tree. I rebase and merge them into this patchset.Wen Congyang (6):
acpi,memory-hotplug: deal with eject request in hotplug queueacpi_memhotplug.c: fix memory leak when memory device is unbound from
the moduleacpi_memhotplug
acpi_memhotplug.c: free memory device ifacpi_memory_enable_device()
failed
acpi_memhotplug.c: don't allow to eject the memory device if it is
being used
acpi_memhotplug.c: bind the memory device when the driver is being
loaded
acpi_memhotplug.c: auto bind the memory device which is hotplugged
before the driver is loadedQuoted 3 lines
Yasuaki Ishimatsu (1):
acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()Quoted 5 lines
Well, I have tried _really_ hard to apply this patchset, but pretty much none of the patches except for [1/7] applied for me. I have no idea what tree they are against, but I'm pretty sure it's not my tree.
I _have_ applied patches [1-4/7] and pushed them to linux-pm.git/linux-next.
I checked your tree and found a mistake.
You merged a following patch into your tree.commitid:2ba281f1
ACPI / memory-hotplug: introduce a mutex lock to protect the list inacpi_memory_deviceBut it is wrong.
Quoted 8 lines
Quoted 3 lines
[1/7] patch is "acpi,memory-hotplug : add memory offline code to
acpi_memory_device_remove()". So we would like you to merge it instead of commitid:2ba281f1.Yes, I've found it too.
Now applied patches [1-6/7], because I agree with Toshi Kani that patch [7/7] goes too far, so I'm not going to apply it.
I confirmed that patches were merged into your tree correctly.
Thanks,
Yasuaki Ishimatsu
Quoted 5 lines
Thanks,
Rafael