diff mbox series

[14/46] libata: add reset tracepoints

Message ID 20200204165547.115220-15-hare@suse.de
State Not Applicable
Delegated to: David Miller
Headers show
Series ata: kill ATA_DEBUG | expand

Commit Message

Hannes Reinecke Feb. 4, 2020, 4:55 p.m. UTC
To follow the flow of control we should be using tracepoints, as
they will tie in with the actual I/O flow and deliver a better
overview about what it happening.
This patch adds tracepoints for hard and soft reset and adds
them in the libata-eh control flow.

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/ata/libata-eh.c       | 16 +++++++-
 include/trace/events/libata.h | 88 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 102 insertions(+), 2 deletions(-)

Comments

Bartlomiej Zolnierkiewicz Feb. 10, 2020, 1:42 p.m. UTC | #1
On 2/4/20 5:55 PM, Hannes Reinecke wrote:
> To follow the flow of control we should be using tracepoints, as
> they will tie in with the actual I/O flow and deliver a better
> overview about what it happening.
> This patch adds tracepoints for hard and soft reset and adds
> them in the libata-eh control flow.
> 
> Signed-off-by: Hannes Reinecke <hare@suse.de>

checkpatch.pl complains about CodingStyle issues:

WARNING: line over 80 characters
#164: FILE: include/trace/events/libata.h:350:
+       TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),

ERROR: space prohibited after that open parenthesis '('
#169: FILE: include/trace/events/libata.h:355:
+               __field( unsigned int,  ata_port )

ERROR: space prohibited before that close parenthesis ')'
#169: FILE: include/trace/events/libata.h:355:
+               __field( unsigned int,  ata_port )

ERROR: space prohibited after that open parenthesis '('
#170: FILE: include/trace/events/libata.h:356:
+               __array( unsigned int,  class, 2)

ERROR: space prohibited after that open parenthesis '('
#171: FILE: include/trace/events/libata.h:357:
+               __field( unsigned long, deadline)

WARNING: line over 80 characters
#187: FILE: include/trace/events/libata.h:373:
+            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),

WARNING: line over 80 characters
#191: FILE: include/trace/events/libata.h:377:
+            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),

WARNING: line over 80 characters
#195: FILE: include/trace/events/libata.h:381:
+            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),

ERROR: space prohibited after that open parenthesis '('
#205: FILE: include/trace/events/libata.h:391:
+               __field( unsigned int,  ata_port )

ERROR: space prohibited before that close parenthesis ')'
#205: FILE: include/trace/events/libata.h:391:
+               __field( unsigned int,  ata_port )

ERROR: space prohibited after that open parenthesis '('
#206: FILE: include/trace/events/libata.h:392:
+               __array( unsigned int,  class, 2)

ERROR: space prohibited after that open parenthesis '('
#207: FILE: include/trace/events/libata.h:393:
+               __field( int,           rc)

Otherwise the patch looks fine.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

