Re: [PATCH] kselftests: ftrace: limit the executing time by reading from cached trace

From: lizhijian@xxxxxxxxxxx
Date: Wed Oct 20 2021 - 00:10:35 EST




On 20/10/2021 10:55, Masami Hiramatsu wrote:
> On Tue, 19 Oct 2021 22:34:54 -0400
> Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
>> On Wed, 20 Oct 2021 11:20:27 +0900
>> Masami Hiramatsu <mhiramat@xxxxxxxxxx> wrote:
>>
>>> Hmm, by the way, shouldn't we set this feature by default?
>>> There are many "cat trace | grep ..." style test code in ftracetest just for
>>> checking whether the event is recorded. At least for the ftracetest, it should
>>> be set unless the testcase is explicitly disable it.
>> For testing, sure.
>>
>> I was criticized by the BPF folks about tracing stopping when the trace
>> file was being read. So for normal operations, it doesn't pause, because
>> that "confuses" people (so I am told).
> OK, I got it.
>
> Here is the patch to enable it by default for ftracetest :)
>
> Thanks!
>
> From 61e641f494307d9942a8415bc6743e85dd95438e Mon Sep 17 00:00:00 2001
> From: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
> Date: Wed, 20 Oct 2021 11:50:35 +0900
> Subject: [PATCH] selftests/ftrace: Stop tracing while reading the trace file
> by default
>
> Stop tracing while reading the trace file by default, to prevent
> the test results while checking it and to avoid taking a long time
> to check the result.
> If there is any testcase which wants to test the tracing while reading
> the trace file, please override this setting inside the test case.
>
> Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>

LGTM.

Tested-by: Li Zhijian <lizhijian@xxxxxxxxxxxxxx>
Reported-by: kernel test robot<lkp@xxxxxxxxx>


> ---
> tools/testing/selftests/ftrace/test.d/functions | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
> index 000fd05e84b1..8adc0140d03f 100644
> --- a/tools/testing/selftests/ftrace/test.d/functions
> +++ b/tools/testing/selftests/ftrace/test.d/functions
> @@ -124,6 +124,12 @@ initialize_ftrace() { # Reset ftrace to initial-state
> [ -f uprobe_events ] && echo > uprobe_events
> [ -f synthetic_events ] && echo > synthetic_events
> [ -f snapshot ] && echo 0 > snapshot
> +
> +# Stop tracing while reading the trace file by default, to prevent
> +# the test results while checking it and to avoid taking a long time
> +# to check the result.
> + [ -f options/pause-on-trace ] && echo 1 > options/pause-on-trace
> +
> clear_trace
> enable_tracing
> }