diff mbox series

[v3,04/10] cxl: add common function to disable event trace

Message ID 166742402697.2654617.15955710715103932892.stgit@djiang5-desk3.ch.intel.com
State Superseded
Headers show
Series cxl: add monitor support for trace events | expand

Commit Message

Dave Jiang Nov. 2, 2022, 9:20 p.m. UTC
Add a common function for cxl command that disables the event trace for the
instance created.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
 cxl/event_trace.c |    8 ++++++++
 cxl/event_trace.h |    1 +
 2 files changed, 9 insertions(+)

Comments

Steven Rostedt Nov. 3, 2022, 6:02 a.m. UTC | #1
On Wed, 02 Nov 2022 14:20:26 -0700
Dave Jiang <dave.jiang@intel.com> wrote:

> Add a common function for cxl command that disables the event trace for the
> instance created.
> 
> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
> ---
>  cxl/event_trace.c |    8 ++++++++
>  cxl/event_trace.h |    1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
> index d59e54c33df6..bcd4f8b2968e 100644
> --- a/cxl/event_trace.c
> +++ b/cxl/event_trace.c
> @@ -221,3 +221,11 @@ int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system)
>  	tracefs_trace_on(inst);
>  	return 0;
>  }
> +
> +int cxl_event_tracing_disable(struct tracefs_instance *inst)
> +{
> +	if (!tracefs_trace_is_on(inst))
> +		return 0;

Why bother checking if tracing is on or not. It's not any more
efficient. You're not eliminating a system call. You are actually
adding another one.

-- Steve


> +
> +	return tracefs_trace_off(inst);
> +}
> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
> index 0258b8dc65a3..17d922f922c1 100644
> --- a/cxl/event_trace.h
> +++ b/cxl/event_trace.h
> @@ -21,5 +21,6 @@ struct event_ctx {
>  
>  int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
>  int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system);
> +int cxl_event_tracing_disable(struct tracefs_instance *inst);
>  
>  #endif
>
Dave Jiang Nov. 3, 2022, 4:30 p.m. UTC | #2
On 11/2/2022 11:02 PM, Steven Rostedt wrote:
> On Wed, 02 Nov 2022 14:20:26 -0700
> Dave Jiang <dave.jiang@intel.com> wrote:
> 
>> Add a common function for cxl command that disables the event trace for the
>> instance created.
>>
>> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
>> ---
>>   cxl/event_trace.c |    8 ++++++++
>>   cxl/event_trace.h |    1 +
>>   2 files changed, 9 insertions(+)
>>
>> diff --git a/cxl/event_trace.c b/cxl/event_trace.c
>> index d59e54c33df6..bcd4f8b2968e 100644
>> --- a/cxl/event_trace.c
>> +++ b/cxl/event_trace.c
>> @@ -221,3 +221,11 @@ int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system)
>>   	tracefs_trace_on(inst);
>>   	return 0;
>>   }
>> +
>> +int cxl_event_tracing_disable(struct tracefs_instance *inst)
>> +{
>> +	if (!tracefs_trace_is_on(inst))
>> +		return 0;
> 
> Why bother checking if tracing is on or not. It's not any more
> efficient. You're not eliminating a system call. You are actually
> adding another one.

Ok, will remove.
> 
> -- Steve
> 
> 
>> +
>> +	return tracefs_trace_off(inst);
>> +}
>> diff --git a/cxl/event_trace.h b/cxl/event_trace.h
>> index 0258b8dc65a3..17d922f922c1 100644
>> --- a/cxl/event_trace.h
>> +++ b/cxl/event_trace.h
>> @@ -21,5 +21,6 @@ struct event_ctx {
>>   
>>   int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
>>   int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system);
>> +int cxl_event_tracing_disable(struct tracefs_instance *inst);
>>   
>>   #endif
>>
>
diff mbox series

Patch

diff --git a/cxl/event_trace.c b/cxl/event_trace.c
index d59e54c33df6..bcd4f8b2968e 100644
--- a/cxl/event_trace.c
+++ b/cxl/event_trace.c
@@ -221,3 +221,11 @@  int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system)
 	tracefs_trace_on(inst);
 	return 0;
 }
+
+int cxl_event_tracing_disable(struct tracefs_instance *inst)
+{
+	if (!tracefs_trace_is_on(inst))
+		return 0;
+
+	return tracefs_trace_off(inst);
+}
diff --git a/cxl/event_trace.h b/cxl/event_trace.h
index 0258b8dc65a3..17d922f922c1 100644
--- a/cxl/event_trace.h
+++ b/cxl/event_trace.h
@@ -21,5 +21,6 @@  struct event_ctx {
 
 int cxl_parse_events(struct tracefs_instance *inst, struct event_ctx *ectx);
 int cxl_event_tracing_enable(struct tracefs_instance *inst, const char *system);
+int cxl_event_tracing_disable(struct tracefs_instance *inst);
 
 #endif