diff mbox series

[v2] scsi: sd_zbc: trace zone append emulation

Message ID 6a21e78a188e5a0d630acd771afee11c7d45d183.1668427228.git.johannes.thumshirn@wdc.com
State Superseded
Headers show
Series [v2] scsi: sd_zbc: trace zone append emulation | expand

Commit Message

Johannes Thumshirn Nov. 14, 2022, 12:01 p.m. UTC
Add tracepoints to the SCSI zone append emulation, in order to trace the
zone start to write-pointer aligned LBA translation and the corresponding
completion.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>

---
Changes to v1:
- Fix style issues pointed out by Damien
---
 drivers/scsi/sd_zbc.c       |  5 +++
 include/trace/events/scsi.h | 64 +++++++++++++++++++++++++++++++++++++
 2 files changed, 69 insertions(+)

Comments

kernel test robot Nov. 14, 2022, 10:42 p.m. UTC | #1
Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on jejb-scsi/for-next linus/master v6.1-rc5 next-20221114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/6a21e78a188e5a0d630acd771afee11c7d45d183.1668427228.git.johannes.thumshirn%40wdc.com
patch subject: [PATCH v2] scsi: sd_zbc: trace zone append emulation
config: i386-randconfig-a014-20221114
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7bb40ba431073a283c1db669aee4142045dd0976
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
        git checkout 7bb40ba431073a283c1db669aee4142045dd0976
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "__tracepoint_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCT__tp_func_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__tracepoint_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCT__tp_func_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
kernel test robot Nov. 15, 2022, 2:24 a.m. UTC | #2
Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on jejb-scsi/for-next linus/master v6.1-rc5 next-20221114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/6a21e78a188e5a0d630acd771afee11c7d45d183.1668427228.git.johannes.thumshirn%40wdc.com
patch subject: [PATCH v2] scsi: sd_zbc: trace zone append emulation
config: arm64-randconfig-c004-20221114
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/7bb40ba431073a283c1db669aee4142045dd0976
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
        git checkout 7bb40ba431073a283c1db669aee4142045dd0976
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

ERROR: modpost: "__tracepoint_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__traceiter_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
ERROR: modpost: "__tracepoint_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__traceiter_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
kernel test robot Nov. 15, 2022, 5:26 a.m. UTC | #3
Hi Johannes,

I love your patch! Yet something to improve:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on jejb-scsi/for-next linus/master v6.1-rc5 next-20221114]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/6a21e78a188e5a0d630acd771afee11c7d45d183.1668427228.git.johannes.thumshirn%40wdc.com
patch subject: [PATCH v2] scsi: sd_zbc: trace zone append emulation
config: x86_64-rhel-8.3-func
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
        # https://github.com/intel-lab-lkp/linux/commit/7bb40ba431073a283c1db669aee4142045dd0976
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Johannes-Thumshirn/scsi-sd_zbc-trace-zone-append-emulation/20221114-200424
        git checkout 7bb40ba431073a283c1db669aee4142045dd0976
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>, old ones prefixed by <<):

