* [PATCH] docs: fault-injection: fix non-working usage of negative values
@ 2021-06-03 12:58 Wolfram Sang
2021-06-03 13:27 ` Geert Uytterhoeven
2021-06-14 21:58 ` Jonathan Corbet
0 siblings, 2 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-06-03 12:58 UTC (permalink / raw)
To: linux-kernel
Cc: linux-renesas-soc, Wolfram Sang, Akinobu Mita, Jonathan Corbet,
linux-doc
Fault injection uses debugfs in a way that the provided values via sysfs
are interpreted as u64. Providing negative numbers results in an error:
/sys/kernel/debug/fail_function# echo -1 > times
sh: write error: Invalid argument
Update the docs and examples to use "printf %#x <val>" in these cases.
For "retval", reword the paragraph a little and fix a typo.
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
.../fault-injection/fault-injection.rst | 24 +++++++++++--------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/Documentation/fault-injection/fault-injection.rst b/Documentation/fault-injection/fault-injection.rst
index 31ecfe44e5b4..f47d05ed0d94 100644
--- a/Documentation/fault-injection/fault-injection.rst
+++ b/Documentation/fault-injection/fault-injection.rst
@@ -78,8 +78,10 @@ configuration of fault-injection capabilities.
- /sys/kernel/debug/fail*/times:
- specifies how many times failures may happen at most.
- A value of -1 means "no limit".
+ specifies how many times failures may happen at most. A value of -1
+ means "no limit". Note, though, that this file only accepts unsigned
+ values. So, if you want to specify -1, you better use 'printf' instead
+ of 'echo', e.g.: $ printf %#x -1 > times
- /sys/kernel/debug/fail*/space:
@@ -167,11 +169,13 @@ configuration of fault-injection capabilities.
- ERRNO: retval must be -1 to -MAX_ERRNO (-4096).
- ERR_NULL: retval must be 0 or -1 to -MAX_ERRNO (-4096).
-- /sys/kernel/debug/fail_function/<functiuon-name>/retval:
+- /sys/kernel/debug/fail_function/<function-name>/retval:
- specifies the "error" return value to inject to the given
- function for given function. This will be created when
- user specifies new injection entry.
+ specifies the "error" return value to inject to the given function.
+ This will be created when the user specifies a new injection entry.
+ Note that this file only accepts unsigned values. So, if you want to
+ use a negative errno, you better use 'printf' instead of 'echo', e.g.:
+ $ printf %#x -12 > retval
Boot option
^^^^^^^^^^^
@@ -255,7 +259,7 @@ Application Examples
echo Y > /sys/kernel/debug/$FAILTYPE/task-filter
echo 10 > /sys/kernel/debug/$FAILTYPE/probability
echo 100 > /sys/kernel/debug/$FAILTYPE/interval
- echo -1 > /sys/kernel/debug/$FAILTYPE/times
+ printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
echo 0 > /sys/kernel/debug/$FAILTYPE/space
echo 2 > /sys/kernel/debug/$FAILTYPE/verbose
echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -309,7 +313,7 @@ Application Examples
echo N > /sys/kernel/debug/$FAILTYPE/task-filter
echo 10 > /sys/kernel/debug/$FAILTYPE/probability
echo 100 > /sys/kernel/debug/$FAILTYPE/interval
- echo -1 > /sys/kernel/debug/$FAILTYPE/times
+ printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
echo 0 > /sys/kernel/debug/$FAILTYPE/space
echo 2 > /sys/kernel/debug/$FAILTYPE/verbose
echo 1 > /sys/kernel/debug/$FAILTYPE/ignore-gfp-wait
@@ -336,11 +340,11 @@ Application Examples
FAILTYPE=fail_function
FAILFUNC=open_ctree
echo $FAILFUNC > /sys/kernel/debug/$FAILTYPE/inject
- echo -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval
+ printf %#x -12 > /sys/kernel/debug/$FAILTYPE/$FAILFUNC/retval
echo N > /sys/kernel/debug/$FAILTYPE/task-filter
echo 100 > /sys/kernel/debug/$FAILTYPE/probability
echo 0 > /sys/kernel/debug/$FAILTYPE/interval
- echo -1 > /sys/kernel/debug/$FAILTYPE/times
+ printf %#x -1 > /sys/kernel/debug/$FAILTYPE/times
echo 0 > /sys/kernel/debug/$FAILTYPE/space
echo 1 > /sys/kernel/debug/$FAILTYPE/verbose
--
2.30.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] docs: fault-injection: fix non-working usage of negative values
2021-06-03 12:58 [PATCH] docs: fault-injection: fix non-working usage of negative values Wolfram Sang
@ 2021-06-03 13:27 ` Geert Uytterhoeven
2021-06-03 15:35 ` Wolfram Sang
2021-06-14 21:58 ` Jonathan Corbet
1 sibling, 1 reply; 4+ messages in thread
From: Geert Uytterhoeven @ 2021-06-03 13:27 UTC (permalink / raw)
To: Wolfram Sang
Cc: Linux Kernel Mailing List, Linux-Renesas, Akinobu Mita,
Jonathan Corbet, open list:DOCUMENTATION
Hi Wolfram,
On Thu, Jun 3, 2021 at 2:59 PM Wolfram Sang
<wsa+renesas@sang-engineering.com> wrote:
> Fault injection uses debugfs in a way that the provided values via sysfs
> are interpreted as u64. Providing negative numbers results in an error:
>
> /sys/kernel/debug/fail_function# echo -1 > times
> sh: write error: Invalid argument
Interesting...
> Update the docs and examples to use "printf %#x <val>" in these cases.
> For "retval", reword the paragraph a little and fix a typo.
Presumably this is something that used to work, but was broken (not
so) recently. Perhaps the code should be fixed instead?
The code uses debugfs_create_atomic_t(), and atomic_t is signed, so
I'd expect negative numbers to work.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] docs: fault-injection: fix non-working usage of negative values
2021-06-03 13:27 ` Geert Uytterhoeven
@ 2021-06-03 15:35 ` Wolfram Sang
0 siblings, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2021-06-03 15:35 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Linux Kernel Mailing List, Linux-Renesas, Akinobu Mita,
Jonathan Corbet, open list:DOCUMENTATION
[-- Attachment #1: Type: text/plain, Size: 421 bytes --]
Yeah, I also assume that it used to work at some time. Didn't bother to
investigate, though.
> The code uses debugfs_create_atomic_t(), and atomic_t is signed, so
> I'd expect negative numbers to work.
In debugfs, it is all cast from unsigned long long to something. Check
simple_attr_write() where the value is obtained with kstrtoull. The code
fix would be to not use simple_attr, I think. I opted for the doc fix.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] docs: fault-injection: fix non-working usage of negative values
2021-06-03 12:58 [PATCH] docs: fault-injection: fix non-working usage of negative values Wolfram Sang
2021-06-03 13:27 ` Geert Uytterhoeven
@ 2021-06-14 21:58 ` Jonathan Corbet
1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Corbet @ 2021-06-14 21:58 UTC (permalink / raw)
To: Wolfram Sang, linux-kernel
Cc: linux-renesas-soc, Wolfram Sang, Akinobu Mita, linux-doc
Wolfram Sang <wsa+renesas@sang-engineering.com> writes:
> Fault injection uses debugfs in a way that the provided values via sysfs
> are interpreted as u64. Providing negative numbers results in an error:
>
> /sys/kernel/debug/fail_function# echo -1 > times
> sh: write error: Invalid argument
>
> Update the docs and examples to use "printf %#x <val>" in these cases.
> For "retval", reword the paragraph a little and fix a typo.
>
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> ---
> .../fault-injection/fault-injection.rst | 24 +++++++++++--------
> 1 file changed, 14 insertions(+), 10 deletions(-)
Applied, thanks.
jon
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-06-14 21:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03 12:58 [PATCH] docs: fault-injection: fix non-working usage of negative values Wolfram Sang
2021-06-03 13:27 ` Geert Uytterhoeven
2021-06-03 15:35 ` Wolfram Sang
2021-06-14 21:58 ` Jonathan Corbet
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.