* [PATCH] selftests/tracing: Fix test_multiple_writes stall
@ 2025-12-26 9:12 Fushuai Wang
2025-12-26 18:29 ` Steven Rostedt
0 siblings, 1 reply; 3+ messages in thread
From: Fushuai Wang @ 2025-12-26 9:12 UTC (permalink / raw)
To: rostedt, mhiramat, mathieu.desnoyers, shuah, wangfushuai
Cc: linux-kernel, linux-trace-kernel, linux-kselftest, Fushuai Wang
When /sys/kernel/tracing/buffer_size_kb is less than 12KB,
the test_multiple_writes test will stall and wait for more
input due to insufficient buffer space.
This patch check current buffer_size_kb value before the test.
If it is less than 12KB, it temporarily increase the buffer to
12KB, and restore the original value after the tests are completed.
Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
---
.../ftrace/test.d/00basic/trace_marker_raw.tc | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
index 7daf7292209e..216f87d89c3f 100644
--- a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
+++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
@@ -58,7 +58,7 @@ test_multiple_writes() {
echo stop > trace_marker
# Check to make sure the number of entries is the id (rounded up by 4)
- awk '/.*: # [0-9a-f]* / {
+ awk -v ORIG="${ORIG}" '/.*: # [0-9a-f]* / {
print;
cnt = -1;
for (i = 0; i < NF; i++) {
@@ -70,6 +70,7 @@ test_multiple_writes() {
# The number of items is always rounded up by 4
cnt2 = int((cnt + 3) / 4) * 4;
if (cnt2 != num) {
+ system("echo \""ORIG"\" > buffer_size_kb");
exit 1;
}
break;
@@ -89,6 +90,7 @@ test_buffer() {
# The id must be four bytes, test that 3 bytes fails a write
if echo -n abc > ./trace_marker_raw ; then
echo "Too small of write expected to fail but did not"
+ echo $ORIG > buffer_size_kb
exit_fail
fi
@@ -99,9 +101,21 @@ test_buffer() {
if write_buffer 0xdeadbeef $size ; then
echo "Too big of write expected to fail but did not"
+ echo $ORIG > buffer_size_kb
exit_fail
fi
}
+ORIG=`cat buffer_size_kb`
+
+# test_multiple_writes test needs at least 12KB buffer
+NEW_SIZE=12
+
+if [ ${ORIG} -lt ${NEW_SIZE} ]; then
+ echo ${NEW_SIZE} > buffer_size_kb
+fi
+
test_buffer
test_multiple_writes
+
+echo $ORIG > buffer_size_kb
--
2.36.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/tracing: Fix test_multiple_writes stall
2025-12-26 9:12 [PATCH] selftests/tracing: Fix test_multiple_writes stall Fushuai Wang
@ 2025-12-26 18:29 ` Steven Rostedt
2025-12-27 3:44 ` Fushuai Wang
0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2025-12-26 18:29 UTC (permalink / raw)
To: Fushuai Wang
Cc: mhiramat, mathieu.desnoyers, shuah, wangfushuai, linux-kernel,
linux-trace-kernel, linux-kselftest
On Fri, 26 Dec 2025 17:12:17 +0800
Fushuai Wang <fushuai.wang@linux.dev> wrote:
> When /sys/kernel/tracing/buffer_size_kb is less than 12KB,
> the test_multiple_writes test will stall and wait for more
> input due to insufficient buffer space.
>
> This patch check current buffer_size_kb value before the test.
Never use "This patch" in a change log. See Submitting Patches:
https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
Describe your changes in imperative mood, e.g. “make xyzzy do frotz”
instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to
do frotz”, as if you are giving orders to the codebase to change its
behaviour.
> If it is less than 12KB, it temporarily increase the buffer to
> 12KB, and restore the original value after the tests are completed.
>
> Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
> ---
> .../ftrace/test.d/00basic/trace_marker_raw.tc | 16 +++++++++++++++-
> 1 file changed, 15 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
> index 7daf7292209e..216f87d89c3f 100644
> --- a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
> +++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
> @@ -58,7 +58,7 @@ test_multiple_writes() {
> echo stop > trace_marker
>
> # Check to make sure the number of entries is the id (rounded up by 4)
> - awk '/.*: # [0-9a-f]* / {
> + awk -v ORIG="${ORIG}" '/.*: # [0-9a-f]* / {
> print;
> cnt = -1;
> for (i = 0; i < NF; i++) {
> @@ -70,6 +70,7 @@ test_multiple_writes() {
> # The number of items is always rounded up by 4
> cnt2 = int((cnt + 3) / 4) * 4;
> if (cnt2 != num) {
> + system("echo \""ORIG"\" > buffer_size_kb");
Why are you doing this in the awk script?
> exit 1;
> }
> break;
> @@ -89,6 +90,7 @@ test_buffer() {
> # The id must be four bytes, test that 3 bytes fails a write
> if echo -n abc > ./trace_marker_raw ; then
> echo "Too small of write expected to fail but did not"
> + echo $ORIG > buffer_size_kb
> exit_fail
> fi
>
> @@ -99,9 +101,21 @@ test_buffer() {
>
> if write_buffer 0xdeadbeef $size ; then
> echo "Too big of write expected to fail but did not"
> + echo $ORIG > buffer_size_kb
> exit_fail
> fi
> }
>
> +ORIG=`cat buffer_size_kb`
> +
> +# test_multiple_writes test needs at least 12KB buffer
> +NEW_SIZE=12
> +
> +if [ ${ORIG} -lt ${NEW_SIZE} ]; then
> + echo ${NEW_SIZE} > buffer_size_kb
> +fi
> +
> test_buffer
> test_multiple_writes
Could add:
if ! test_multiple_writes ; then
echo $ORIG > buffer_size_kb
exit_fail
fi
instead.
-- Steve
> +
> +echo $ORIG > buffer_size_kb
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] selftests/tracing: Fix test_multiple_writes stall
2025-12-26 18:29 ` Steven Rostedt
@ 2025-12-27 3:44 ` Fushuai Wang
0 siblings, 0 replies; 3+ messages in thread
From: Fushuai Wang @ 2025-12-27 3:44 UTC (permalink / raw)
To: rostedt
Cc: fushuai.wang, linux-kernel, linux-kselftest, linux-trace-kernel,
mathieu.desnoyers, mhiramat, shuah, wangfushuai
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=y, Size: 3074 bytes --]
>> When /sys/kernel/tracing/buffer_size_kb is less than 12KB,
>> the test_multiple_writes test will stall and wait for more
>> input due to insufficient buffer space.
>>
>> This patch check current buffer_size_kb value before the test.
>
> Never use "This patch" in a change log. See Submitting Patches:
>
> https://docs.kernel.org/process/submitting-patches.html#describe-your-changes
>
> Describe your changes in imperative mood, e.g. “make xyzzy do frotz”
> instead of “[This patch] makes xyzzy do frotz” or “[I] changed xyzzy to
> do frotz”, as if you are giving orders to the codebase to change its
> behaviour.
>
>
Thank you for pointing this out. I will follow this guideline
in future submissions.
>> If it is less than 12KB, it temporarily increase the buffer to
>> 12KB, and restore the original value after the tests are completed.
>>
>> Fixes: 37f46601383a ("selftests/tracing: Add basic test for trace_marker_raw file")
>> Signed-off-by: Fushuai Wang <wangfushuai@baidu.com>
>> ---
>> .../ftrace/test.d/00basic/trace_marker_raw.tc | 16 +++++++++++++++-
>> 1 file changed, 15 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
>> index 7daf7292209e..216f87d89c3f 100644
>> --- a/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
>> +++ b/tools/testing/selftests/ftrace/test.d/00basic/trace_marker_raw.tc
>> @@ -58,7 +58,7 @@ test_multiple_writes() {
>> echo stop > trace_marker
>>
>> # Check to make sure the number of entries is the id (rounded up by 4)
>> - awk '/.*: # [0-9a-f]* / {
>> + awk -v ORIG="${ORIG}" '/.*: # [0-9a-f]* / {
>> print;
>> cnt = -1;
>> for (i = 0; i < NF; i++) {
>> @@ -70,6 +70,7 @@ test_multiple_writes() {
>> # The number of items is always rounded up by 4
>> cnt2 = int((cnt + 3) / 4) * 4;
>> if (cnt2 != num) {
>> + system("echo \""ORIG"\" > buffer_size_kb");
>
> Why are you doing this in the awk script?
>>
>> exit 1;
>> }
>> break;
>> @@ -89,6 +90,7 @@ test_buffer() {
>> # The id must be four bytes, test that 3 bytes fails a write
>> if echo -n abc > ./trace_marker_raw ; then
>> echo "Too small of write expected to fail but did not"
>> + echo $ORIG > buffer_size_kb
>> exit_fail
>> fi
>>
>> @@ -99,9 +101,21 @@ test_buffer() {
>>
>> if write_buffer 0xdeadbeef $size ; then
>> echo "Too big of write expected to fail but did not"
>> + echo $ORIG > buffer_size_kb
>> exit_fail
>> fi
>> }
>>
>> +ORIG=`cat buffer_size_kb`
>> +
>> +# test_multiple_writes test needs at least 12KB buffer
>> +NEW_SIZE=12
>> +
>> +if [ ${ORIG} -lt ${NEW_SIZE} ]; then
>> + echo ${NEW_SIZE} > buffer_size_kb
>> +fi
>> +
>> test_buffer
>> test_multiple_writes
>
> Could add:
>
> if ! test_multiple_writes ; then
> echo $ORIG > buffer_size_kb
> exit_fail
> fi
>
> instead.
>
> -- Steve
Thank you, and this looks better.
I will send a v2 shortly.
---
Regards,
WANG
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-27 3:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-26 9:12 [PATCH] selftests/tracing: Fix test_multiple_writes stall Fushuai Wang
2025-12-26 18:29 ` Steven Rostedt
2025-12-27 3:44 ` Fushuai Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox