diff mbox series

[-next,v2,1/5] docs: notifier-error-inject: fix non-working usage of negative values

Message ID 20220915085757.258608-2-zhaogongyi@huawei.com (mailing list archive)
State Superseded
Headers show
Series Optimize and bugfix for notifier error | expand

Commit Message

Zhao Gongyi Sept. 15, 2022, 8:57 a.m. UTC
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(-)

--
2.17.1

Comments

Akinobu Mita Sept. 17, 2022, 5:39 a.m. UTC | #1
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.
David Hildenbrand Sept. 19, 2022, 8:43 a.m. UTC | #2
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?
diff mbox series

Patch

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