All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Introduce ftrace_disabled
@ 2021-06-19  6:29 Tiezhu Yang
  2021-06-19  6:29 ` [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled Tiezhu Yang
  2021-06-19  6:29 ` [RFC PATCH 2/2] docs: kernel-parameters: Add ftrace_disabled Tiezhu Yang
  0 siblings, 2 replies; 7+ messages in thread
From: Tiezhu Yang @ 2021-06-19  6:29 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, Jonathan Corbet
  Cc: linux-doc, linux-kernel, Xuefeng Li

Tiezhu Yang (2):
  ftrace: Introduce cmdline argument ftrace_disabled
  docs: kernel-parameters: Add ftrace_disabled

 Documentation/admin-guide/kernel-parameters.txt | 4 ++++
 kernel/trace/ftrace.c                           | 8 ++++++++
 2 files changed, 12 insertions(+)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled
  2021-06-19  6:29 [RFC PATCH 0/2] Introduce ftrace_disabled Tiezhu Yang
@ 2021-06-19  6:29 ` Tiezhu Yang
  2021-06-19 15:22   ` Steven Rostedt
  2021-06-19  6:29 ` [RFC PATCH 2/2] docs: kernel-parameters: Add ftrace_disabled Tiezhu Yang
  1 sibling, 1 reply; 7+ messages in thread
From: Tiezhu Yang @ 2021-06-19  6:29 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, Jonathan Corbet
  Cc: linux-doc, linux-kernel, Xuefeng Li

If set CONFIG_FUNCTION_TRACER=y, we can use the following command to
disable ftrace after boot up:
echo 0 > /proc/sys/kernel/ftrace_enabled

ftrace_disabled is much stronger than ftrace_enabled, introduce a new
cmdline argument ftrace_disabled for user to control whether to disable
ftrace when boot up.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 kernel/trace/ftrace.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 72ef4dc..a015699 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -5517,6 +5517,14 @@ static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
 /* Used by function selftest to not test if filter is set */
 bool ftrace_filter_param __initdata;
 
+static int __init set_ftrace_disabled(char *str)
+{
+	pr_info("Set ftrace_disabled to disable ftrace\n");
+	ftrace_disabled = 1;
+	return 1;
+}
+__setup("ftrace_disabled", set_ftrace_disabled);
+
 static int __init set_ftrace_notrace(char *str)
 {
 	ftrace_filter_param = true;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC PATCH 2/2] docs: kernel-parameters: Add ftrace_disabled
  2021-06-19  6:29 [RFC PATCH 0/2] Introduce ftrace_disabled Tiezhu Yang
  2021-06-19  6:29 ` [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled Tiezhu Yang
@ 2021-06-19  6:29 ` Tiezhu Yang
  1 sibling, 0 replies; 7+ messages in thread
From: Tiezhu Yang @ 2021-06-19  6:29 UTC (permalink / raw)
  To: Steven Rostedt, Ingo Molnar, Jonathan Corbet
  Cc: linux-doc, linux-kernel, Xuefeng Li

Explain the cmdline argument ftrace_disabled in the file
Documentation/admin-guide/kernel-parameters.txt

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 Documentation/admin-guide/kernel-parameters.txt | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index cb89dbd..f255aff 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1392,6 +1392,10 @@
 			dump only the buffer of the CPU that triggered the
 			oops.
 
+	ftrace_disabled
+			Set ftrace_disabled in cmdline to disable ftrace when
+			boot up.
+
 	ftrace_filter=[function-list]
 			[FTRACE] Limit the functions traced by the function
 			tracer at boot up. function-list is a comma-separated
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled
  2021-06-19  6:29 ` [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled Tiezhu Yang
@ 2021-06-19 15:22   ` Steven Rostedt
  2021-06-21  1:21     ` Tiezhu Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2021-06-19 15:22 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Ingo Molnar, Jonathan Corbet, linux-doc, linux-kernel, Xuefeng Li

On Sat, 19 Jun 2021 14:29:19 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> If set CONFIG_FUNCTION_TRACER=y, we can use the following command to
> disable ftrace after boot up:
> echo 0 > /proc/sys/kernel/ftrace_enabled

I'd love to just remove that. It's original purpose was to stop function
tracing when the latency tracers were active. That's now done via a tracefs
option. The "ftrace_enabled" really has no use anymore.

> 
> ftrace_disabled is much stronger than ftrace_enabled, introduce a new
> cmdline argument ftrace_disabled for user to control whether to disable
> ftrace when boot up.

"ftrace_disabled" is triggered when an anomaly is detected, and for the
safety of the system, ftrace shuts down. It was never meant to be a user
triggered event.

You have no rationale for this change. What's the purpose of this?

-- Steve


> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
>  kernel/trace/ftrace.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index 72ef4dc..a015699 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -5517,6 +5517,14 @@ static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
>  /* Used by function selftest to not test if filter is set */
>  bool ftrace_filter_param __initdata;
>  
> +static int __init set_ftrace_disabled(char *str)
> +{
> +	pr_info("Set ftrace_disabled to disable ftrace\n");
> +	ftrace_disabled = 1;
> +	return 1;
> +}
> +__setup("ftrace_disabled", set_ftrace_disabled);
> +
>  static int __init set_ftrace_notrace(char *str)
>  {
>  	ftrace_filter_param = true;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled
  2021-06-19 15:22   ` Steven Rostedt
@ 2021-06-21  1:21     ` Tiezhu Yang
  2021-06-21 14:00       ` Steven Rostedt
  0 siblings, 1 reply; 7+ messages in thread
From: Tiezhu Yang @ 2021-06-21  1:21 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, Jonathan Corbet, linux-doc, linux-kernel, Xuefeng Li

On 06/19/2021 11:22 PM, Steven Rostedt wrote:
> On Sat, 19 Jun 2021 14:29:19 +0800
> Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
>> If set CONFIG_FUNCTION_TRACER=y, we can use the following command to
>> disable ftrace after boot up:
>> echo 0 > /proc/sys/kernel/ftrace_enabled
> I'd love to just remove that. It's original purpose was to stop function
> tracing when the latency tracers were active. That's now done via a tracefs
> option. The "ftrace_enabled" really has no use anymore.
>
>> ftrace_disabled is much stronger than ftrace_enabled, introduce a new
>> cmdline argument ftrace_disabled for user to control whether to disable
>> ftrace when boot up.
> "ftrace_disabled" is triggered when an anomaly is detected, and for the
> safety of the system, ftrace shuts down. It was never meant to be a user
> triggered event.

Thanks for your explanation.

>
> You have no rationale for this change. What's the purpose of this?

The "System Benchmarks Index Score" of UnixBench under FUNCTION_TRACER
is lower than !FUNCTION_TRACER, I want to use this new cmdline argument
ftrace_disabled to test it, this is the original intention.

I see the following help info of "config FUNCTION_TRACER":

[If it's runtime disabled (the bootup default), then the overhead of the
instructions is very small and not measurable even in micro-benchmarks.]

I am not quite understand the above description, could you tell me how to
avoid the runtime performance overhead under FUNCTION_TRACER?

Thanks,
Tiezhu

>
> -- Steve
>
>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>>   kernel/trace/ftrace.c | 8 ++++++++
>>   1 file changed, 8 insertions(+)
>>
>> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
>> index 72ef4dc..a015699 100644
>> --- a/kernel/trace/ftrace.c
>> +++ b/kernel/trace/ftrace.c
>> @@ -5517,6 +5517,14 @@ static char ftrace_filter_buf[FTRACE_FILTER_SIZE] __initdata;
>>   /* Used by function selftest to not test if filter is set */
>>   bool ftrace_filter_param __initdata;
>>   
>> +static int __init set_ftrace_disabled(char *str)
>> +{
>> +	pr_info("Set ftrace_disabled to disable ftrace\n");
>> +	ftrace_disabled = 1;
>> +	return 1;
>> +}
>> +__setup("ftrace_disabled", set_ftrace_disabled);
>> +
>>   static int __init set_ftrace_notrace(char *str)
>>   {
>>   	ftrace_filter_param = true;


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled
  2021-06-21  1:21     ` Tiezhu Yang
@ 2021-06-21 14:00       ` Steven Rostedt
  2021-06-22  1:19         ` Tiezhu Yang
  0 siblings, 1 reply; 7+ messages in thread
From: Steven Rostedt @ 2021-06-21 14:00 UTC (permalink / raw)
  To: Tiezhu Yang
  Cc: Ingo Molnar, Jonathan Corbet, linux-doc, linux-kernel, Xuefeng Li

On Mon, 21 Jun 2021 09:21:31 +0800
Tiezhu Yang <yangtiezhu@loongson.cn> wrote:

> >
> > You have no rationale for this change. What's the purpose of this?  
> 
> The "System Benchmarks Index Score" of UnixBench under FUNCTION_TRACER
> is lower than !FUNCTION_TRACER, I want to use this new cmdline argument
> ftrace_disabled to test it, this is the original intention.
> 
> I see the following help info of "config FUNCTION_TRACER":
> 
> [If it's runtime disabled (the bootup default), then the overhead of the
> instructions is very small and not measurable even in micro-benchmarks.]

Those benchmarks were done a long time ago, and they may be measurable today :-/

> 
> I am not quite understand the above description, could you tell me how to
> avoid the runtime performance overhead under FUNCTION_TRACER?

Anyway, your patch wont do anything to change the benchmarks.

When CONFIG_FUNCTION_TRACER is enabled, on x86_64, most functions will
start with a call to fentry. At boot up, these functions will be
converted over to become a nop. And thinking about it, "ftrace_disable"
stops all conversions, so if you add that to the kernel command line,
those calls to fentry, wont be converted to nops, and you'll make
things much worse!

Now, some versions of gcc (and perhaps clang) can do the conversion to
nops at compile time (in which case, your patch would keep the nops and
not the calls to fentry).

The overhead that FUNCTION_TRACER adds is the 5 byte nop at the start
of most functions. This causes a slight hit to instruction cache, and a
minuscule amount of time in the instruction pipeline of the CPU. This
is the "overhead" that is talked about. Your patch doesn't do anything
to address it. The only way to remove that overhead is to compile the
kernel without CONFIG_FUNCTION_TRACER.

-- Steve


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled
  2021-06-21 14:00       ` Steven Rostedt
@ 2021-06-22  1:19         ` Tiezhu Yang
  0 siblings, 0 replies; 7+ messages in thread
From: Tiezhu Yang @ 2021-06-22  1:19 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Ingo Molnar, Jonathan Corbet, linux-doc, linux-kernel, Xuefeng Li

On 06/21/2021 10:00 PM, Steven Rostedt wrote:
> On Mon, 21 Jun 2021 09:21:31 +0800
> Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
>
>>> You have no rationale for this change. What's the purpose of this?
>> The "System Benchmarks Index Score" of UnixBench under FUNCTION_TRACER
>> is lower than !FUNCTION_TRACER, I want to use this new cmdline argument
>> ftrace_disabled to test it, this is the original intention.
>>
>> I see the following help info of "config FUNCTION_TRACER":
>>
>> [If it's runtime disabled (the bootup default), then the overhead of the
>> instructions is very small and not measurable even in micro-benchmarks.]
> Those benchmarks were done a long time ago, and they may be measurable today :-/
>
>> I am not quite understand the above description, could you tell me how to
>> avoid the runtime performance overhead under FUNCTION_TRACER?
> Anyway, your patch wont do anything to change the benchmarks.
>
> When CONFIG_FUNCTION_TRACER is enabled, on x86_64, most functions will
> start with a call to fentry. At boot up, these functions will be
> converted over to become a nop. And thinking about it, "ftrace_disable"
> stops all conversions, so if you add that to the kernel command line,
> those calls to fentry, wont be converted to nops, and you'll make
> things much worse!
>
> Now, some versions of gcc (and perhaps clang) can do the conversion to
> nops at compile time (in which case, your patch would keep the nops and
> not the calls to fentry).
>
> The overhead that FUNCTION_TRACER adds is the 5 byte nop at the start
> of most functions. This causes a slight hit to instruction cache, and a
> minuscule amount of time in the instruction pipeline of the CPU. This
> is the "overhead" that is talked about. Your patch doesn't do anything
> to address it. The only way to remove that overhead is to compile the
> kernel without CONFIG_FUNCTION_TRACER.
>
> -- Steve

OK, I see, thank you very much.

Thanks,
Tiezhu


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-22  1:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-19  6:29 [RFC PATCH 0/2] Introduce ftrace_disabled Tiezhu Yang
2021-06-19  6:29 ` [RFC PATCH 1/2] ftrace: Introduce cmdline argument ftrace_disabled Tiezhu Yang
2021-06-19 15:22   ` Steven Rostedt
2021-06-21  1:21     ` Tiezhu Yang
2021-06-21 14:00       ` Steven Rostedt
2021-06-22  1:19         ` Tiezhu Yang
2021-06-19  6:29 ` [RFC PATCH 2/2] docs: kernel-parameters: Add ftrace_disabled Tiezhu Yang

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.