>> ERROR: modpost: "__tracepoint_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCK__tp_func_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCK__tp_func_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCT__tp_func_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__tracepoint_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>> ERROR: modpost: "__SCT__tp_func_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
Johannes Thumshirn Nov. 28, 2022, 8:54 a.m. UTC | #4
On 26.11.22 03:35, Damien Le Moal wrote:
> On 11/26/22 11:18, Martin K. Petersen wrote:
>>
>> Johannes,
>>
>>>>>> ERROR: modpost: "__tracepoint_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>>>>>> ERROR: modpost: "__SCK__tp_func_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>>>>>> ERROR: modpost: "__SCK__tp_func_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>>>>>> ERROR: modpost: "__SCT__tp_func_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>>>>>> ERROR: modpost: "__tracepoint_scsi_zone_wp_update" [drivers/scsi/sd_mod.ko] undefined!
>>>>>> ERROR: modpost: "__SCT__tp_func_scsi_prepare_zone_append" [drivers/scsi/sd_mod.ko] undefined!
>>>>
>>>
>>> I have no clue what modpost is trying to tell me here. These tracepoints aren't
>>> in any way different to the other tracepoints in SCSI.
>>
>> Haven't investigated. But I get the same errors building scsi-staging
>> with your patch applied. Builds fine without it. gcc 12.1.
>>
> 
> This is missing:
> 
> diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
> index 41a950075913..224b38c0fb0f 100644
> --- a/drivers/scsi/scsi_trace.c
> +++ b/drivers/scsi/scsi_trace.c
> @@ -389,3 +389,4 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned
> char *cdb, int len)
>                 return scsi_trace_misc(p, cdb, len);
>         }
>  }
> +EXPORT_SYMBOL(scsi_trace_parse_cdb);
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 956d1982c51b..e7a0e1ace6d0 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -18,6 +18,7 @@
>  #include <scsi/scsi.h>
>  #include <scsi/scsi_cmnd.h>
> 
> +#define CREATE_TRACE_POINTS
>  #include <trace/events/scsi.h>
> 
>  #include "sd.h"
> 
> With that, it compiles fine.
> 

Thanks, but for me it doesn't when I have scsi_mod builtin,
only as a module :(
If I remove the CREATE_TRACE_POINTS hunk it compiles again as
builtin but breaks as module :(
Johannes Thumshirn Nov. 28, 2022, 9:02 a.m. UTC | #5
On 28.11.22 09:54, Johannes Thumshirn wrote:
>>
>> This is missing:
>>
>> diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
>> index 41a950075913..224b38c0fb0f 100644
>> --- a/drivers/scsi/scsi_trace.c
>> +++ b/drivers/scsi/scsi_trace.c
>> @@ -389,3 +389,4 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned
>> char *cdb, int len)
>>                 return scsi_trace_misc(p, cdb, len);
>>         }
>>  }
>> +EXPORT_SYMBOL(scsi_trace_parse_cdb);
>> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
>> index 956d1982c51b..e7a0e1ace6d0 100644
>> --- a/drivers/scsi/sd_zbc.c
>> +++ b/drivers/scsi/sd_zbc.c
>> @@ -18,6 +18,7 @@
>>  #include <scsi/scsi.h>
>>  #include <scsi/scsi_cmnd.h>
>>
>> +#define CREATE_TRACE_POINTS
>>  #include <trace/events/scsi.h>
>>
>>  #include "sd.h"
>>
>> With that, it compiles fine.
>>
> 
> Thanks, but for me it doesn't when I have scsi_mod builtin,
> only as a module :(
> If I remove the CREATE_TRACE_POINTS hunk it compiles again as
> builtin but breaks as module :(
> 
> 

This is working for me, but having to use #if IS_MODULE() feels
kinda hackish.

Martin your call:

diff --git a/drivers/scsi/scsi_trace.c b/drivers/scsi/scsi_trace.c
index 41a950075913..224b38c0fb0f 100644
--- a/drivers/scsi/scsi_trace.c
+++ b/drivers/scsi/scsi_trace.c
@@ -389,3 +389,4 @@ scsi_trace_parse_cdb(struct trace_seq *p, unsigned char *cdb, int len)
                return scsi_trace_misc(p, cdb, len);
        }
 }
+EXPORT_SYMBOL(scsi_trace_parse_cdb);
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 956d1982c51b..d84578df27c8 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -18,7 +18,10 @@
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 
+#if IS_MODULE(CONFIG_BLK_DEV_SD)
+#define CREATE_TRACE_POINTS
 #include <trace/events/scsi.h>
+#endif
 
 #include "sd.h"
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index bd15624c6322..956d1982c51b 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -18,6 +18,8 @@ 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
 
