All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhao Gongyi <zhaogongyi@huawei.com>
To: <linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-mm@kvack.org>, <linux-kselftest@vger.kernel.org>
Cc: <akinobu.mita@gmail.com>, <corbet@lwn.net>, <david@redhat.com>,
	<osalvador@suse.de>, <shuah@kernel.org>,
	Zhao Gongyi <zhaogongyi@huawei.com>
Subject: [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values
Date: Thu, 15 Sep 2022 16:57:53 +0800	[thread overview]
Message-ID: <20220915085757.258608-2-zhaogongyi@huawei.com> (raw)
In-Reply-To: <20220915085757.258608-1-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.

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


  reply	other threads:[~2022-09-15  9:02 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2022-09-17  5:39   ` [PATCH -next v2 1/5] docs: notifier-error-inject: fix non-working usage of negative values Akinobu Mita
2022-09-19  8:43     ` David Hildenbrand
2022-09-15  8:57 ` [PATCH -next v2 2/5] selftests/memory-hotplug: Use 'printf' instead of 'echo' Zhao Gongyi
2022-09-15  8:57 ` [PATCH -next v2 3/5] selftests/memory-hotplug: Add checking after online or offline Zhao Gongyi
2022-09-15  8:57 ` [PATCH -next v2 4/5] selftests/memory-hotplug: Restore memory before exit Zhao Gongyi
2022-09-15  8:57 ` [PATCH -next v2 5/5] docs: notifier-error-inject: Correct test's name Zhao Gongyi
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220915085757.258608-2-zhaogongyi@huawei.com \
    --to=zhaogongyi@huawei.com \
    --cc=akinobu.mita@gmail.com \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=osalvador@suse.de \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.