Thread (8 messages) 8 messages, 3 authors, 2016-09-01

Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value

From: David Rientjes <rientjes@google.com>
Date: 2016-08-31 21:07:50
Also in: lkml

On Wed, 31 Aug 2016, Andrew Morton wrote:
quoted
Attempting to online memory which is already online will cause this:

1. store_mem_state() called with buf="online"
2. device_online() returns 1 because device is already online
3. store_mem_state() returns 1
4. calling code interprets this as 1-byte buffer read
5. store_mem_state() called again with buf="nline"
6. store_mem_state() returns -EINVAL

Example:

$ cat /sys/devices/system/memory/memory0/state
online
$ echo online > /sys/devices/system/memory/memory0/state
-bash: echo: write error: Invalid argument

Fix the return value of store_mem_state() so this doesn't happen.
So..  what *does* happen after the patch?  Is some sort of failure still
reported?  Or am I correct in believing that the operation will appear
to have succeeded?  If so, is that desirable?
It's not desirable, before commit 4f3549d72 this would have returned 
EINVAL since __memory_block_change_state() does not see the state as 
MEM_OFFLINE when the write is done.  The correct fix is for 
store_mem_state() to return -EINVAL when device_online() returns non-zero.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help