linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
@ 2022-09-19  9:01 zhaogongyi
  2022-09-19 11:05 ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: zhaogongyi @ 2022-09-19  9:01 UTC (permalink / raw)
  To: David Hildenbrand, Akinobu Mita
  Cc: linux-doc, LKML, linux-mm, linux-kselftest, Jonathan Corbet,
	osalvador, shuah

Hi!

> 
> On 17.09.22 07:39, Akinobu Mita wrote:
> > 2022年9月15日(木) 18:01 Zhao Gongyi <zhaogongyi@huawei.com>:
> >>
> >> Fault injection uses debugfs in a way that the provided values via
> >> sysfs are interpreted as u64. Providing negative numbers results in
> >> an error:
> >>
> >>    # cd sys/kernel/debug/notifier-error-inject/memory
> >>    #  echo -12 > actions/MEM_GOING_ONLINE/error
> >>    -bash: echo: write error: Invalid argument
> >>
> >> Update the docs and examples to use "printf %#x <val>" in these cases.
> >
> > I'd rather fix the notifier-error-inject module than change the user
> interface.
> > I'll send a patch, so could you check if that solves the problem.
> >
> 
> That will also make patch #2 unnecessary, correct?

Yes. But there is another commit 005747526d4f3c2ec995891e95cb7625161022f9 that has the same problem.

Thanks!