+#include <trace/events/scsi.h>
+
 #include "sd.h"
 
 /**
@@ -450,6 +452,7 @@  blk_status_t sd_zbc_prepare_zone_append(struct scsi_cmnd *cmd, sector_t *lba,
 			break;
 		}
 
+		trace_scsi_prepare_zone_append(cmd, *lba, wp_offset);
 		*lba += wp_offset;
 	}
 	spin_unlock_irqrestore(&sdkp->zones_wp_offset_lock, flags);
@@ -558,6 +561,8 @@  static unsigned int sd_zbc_zone_wp_update(struct scsi_cmnd *cmd,
 
 	switch (op) {
 	case REQ_OP_ZONE_APPEND:
+		trace_scsi_zone_wp_update(cmd, rq->__sector,
+				  sdkp->zones_wp_offset[zno], good_bytes);
 		rq->__sector += sdkp->zones_wp_offset[zno];
 		fallthrough;
 	case REQ_OP_WRITE_ZEROES:
diff --git a/include/trace/events/scsi.h b/include/trace/events/scsi.h
index a2c7befd451a..851b89e1c811 100644
--- a/include/trace/events/scsi.h
+++ b/include/trace/events/scsi.h
@@ -327,6 +327,70 @@  TRACE_EVENT(scsi_eh_wakeup,
 	TP_printk("host_no=%u", __entry->host_no)
 );
 
+TRACE_EVENT(scsi_prepare_zone_append,
+
+	    TP_PROTO(struct scsi_cmnd *cmnd, sector_t lba,
+		     unsigned int wp_offset),
+
+	    TP_ARGS(cmnd, lba, wp_offset),
+
+	    TP_STRUCT__entry(
+		     __field( unsigned int, host_no )
+		     __field( unsigned int, channel )
+		     __field( unsigned int, id )
+		     __field( unsigned int, lun )
+		     __field( sector_t,     lba )
+		     __field( unsigned int, wp_offset )
+	    ),
+
+	    TP_fast_assign(
+		__entry->host_no	= cmnd->device->host->host_no;
+		__entry->channel	= cmnd->device->channel;
+		__entry->id		= cmnd->device->id;
+		__entry->lun		= cmnd->device->lun;
+		__entry->lba		= lba;
+		__entry->wp_offset	= wp_offset;
+	    ),
+
+	    TP_printk("host_no=%u, channel=%u id=%u lun=%u lba=%llu wp_offset=%u",
+		      __entry->host_no, __entry->channel, __entry->id,
+		      __entry->lun, __entry->lba, __entry->wp_offset)
+);
+
+TRACE_EVENT(scsi_zone_wp_update,
+
+	    TP_PROTO(struct scsi_cmnd *cmnd, sector_t rq_sector,
+		     unsigned int wp_offset, unsigned int good_bytes),
+
+	    TP_ARGS(cmnd, rq_sector, wp_offset, good_bytes),
+
+	    TP_STRUCT__entry(
+		     __field( unsigned int, host_no )
+		     __field( unsigned int, channel )
+		     __field( unsigned int, id )
+		     __field( unsigned int, lun )
+		     __field( sector_t,     rq_sector )
+		     __field( unsigned int, wp_offset )
+		     __field( unsigned int, good_bytes )
+	    ),
+
+	    TP_fast_assign(
+		__entry->host_no	= cmnd->device->host->host_no;
+		__entry->channel	= cmnd->device->channel;
+		__entry->id		= cmnd->device->id;
+		__entry->lun		= cmnd->device->lun;
+		__entry->rq_sector	= rq_sector;
+		__entry->wp_offset	= wp_offset;
+		__entry->good_bytes	= good_bytes;
+	    ),
+
+	    TP_printk("host_no=%u, channel=%u id=%u lun=%u rq_sector=%llu" \
+		      " wp_offset=%u good_bytes=%u",
+		      __entry->host_no, __entry->channel, __entry->id,
+		      __entry->lun, __entry->rq_sector, __entry->wp_offset,
+		      __entry->good_bytes)
+);
+
 #endif /*  _TRACE_SCSI_H */
 
 /* This part must be outside protection */