Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1473413 > unrolled thread
| Started by | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| First post | 2016-08-31 14:30 +0200 |
| Last post | 2016-08-31 16:40 +0200 |
| Articles | 12 — 4 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH v2] memory-hotplug: fix store_mem_state() return value Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-31 14:30 +0200
Re: [PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-08-31 16:40 +0200
Re: [PATCH v2] memory-hotplug: fix store_mem_state() return value Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-08-31 17:10 +0200
[RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-08-31 17:50 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Andrew Morton <akpm@linux-foundation.org> - 2016-08-31 22:30 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value David Rientjes <rientjes@google.com> - 2016-08-31 23:10 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-09-01 01:40 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value David Rientjes <rientjes@google.com> - 2016-09-01 02:10 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-09-01 02:20 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value David Rientjes <rientjes@google.com> - 2016-09-01 02:30 +0200
Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-09-01 04:00 +0200
[RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value Reza Arbab <arbab@linux.vnet.ibm.com> - 2016-08-31 16:40 +0200
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-08-31 14:30 +0200 |
| Subject | Re: [PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <sccOt-2m4-13@gated-at.bofh.it> |
On Thu, May 26, 2016 at 09:43:04AM -0500, Reza Arbab wrote: > Hi Greg, > > On Thu, May 05, 2016 at 02:07:24PM -0500, Reza Arbab wrote: > > $ 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. > > I can't find where this might have been committed. Am I being impatient, or > did it slip through the cracks? I think it fell through, can you resend it and cc: all of the people involved in this subsystem, like you did for your other patch series? thanks, greg k-h
[toc] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-08-31 16:40 +0200 |
| Message-ID | <sceQh-3B0-1@gated-at.bofh.it> |
| In reply to | #1473413 |
On Wed, Aug 31, 2016 at 02:21:28PM +0200, Greg Kroah-Hartman wrote: >> I can't find where this might have been committed. Am I being >> impatient, or did it slip through the cracks? > >I think it fell through, can you resend it and cc: all of the people >involved in this subsystem, like you did for your other patch series? I can resend, but I'm not sure what you mean by the rest--this was a singleton patch, and you're the only one listed by get_maintainer.pl: $ scripts/get_maintainer.pl drivers/base/memory.c Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:DRIVER CORE, KOBJECTS, DEBUGFS, KERNFS AND SYSFS) linux-kernel@vger.kernel.org (open list) -- Reza Arbab
[toc] | [prev] | [next] | [standalone]
| From | Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
|---|---|
| Date | 2016-08-31 17:10 +0200 |
| Message-ID | <scfjk-40K-55@gated-at.bofh.it> |
| In reply to | #1473543 |
On Wed, Aug 31, 2016 at 09:37:55AM -0500, Reza Arbab wrote: > On Wed, Aug 31, 2016 at 02:21:28PM +0200, Greg Kroah-Hartman wrote: > > > I can't find where this might have been committed. Am I being > > > impatient, or did it slip through the cracks? > > > > I think it fell through, can you resend it and cc: all of the people > > involved in this subsystem, like you did for your other patch series? > > I can resend, but I'm not sure what you mean by the rest--this was a > singleton patch, and you're the only one listed by get_maintainer.pl: > > $ scripts/get_maintainer.pl drivers/base/memory.c > Greg Kroah-Hartman <gregkh@linuxfoundation.org> (supporter:DRIVER CORE, KOBJECTS, DEBUGFS, KERNFS AND SYSFS) > linux-kernel@vger.kernel.org (open list) You sent in other memory-hotplug patches that got merged through the -mm tree. I suggest doing that here as well, as those developers know this code much better than I do. thanks, greg k-h
[toc] | [prev] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-08-31 17:50 +0200 |
| Subject | [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <scfW2-4eb-21@gated-at.bofh.it> |
| In reply to | #1473596 |
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. Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com> --- Andrew et al, Greg asked that this come in through the -mm tree, as you know this code better than him. drivers/base/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 1cea0ba..8e385ea 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -359,7 +359,7 @@ store_mem_state(struct device *dev, err: unlock_device_hotplug(); - if (ret) + if (ret < 0) return ret; return count; } -- 1.8.3.1
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2016-08-31 22:30 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <sckiZ-74j-27@gated-at.bofh.it> |
| In reply to | #1473624 |
On Wed, 31 Aug 2016 10:44:01 -0500 Reza Arbab <arbab@linux.vnet.ibm.com> wrote: > 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?
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-08-31 23:10 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <sckVJ-7wC-35@gated-at.bofh.it> |
| In reply to | #1473831 |
On Wed, 31 Aug 2016, Andrew Morton wrote: > > 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.
[toc] | [prev] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-09-01 01:40 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <scngR-sq-3@gated-at.bofh.it> |
| In reply to | #1473883 |
On Wed, Aug 31, 2016 at 02:06:14PM -0700, David Rientjes wrote: >The correct fix is for store_mem_state() to return -EINVAL when >device_online() returns non-zero. Let me put it to you this way--which one of these sysfs operations is behaving correctly? # cd /sys/devices/system/memory/memory0 # cat online 1 # echo 1 > online; echo $? 0 or # cd /sys/devices/system/memory/memory0 # cat state online # echo online > state; echo $? -bash: echo: write error: Invalid argument 1 One of them should change to match the other. -- Reza Arbab
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-09-01 02:10 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <scnJT-Ri-3@gated-at.bofh.it> |
| In reply to | #1473968 |
On Wed, 31 Aug 2016, Reza Arbab wrote:
> > The correct fix is for store_mem_state() to return -EINVAL when
> > device_online() returns non-zero.
>
> Let me put it to you this way--which one of these sysfs operations is behaving
> correctly?
>
> # cd /sys/devices/system/memory/memory0
> # cat online
> 1
> # echo 1 > online; echo $?
> 0
>
> or
>
> # cd /sys/devices/system/memory/memory0
> # cat state
> online
> # echo online > state; echo $?
> -bash: echo: write error: Invalid argument
> 1
>
> One of them should change to match the other.
>
Nope, the return value of changing state from online to online was
established almost 11 years ago in commit 3947be1969a9. This was broken
by commit fa2be40fe7c0 ("drivers: base: use standard device online/offline
for state change") which was not intended to introduce a functional
change, but it did (memory_block_change_state() would have returned
EINVAL, device_online() does not).
[toc] | [prev] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-09-01 02:20 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <scnTz-UF-1@gated-at.bofh.it> |
| In reply to | #1473976 |
On Wed, Aug 31, 2016 at 05:03:25PM -0700, David Rientjes wrote: >Nope, the return value of changing state from online to online was >established almost 11 years ago in commit 3947be1969a9. Fair enough. So if online-to-online is -EINVAL, 1. Shouldn't 'echo 1 > online' then also return -EINVAL? 2. store_mem_state() still needs a tweak, right? It was only returning -EINVAL by accident, due to the convoluted sequence I listed in the patch. -- Reza Arbab
[toc] | [prev] | [next] | [standalone]
| From | David Rientjes <rientjes@google.com> |
|---|---|
| Date | 2016-09-01 02:30 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <sco3f-Yp-1@gated-at.bofh.it> |
| In reply to | #1473978 |
On Wed, 31 Aug 2016, Reza Arbab wrote: > > Nope, the return value of changing state from online to online was > > established almost 11 years ago in commit 3947be1969a9. > > Fair enough. So if online-to-online is -EINVAL, online-to-online for state is -EINVAL, it has been since 2005. > 1. Shouldn't 'echo 1 > online' then also return -EINVAL? > No, it's a different tunable. There's no requirement that two different tunables that do a similar thing have the same return values: the former existed long before device_online() and still exists for backwards compatibility. > 2. store_mem_state() still needs a tweak, right? It was only returning -EINVAL > by accident, due to the convoluted sequence I listed in the patch. > Yes, absolutely. It returning -EINVAL for "nline" is what is accidently preserving it's backwards compatibility :) Note that device_online() returns 1 if already online and memory_subsys_online() returns 0 if online in this case. So we want store_mem_state() to return -EINVAL if device_online() returns non-zero (this was in my first email).
[toc] | [prev] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-09-01 04:00 +0200 |
| Subject | Re: [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <scpsl-1In-9@gated-at.bofh.it> |
| In reply to | #1473980 |
On Wed, Aug 31, 2016 at 05:28:26PM -0700, David Rientjes wrote: >> 2. store_mem_state() still needs a tweak, right? It was only >> returning -EINVAL by accident, due to the convoluted sequence I >> listed in the patch. > >Yes, absolutely. It returning -EINVAL for "nline" is what is accidently >preserving it's backwards compatibility :) Note that device_online() >returns 1 if already online and memory_subsys_online() returns 0 if online >in this case. So we want store_mem_state() to return -EINVAL if >device_online() returns non-zero (this was in my first email). I'll spin a v3 patch to do this. Thank you for your review! -- Reza Arbab
[toc] | [prev] | [next] | [standalone]
| From | Reza Arbab <arbab@linux.vnet.ibm.com> |
|---|---|
| Date | 2016-08-31 16:40 +0200 |
| Subject | [RESEND PATCH v2] memory-hotplug: fix store_mem_state() return value |
| Message-ID | <sceQh-3B0-9@gated-at.bofh.it> |
| In reply to | #1473413 |
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. Signed-off-by: Reza Arbab <arbab@linux.vnet.ibm.com> --- drivers/base/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 1cea0ba..8e385ea 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -359,7 +359,7 @@ store_mem_state(struct device *dev, err: unlock_device_hotplug(); - if (ret) + if (ret < 0) return ret; return count; } -- 1.8.3.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web