> 
> --
> Thanks,
> 
> David / dhildenb


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
  2022-09-19  9:01 [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values zhaogongyi
@ 2022-09-19 11:05 ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-09-19 11:05 UTC (permalink / raw)
  To: zhaogongyi, Akinobu Mita
  Cc: linux-doc, LKML, linux-mm, linux-kselftest, Jonathan Corbet,
	osalvador, shuah

On 19.09.22 11:01, zhaogongyi wrote:
> Hi!
> 
>>
>> On 17.09.22 07:39, Akinobu Mita wrote:
>>> 2022年9月15日(木) 18:01 Zhao Gongyi <zhaogongyi@huawei.com>:
>>>>
>>>> Fault injection uses debugfs in a way that the provided values via
>>>> sysfs are interpreted as u64. Providing negative numbers results in
>>>> an error:
>>>>
>>>>     # cd sys/kernel/debug/notifier-error-inject/memory
>>>>     #  echo -12 > actions/MEM_GOING_ONLINE/error
>>>>     -bash: echo: write error: Invalid argument
>>>>
>>>> Update the docs and examples to use "printf %#x <val>" in these cases.
>>>
>>> I'd rather fix the notifier-error-inject module than change the user
>> interface.
>>> I'll send a patch, so could you check if that solves the problem.
>>>
>>
>> That will also make patch #2 unnecessary, correct?
> 
> Yes. But there is another commit 005747526d4f3c2ec995891e95cb7625161022f9 that has the same problem.
> 
> Thanks!

Right. See my reply to the other patch:

https://lkml.kernel.org/r/93c044ca-7d2f-e23f-8eb4-72c133737a15@redhat.com

simple_attr_read()/simple_attr_write() fmt behavior is odd.

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
  2022-09-17  5:39   ` Akinobu Mita
@ 2022-09-19  8:43     ` David Hildenbrand
  0 siblings, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2022-09-19  8:43 UTC (permalink / raw)
  To: Akinobu Mita, Zhao Gongyi
  Cc: linux-doc, LKML, linux-mm, linux-kselftest, Jonathan Corbet,
	osalvador, shuah

On 17.09.22 07:39, Akinobu Mita wrote:
> 2022年9月15日(木) 18:01 Zhao Gongyi <zhaogongyi@huawei.com>:
>>
>> Fault injection uses debugfs in a way that the provided values via
>> sysfs are interpreted as u64. Providing negative numbers results in
>> an error:
>>
>>    # cd sys/kernel/debug/notifier-error-inject/memory
>>    #  echo -12 > actions/MEM_GOING_ONLINE/error
>>    -bash: echo: write error: Invalid argument
>>
>> Update the docs and examples to use "printf %#x <val>" in these cases.
> 
> I'd rather fix the notifier-error-inject module than change the user interface.
> I'll send a patch, so could you check if that solves the problem.
> 

That will also make patch #2 unnecessary, correct?

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
  2022-09-15  8:57 ` [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values Zhao Gongyi
@ 2022-09-17  5:39   ` Akinobu Mita
  2022-09-19  8:43     ` David Hildenbrand
  0 siblings, 1 reply; 5+ messages in thread
From: Akinobu Mita @ 2022-09-17  5:39 UTC (permalink / raw)
  To: Zhao Gongyi
  Cc: linux-doc, LKML, linux-mm, linux-kselftest, Jonathan Corbet,
	david, osalvador, shuah

2022年9月15日(木) 18:01 Zhao Gongyi <zhaogongyi@huawei.com>:
>
> Fault injection uses debugfs in a way that the provided values via
> sysfs are interpreted as u64. Providing negative numbers results in
> an error:
>
>   # cd sys/kernel/debug/notifier-error-inject/memory
>   #  echo -12 > actions/MEM_GOING_ONLINE/error
>   -bash: echo: write error: Invalid argument
>
> Update the docs and examples to use "printf %#x <val>" in these cases.

I'd rather fix the notifier-error-inject module than change the user interface.
I'll send a patch, so could you check if that solves the problem.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
  2022-09-15  8:57 [PATCH -next v2 0/5] Optimize and bugfix for notifier error Zhao Gongyi
@ 2022-09-15  8:57 ` Zhao Gongyi
  2022-09-17  5:39   ` Akinobu Mita
  0 siblings, 1 reply; 5+ messages in thread
From: Zhao Gongyi @ 2022-09-15  8:57 UTC (permalink / raw)
  To: linux-doc, linux-kernel, linux-mm, linux-kselftest
  Cc: akinobu.mita, corbet, david, osalvador, shuah, Zhao Gongyi

Fault injection uses debugfs in a way that the provided values via
sysfs are interpreted as u64. Providing negative numbers results in
an error:

  # cd sys/kernel/debug/notifier-error-inject/memory
  #  echo -12 > actions/MEM_GOING_ONLINE/error
  -bash: echo: write error: Invalid argument

Update the docs and examples to use "printf %#x <val>" in these cases.

Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
 .../fault-injection/notifier-error-inject.rst          | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/Documentation/fault-injection/notifier-error-inject.rst b/Documentation/fault-injection/notifier-error-inject.rst
index 1668b6e48d3a..0e2790122166 100644
--- a/Documentation/fault-injection/notifier-error-inject.rst
+++ b/Documentation/fault-injection/notifier-error-inject.rst
@@ -11,6 +11,10 @@ modules that can be used to test the following notifiers.
  * powerpc pSeries reconfig notifier
  * Netdevice notifier

+Note that the interface only accepts unsigned values. So, if you want
+to use a negative errno, you'd better use 'printf' instead of 'echo', e.g.:
+$ printf %#x -12 > actions/PM_SUSPEND_PREPARE/error
+
 PM notifier error injection module
 ----------------------------------
 This feature is controlled through debugfs interface
@@ -26,7 +30,7 @@ Possible PM notifier events to be failed are:
 Example: Inject PM suspend error (-12 = -ENOMEM)::

 	# cd /sys/kernel/debug/notifier-error-inject/pm/
-	# echo -12 > actions/PM_SUSPEND_PREPARE/error
+	# printf %#x -12 > actions/PM_SUSPEND_PREPARE/error
 	# echo mem > /sys/power/state
 	bash: echo: write error: Cannot allocate memory

@@ -44,7 +48,7 @@ Possible memory notifier events to be failed are:
 Example: Inject memory hotplug offline error (-12 == -ENOMEM)::

 	# cd /sys/kernel/debug/notifier-error-inject/memory
-	# echo -12 > actions/MEM_GOING_OFFLINE/error
+	# printf %#x -12 > actions/MEM_GOING_OFFLINE/error
 	# echo offline > /sys/devices/system/memory/memoryXXX/state
 	bash: echo: write error: Cannot allocate memory

@@ -82,7 +86,7 @@ Netdevice notifier events which can be failed are:
 Example: Inject netdevice mtu change error (-22 == -EINVAL)::

 	# cd /sys/kernel/debug/notifier-error-inject/netdev
-	# echo -22 > actions/NETDEV_CHANGEMTU/error
+	# printf %#x -22 > actions/NETDEV_CHANGEMTU/error
 	# ip link set eth0 mtu 1024
 	RTNETLINK answers: Invalid argument

--
2.17.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-09-19 11:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19  9:01 [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values zhaogongyi
2022-09-19 11:05 ` David Hildenbrand
  -- strict thread matches above, loose matches on Subject: below --
2022-09-15  8:57 [PATCH -next v2 0/5] Optimize and bugfix for notifier error Zhao Gongyi
2022-09-15  8:57 ` [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values Zhao Gongyi
2022-09-17  5:39   ` Akinobu Mita
2022-09-19  8:43     ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).