> ---
>  drivers/ata/libata-eh.c       | 16 +++++++-
>  include/trace/events/libata.h | 88 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 102 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
> index 3bfd9da58473..253dcf903c1b 100644
> --- a/drivers/ata/libata-eh.c
> +++ b/drivers/ata/libata-eh.c
> @@ -2787,12 +2787,19 @@ int ata_eh_reset(struct ata_link *link, int classify,
>  
>  		/* mark that this EH session started with reset */
>  		ehc->last_reset = jiffies;
> -		if (reset == hardreset)
> +		if (reset == hardreset) {
>  			ehc->i.flags |= ATA_EHI_DID_HARDRESET;
> -		else
> +			trace_ata_link_hardreset_begin(link, classes, deadline);
> +		} else {
>  			ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
> +			trace_ata_link_softreset_begin(link, classes, deadline);
> +		}
>  
>  		rc = ata_do_reset(link, reset, classes, deadline, true);
> +		if (reset == hardreset)
> +			trace_ata_link_hardreset_end(link, classes, rc);
> +		else
> +			trace_ata_link_softreset_end(link, classes, rc);
>  		if (rc && rc != -EAGAIN) {
>  			failed_link = link;
>  			goto fail;
> @@ -2806,8 +2813,11 @@ int ata_eh_reset(struct ata_link *link, int classify,
>  				ata_link_info(slave, "hard resetting link\n");
>  
>  			ata_eh_about_to_do(slave, NULL, ATA_EH_RESET);
> +			trace_ata_slave_hardreset_begin(slave, classes,
> +							deadline);
>  			tmp = ata_do_reset(slave, reset, classes, deadline,
>  					   false);
> +			trace_ata_slave_hardreset_end(slave, classes, tmp);
>  			switch (tmp) {
>  			case -EAGAIN:
>  				rc = -EAGAIN;
> @@ -2834,7 +2844,9 @@ int ata_eh_reset(struct ata_link *link, int classify,
>  			}
>  
>  			ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
> +			trace_ata_link_softreset_begin(link, classes, deadline);
>  			rc = ata_do_reset(link, reset, classes, deadline, true);
> +			trace_ata_link_softreset_end(link, classes, rc);
>  			if (rc) {
>  				failed_link = link;
>  				goto fail;
> diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
> index ab69434e2329..e9fb4d44eeac 100644
> --- a/include/trace/events/libata.h
> +++ b/include/trace/events/libata.h
> @@ -132,6 +132,22 @@
>  		ata_protocol_name(ATAPI_PROT_PIO),	\
>  		ata_protocol_name(ATAPI_PROT_DMA))
>  
> +#define ata_class_name(class)	{ class, #class }
> +#define show_class_name(val)				\
> +	__print_symbolic(val,				\
> +		ata_class_name(ATA_DEV_UNKNOWN),	\
> +		ata_class_name(ATA_DEV_ATA),		\
> +		ata_class_name(ATA_DEV_ATA_UNSUP),	\
> +		ata_class_name(ATA_DEV_ATAPI),		\
> +		ata_class_name(ATA_DEV_ATAPI_UNSUP),	\
> +		ata_class_name(ATA_DEV_PMP),		\
> +		ata_class_name(ATA_DEV_PMP_UNSUP),	\
> +		ata_class_name(ATA_DEV_SEMB),		\
> +		ata_class_name(ATA_DEV_SEMB_UNSUP),	\
> +		ata_class_name(ATA_DEV_ZAC),		\
> +		ata_class_name(ATA_DEV_ZAC_UNSUP),	\
> +		ata_class_name(ATA_DEV_NONE))
> +
>  const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
>  #define __parse_status(s) libata_trace_parse_status(p, s)
>  
> @@ -329,6 +345,78 @@ TRACE_EVENT(ata_eh_link_autopsy_qc,
>  		  __parse_eh_err_mask(__entry->eh_err_mask))
>  );
>  
> +DECLARE_EVENT_CLASS(ata_link_reset_begin_template,
> +
> +	TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> +
> +	TP_ARGS(link, class, deadline),
> +
> +	TP_STRUCT__entry(
> +		__field( unsigned int,	ata_port )
> +		__array( unsigned int,	class, 2)
> +		__field( unsigned long,	deadline)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->ata_port	= link->ap->print_id;
> +		memcpy(__entry->class, class, 2);
> +		__entry->deadline	= deadline;
> +	),
> +
> +	TP_printk("ata_port=%u deadline=%lu classes=[%s,%s]",
> +		  __entry->ata_port, __entry->deadline,
> +		  show_class_name(__entry->class[0]),
> +		  show_class_name(__entry->class[1]))
> +);
> +
> +DEFINE_EVENT(ata_link_reset_begin_template, ata_link_hardreset_begin,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> +	     TP_ARGS(link, class, deadline));
> +
> +DEFINE_EVENT(ata_link_reset_begin_template, ata_slave_hardreset_begin,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> +	     TP_ARGS(link, class, deadline));
> +
> +DEFINE_EVENT(ata_link_reset_begin_template, ata_link_softreset_begin,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> +	     TP_ARGS(link, class, deadline));
> +
> +DECLARE_EVENT_CLASS(ata_link_reset_end_template,
> +
> +	TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
> +
> +	TP_ARGS(link, class, rc),
> +
> +	TP_STRUCT__entry(
> +		__field( unsigned int,	ata_port )
> +		__array( unsigned int,	class, 2)
> +		__field( int,		rc)
> +	),
> +
> +	TP_fast_assign(
> +		__entry->ata_port	= link->ap->print_id;
> +		memcpy(__entry->class, class, 2);
> +		__entry->rc		= rc;
> +	),
> +
> +	TP_printk("ata_port=%u rc=%d class=[%s,%s]",
> +		  __entry->ata_port, __entry->rc,
> +		  show_class_name(__entry->class[0]),
> +		  show_class_name(__entry->class[1]))
> +);
> +
> +DEFINE_EVENT(ata_link_reset_end_template, ata_link_hardreset_end,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
> +	     TP_ARGS(link, class, rc));
> +
> +DEFINE_EVENT(ata_link_reset_end_template, ata_slave_hardreset_end,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
> +	     TP_ARGS(link, class, rc));
> +
> +DEFINE_EVENT(ata_link_reset_end_template, ata_link_softreset_end,
> +	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
> +	     TP_ARGS(link, class, rc));
> +
>  #endif /*  _TRACE_LIBATA_H */
>  
>  /* This part must be outside protection */
>
Hannes Reinecke Feb. 12, 2020, 10:11 a.m. UTC | #2
On 2/10/20 2:42 PM, Bartlomiej Zolnierkiewicz wrote:
> 
> On 2/4/20 5:55 PM, Hannes Reinecke wrote:
>> To follow the flow of control we should be using tracepoints, as
>> they will tie in with the actual I/O flow and deliver a better
>> overview about what it happening.
>> This patch adds tracepoints for hard and soft reset and adds
>> them in the libata-eh control flow.
>>
>> Signed-off-by: Hannes Reinecke <hare@suse.de>
> 
> checkpatch.pl complains about CodingStyle issues:
> 
> WARNING: line over 80 characters
> #164: FILE: include/trace/events/libata.h:350:
> +       TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> 
> ERROR: space prohibited after that open parenthesis '('
> #169: FILE: include/trace/events/libata.h:355:
> +               __field( unsigned int,  ata_port )
> 
> ERROR: space prohibited before that close parenthesis ')'
> #169: FILE: include/trace/events/libata.h:355:
> +               __field( unsigned int,  ata_port )
> 
> ERROR: space prohibited after that open parenthesis '('
> #170: FILE: include/trace/events/libata.h:356:
> +               __array( unsigned int,  class, 2)
> 
> ERROR: space prohibited after that open parenthesis '('
> #171: FILE: include/trace/events/libata.h:357:
> +               __field( unsigned long, deadline)
> 
> WARNING: line over 80 characters
> #187: FILE: include/trace/events/libata.h:373:
> +            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> 
> WARNING: line over 80 characters
> #191: FILE: include/trace/events/libata.h:377:
> +            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> 
> WARNING: line over 80 characters
> #195: FILE: include/trace/events/libata.h:381:
> +            TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
> 
> ERROR: space prohibited after that open parenthesis '('
> #205: FILE: include/trace/events/libata.h:391:
> +               __field( unsigned int,  ata_port )
> 
> ERROR: space prohibited before that close parenthesis ')'
> #205: FILE: include/trace/events/libata.h:391:
> +               __field( unsigned int,  ata_port )
> 
> ERROR: space prohibited after that open parenthesis '('
> #206: FILE: include/trace/events/libata.h:392:
> +               __array( unsigned int,  class, 2)
> 
> ERROR: space prohibited after that open parenthesis '('
> #207: FILE: include/trace/events/libata.h:393:
> +               __field( int,           rc)
> 
> Otherwise the patch looks fine.
> 
[ .. ]
This is just following the existing coding style used in the trace event
declaration. Seeing that tracepoint generation is quite black magic in
itself I'd rather keep it in-line with the rest of the header file.

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c
index 3bfd9da58473..253dcf903c1b 100644
--- a/drivers/ata/libata-eh.c
+++ b/drivers/ata/libata-eh.c
@@ -2787,12 +2787,19 @@  int ata_eh_reset(struct ata_link *link, int classify,
 
 		/* mark that this EH session started with reset */
 		ehc->last_reset = jiffies;
-		if (reset == hardreset)
+		if (reset == hardreset) {
 			ehc->i.flags |= ATA_EHI_DID_HARDRESET;
-		else
+			trace_ata_link_hardreset_begin(link, classes, deadline);
+		} else {
 			ehc->i.flags |= ATA_EHI_DID_SOFTRESET;
+			trace_ata_link_softreset_begin(link, classes, deadline);
+		}
 
 		rc = ata_do_reset(link, reset, classes, deadline, true);
+		if (reset == hardreset)
+			trace_ata_link_hardreset_end(link, classes, rc);
+		else
+			trace_ata_link_softreset_end(link, classes, rc);
 		if (rc && rc != -EAGAIN) {
 			failed_link = link;
 			goto fail;
@@ -2806,8 +2813,11 @@  int ata_eh_reset(struct ata_link *link, int classify,
 				ata_link_info(slave, "hard resetting link\n");
 
 			ata_eh_about_to_do(slave, NULL, ATA_EH_RESET);
+			trace_ata_slave_hardreset_begin(slave, classes,
+							deadline);
 			tmp = ata_do_reset(slave, reset, classes, deadline,
 					   false);
+			trace_ata_slave_hardreset_end(slave, classes, tmp);
 			switch (tmp) {
 			case -EAGAIN:
 				rc = -EAGAIN;
@@ -2834,7 +2844,9 @@  int ata_eh_reset(struct ata_link *link, int classify,
 			}
 
 			ata_eh_about_to_do(link, NULL, ATA_EH_RESET);
+			trace_ata_link_softreset_begin(link, classes, deadline);
 			rc = ata_do_reset(link, reset, classes, deadline, true);
+			trace_ata_link_softreset_end(link, classes, rc);
 			if (rc) {
 				failed_link = link;
 				goto fail;
diff --git a/include/trace/events/libata.h b/include/trace/events/libata.h
index ab69434e2329..e9fb4d44eeac 100644
--- a/include/trace/events/libata.h
+++ b/include/trace/events/libata.h
@@ -132,6 +132,22 @@ 
 		ata_protocol_name(ATAPI_PROT_PIO),	\
 		ata_protocol_name(ATAPI_PROT_DMA))
 
+#define ata_class_name(class)	{ class, #class }
+#define show_class_name(val)				\
+	__print_symbolic(val,				\
+		ata_class_name(ATA_DEV_UNKNOWN),	\
+		ata_class_name(ATA_DEV_ATA),		\
+		ata_class_name(ATA_DEV_ATA_UNSUP),	\
+		ata_class_name(ATA_DEV_ATAPI),		\
+		ata_class_name(ATA_DEV_ATAPI_UNSUP),	\
+		ata_class_name(ATA_DEV_PMP),		\
+		ata_class_name(ATA_DEV_PMP_UNSUP),	\
+		ata_class_name(ATA_DEV_SEMB),		\
+		ata_class_name(ATA_DEV_SEMB_UNSUP),	\
+		ata_class_name(ATA_DEV_ZAC),		\
+		ata_class_name(ATA_DEV_ZAC_UNSUP),	\
+		ata_class_name(ATA_DEV_NONE))
+
 const char *libata_trace_parse_status(struct trace_seq*, unsigned char);
 #define __parse_status(s) libata_trace_parse_status(p, s)
 
@@ -329,6 +345,78 @@  TRACE_EVENT(ata_eh_link_autopsy_qc,
 		  __parse_eh_err_mask(__entry->eh_err_mask))
 );
 
+DECLARE_EVENT_CLASS(ata_link_reset_begin_template,
+
+	TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
+
+	TP_ARGS(link, class, deadline),
+
+	TP_STRUCT__entry(
+		__field( unsigned int,	ata_port )
+		__array( unsigned int,	class, 2)
+		__field( unsigned long,	deadline)
+	),
+
+	TP_fast_assign(
+		__entry->ata_port	= link->ap->print_id;
+		memcpy(__entry->class, class, 2);
+		__entry->deadline	= deadline;
+	),
+
+	TP_printk("ata_port=%u deadline=%lu classes=[%s,%s]",
+		  __entry->ata_port, __entry->deadline,
+		  show_class_name(__entry->class[0]),
+		  show_class_name(__entry->class[1]))
+);
+
+DEFINE_EVENT(ata_link_reset_begin_template, ata_link_hardreset_begin,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
+	     TP_ARGS(link, class, deadline));
+
+DEFINE_EVENT(ata_link_reset_begin_template, ata_slave_hardreset_begin,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
+	     TP_ARGS(link, class, deadline));
+
+DEFINE_EVENT(ata_link_reset_begin_template, ata_link_softreset_begin,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, unsigned long deadline),
+	     TP_ARGS(link, class, deadline));
+
+DECLARE_EVENT_CLASS(ata_link_reset_end_template,
+
+	TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
+
+	TP_ARGS(link, class, rc),
+
+	TP_STRUCT__entry(
+		__field( unsigned int,	ata_port )
+		__array( unsigned int,	class, 2)
+		__field( int,		rc)
+	),
+
+	TP_fast_assign(
+		__entry->ata_port	= link->ap->print_id;
+		memcpy(__entry->class, class, 2);
+		__entry->rc		= rc;
+	),
+
+	TP_printk("ata_port=%u rc=%d class=[%s,%s]",
+		  __entry->ata_port, __entry->rc,
+		  show_class_name(__entry->class[0]),
+		  show_class_name(__entry->class[1]))
+);
+
+DEFINE_EVENT(ata_link_reset_end_template, ata_link_hardreset_end,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
+	     TP_ARGS(link, class, rc));
+
+DEFINE_EVENT(ata_link_reset_end_template, ata_slave_hardreset_end,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
+	     TP_ARGS(link, class, rc));
+
+DEFINE_EVENT(ata_link_reset_end_template, ata_link_softreset_end,
+	     TP_PROTO(struct ata_link *link, unsigned int *class, int rc),
+	     TP_ARGS(link, class, rc));
+
 #endif /*  _TRACE_LIBATA_H */
 
 /* This part must be outside protection */