* [PATCH -next v2 0/5] Optimize and bugfix for notifier error
@ 2022-09-15 8:57 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
` (4 more replies)
0 siblings, 5 replies; 8+ 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
1. Fix non-working usage of negative values
2. Add checking after online or offline
3. Restore memory before exit
4. Correct test's name
Changes in v2:
- Replace 'online_all_hot_pluggable_memory'
with 'online_all_offline_memory()'.
- Collect Reviewed-by tags from David Hildenbrand.
Zhao Gongyi (5):
docs: notifier-error-inject: fix non-working usage of negative values
selftests/memory-hotplug: Use 'printf' instead of 'echo'
selftests/memory-hotplug: Add checking after online or offline
selftests/memory-hotplug: Restore memory before exit
docs: notifier-error-inject: Correct test's name
.../fault-injection/notifier-error-inject.rst | 14 ++++---
.../memory-hotplug/mem-on-off-test.sh | 37 +++++++++++++++----
2 files changed, 39 insertions(+), 12 deletions(-)
--
2.17.1
^ permalink raw reply [flat|nested] 8+ 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
2022-09-15 8:57 ` [PATCH -next v2 2/5] selftests/memory-hotplug: Use 'printf' instead of 'echo' Zhao Gongyi
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ 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] 8+ messages in thread
* [PATCH -next v2 2/5] selftests/memory-hotplug: Use 'printf' instead of 'echo'
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-15 8:57 ` Zhao Gongyi
2022-09-15 8:57 ` [PATCH -next v2 3/5] selftests/memory-hotplug: Add checking after online or offline Zhao Gongyi
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ 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 errors:
# sh mem-on-off-test.sh
...
mem-on-off-test.sh: line 267: echo: write error: Invalid argument
...
mem-on-off-test.sh: line 283: echo: write error: Invalid argument
...
#
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
tools/testing/selftests/memory-hotplug/mem-on-off-test.sh | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
index 46a97f318f58..f1a9d81b934c 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -264,7 +264,8 @@ done
#
# Test memory hot-add error handling (offline => online)
#
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
+printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/erro
+
for memory in `hotpluggable_offline_memory`; do
online_memory_expect_fail $memory
done
@@ -280,7 +281,7 @@ done
#
# Test memory hot-remove error handling (online => offline)
#
-echo $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
+printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
for memory in `hotpluggable_online_memory`; do
if [ $((RANDOM % 100)) -lt $ratio ]; then
offline_memory_expect_fail $memory
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH -next v2 3/5] selftests/memory-hotplug: Add checking after online or offline
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-15 8:57 ` [PATCH -next v2 2/5] selftests/memory-hotplug: Use 'printf' instead of 'echo' Zhao Gongyi
@ 2022-09-15 8:57 ` 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
4 siblings, 0 replies; 8+ 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
Add checking for online_memory_expect_success()/
offline_memory_expect_success()/offline_memory_expect_fail(), or
the test would exit 0 although the functions return 1.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
.../memory-hotplug/mem-on-off-test.sh | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
index f1a9d81b934c..3bdf3c4d6d06 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -267,7 +267,11 @@ done
printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/erro
for memory in `hotpluggable_offline_memory`; do
- online_memory_expect_fail $memory
+ online_memory_expect_fail $memory || {
+ echo "online memory $memory: unexpected success"
+ retval=1
+ }
+
done
#
@@ -275,7 +279,11 @@ done
#
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
for memory in `hotpluggable_offline_memory`; do
- online_memory_expect_success $memory
+ online_memory_expect_success $memory || {
+ echo "online memory $memory: unexpected fail"
+ retval=1
+ }
+
done
#
@@ -284,7 +292,11 @@ done
printf %#x $error > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
for memory in `hotpluggable_online_memory`; do
if [ $((RANDOM % 100)) -lt $ratio ]; then
- offline_memory_expect_fail $memory
+ offline_memory_expect_fail $memory || {
+ echo "offline memory $memory: unexpected success"
+ retval=1
+ }
+
fi
done
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH -next v2 4/5] selftests/memory-hotplug: Restore memory before exit
2022-09-15 8:57 [PATCH -next v2 0/5] Optimize and bugfix for notifier error Zhao Gongyi
` (2 preceding siblings ...)
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 ` Zhao Gongyi
2022-09-15 8:57 ` [PATCH -next v2 5/5] docs: notifier-error-inject: Correct test's name Zhao Gongyi
4 siblings, 0 replies; 8+ 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
Some momory will be left in offline state when calling
offline_memory_expect_fail() failed. Restore it before exit.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
---
.../memory-hotplug/mem-on-off-test.sh | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
index 3bdf3c4d6d06..c620adf33629 100755
--- a/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
+++ b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
@@ -134,6 +134,17 @@ offline_memory_expect_fail()
return 0
}
+online_all_offline_memory()
+{
+
+ for memory in `hotpluggable_offline_memory`; do
+ online_memory_expect_success $memory || {
+ echo "online memory $memory: unexpected fail"
+ retval=1
+ }
+ done
+}
+
error=-12
priority=0
# Run with default of ratio=2 for Kselftest run
@@ -278,13 +289,7 @@ done
# Online all hot-pluggable memory
#
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_ONLINE/error
-for memory in `hotpluggable_offline_memory`; do
- online_memory_expect_success $memory || {
- echo "online memory $memory: unexpected fail"
- retval=1
- }
-
-done
+online_all_offline_memory
#
# Test memory hot-remove error handling (online => offline)
@@ -303,4 +308,9 @@ done
echo 0 > $NOTIFIER_ERR_INJECT_DIR/actions/MEM_GOING_OFFLINE/error
/sbin/modprobe -q -r memory-notifier-error-inject
+#
+# Restore memory before exit
+#
+online_all_offline_memory
+
exit $retval
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH -next v2 5/5] docs: notifier-error-inject: Correct test's name
2022-09-15 8:57 [PATCH -next v2 0/5] Optimize and bugfix for notifier error Zhao Gongyi
` (3 preceding siblings ...)
2022-09-15 8:57 ` [PATCH -next v2 4/5] selftests/memory-hotplug: Restore memory before exit Zhao Gongyi
@ 2022-09-15 8:57 ` Zhao Gongyi
4 siblings, 0 replies; 8+ 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
Correct test's name for mem-on-off-test.sh/cpu-on-off-test.sh.
Signed-off-by: Zhao Gongyi <zhaogongyi@huawei.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
---
Documentation/fault-injection/notifier-error-inject.rst | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Documentation/fault-injection/notifier-error-inject.rst b/Documentation/fault-injection/notifier-error-inject.rst
index 0e2790122166..170c583eb5bc 100644
--- a/Documentation/fault-injection/notifier-error-inject.rst
+++ b/Documentation/fault-injection/notifier-error-inject.rst
@@ -95,8 +95,8 @@ For more usage examples
There are tools/testing/selftests using the notifier error injection features
for CPU and memory notifiers.
- * tools/testing/selftests/cpu-hotplug/on-off-test.sh
- * tools/testing/selftests/memory-hotplug/on-off-test.sh
+ * tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
+ * tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
These scripts first do simple online and offline tests and then do fault
injection tests if notifier error injection module is available.
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ 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; 8+ 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] 8+ 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; 8+ 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] 8+ messages in thread
end of thread, other threads:[~2022-09-19 8:43 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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.