* [PATCH V2 1/3] block: add a zone condition debug helper
2020-02-18 17:28 [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
@ 2020-02-18 17:28 ` Chaitanya Kulkarni
2020-02-19 1:58 ` Damien Le Moal
2020-02-18 17:28 ` [PATCH V2 2/3] null_blk: add tracepoint helpers for zoned mode Chaitanya Kulkarni
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-18 17:28 UTC (permalink / raw)
To: damien.lemoal, axboe; +Cc: linux-block, Chaitanya Kulkarni
Add a helper to stringify the zone conditions. We use this helper in the
next patch to track zone conditions in tracepoints.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
Changes from V1 : -
1. Move blk_zone_cond_str() to blk-zoned.c.
2. Mark zone_cond_namd array static.
3. Remove BLK_ZONE_COND_LAST.
4. Get rid of inline prefix for blk_zone_cond_str().
---
block/blk-zoned.c | 32 ++++++++++++++++++++++++++++++++
include/linux/blkdev.h | 10 ++++++++++
2 files changed, 42 insertions(+)
diff --git a/block/blk-zoned.c b/block/blk-zoned.c
index 05741c6f618b..f18f1ee9d71f 100644
--- a/block/blk-zoned.c
+++ b/block/blk-zoned.c
@@ -20,6 +20,38 @@
#include "blk.h"
+#define ZONE_COND_NAME(name) [BLK_ZONE_COND_##name] = #name
+static const char *const zone_cond_name[] = {
+ ZONE_COND_NAME(NOT_WP),
+ ZONE_COND_NAME(EMPTY),
+ ZONE_COND_NAME(IMP_OPEN),
+ ZONE_COND_NAME(EXP_OPEN),
+ ZONE_COND_NAME(CLOSED),
+ ZONE_COND_NAME(READONLY),
+ ZONE_COND_NAME(FULL),
+ ZONE_COND_NAME(OFFLINE),
+};
+#undef ZONE_COND_NAME
+
+/**
+ * blk_zone_cond_str - Return string XXX in BLK_ZONE_COND_XXX.
+ * @zone_cond: BLK_ZONE_COND_XXX.
+ *
+ * Description: Centralize block layer function to convert BLK_ZONE_COND_XXX
+ * into string format. Useful in the debugging and tracing zone conditions. For
+ * invalid BLK_ZONE_COND_XXX it returns string "UNKNOWN".
+ */
+const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
+{
+ static const char *zone_cond_str = "UNKNOWN";
+
+ if (zone_cond < ARRAY_SIZE(zone_cond_name) && zone_cond_name[zone_cond])
+ zone_cond_str = zone_cond_name[zone_cond];
+
+ return zone_cond_str;
+}
+EXPORT_SYMBOL_GPL(blk_zone_cond_str);
+
static inline sector_t blk_zone_start(struct request_queue *q,
sector_t sector)
{
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index 053ea4b51988..a40a3a27bfbc 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -887,6 +887,16 @@ extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
/* Helper to convert REQ_OP_XXX to its string format XXX */
extern const char *blk_op_str(unsigned int op);
+#ifdef CONFIG_BLK_DEV_ZONED
+/* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
+extern const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
+#else
+static const char *blk_zone_cond_str(unsigned int zone_cond)
+{
+ return "NOT SUPPORTED";
+}
+#endif /* CONFIG_BLK_DEV_ZONED */
+
int blk_status_to_errno(blk_status_t status);
blk_status_t errno_to_blk_status(int errno);
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH V2 1/3] block: add a zone condition debug helper
2020-02-18 17:28 ` [PATCH V2 1/3] block: add a zone condition debug helper Chaitanya Kulkarni
@ 2020-02-19 1:58 ` Damien Le Moal
0 siblings, 0 replies; 8+ messages in thread
From: Damien Le Moal @ 2020-02-19 1:58 UTC (permalink / raw)
To: Chaitanya Kulkarni, axboe@kernel.dk; +Cc: linux-block@vger.kernel.org
On 2020/02/19 2:29, Chaitanya Kulkarni wrote:
> Add a helper to stringify the zone conditions. We use this helper in the
> next patch to track zone conditions in tracepoints.
>
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
> Changes from V1 : -
>
> 1. Move blk_zone_cond_str() to blk-zoned.c.
> 2. Mark zone_cond_namd array static.
> 3. Remove BLK_ZONE_COND_LAST.
> 4. Get rid of inline prefix for blk_zone_cond_str().
> ---
> block/blk-zoned.c | 32 ++++++++++++++++++++++++++++++++
> include/linux/blkdev.h | 10 ++++++++++
> 2 files changed, 42 insertions(+)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 05741c6f618b..f18f1ee9d71f 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -20,6 +20,38 @@
>
> #include "blk.h"
>
> +#define ZONE_COND_NAME(name) [BLK_ZONE_COND_##name] = #name
> +static const char *const zone_cond_name[] = {
> + ZONE_COND_NAME(NOT_WP),
> + ZONE_COND_NAME(EMPTY),
> + ZONE_COND_NAME(IMP_OPEN),
> + ZONE_COND_NAME(EXP_OPEN),
> + ZONE_COND_NAME(CLOSED),
> + ZONE_COND_NAME(READONLY),
> + ZONE_COND_NAME(FULL),
> + ZONE_COND_NAME(OFFLINE),
> +};
> +#undef ZONE_COND_NAME
> +
> +/**
> + * blk_zone_cond_str - Return string XXX in BLK_ZONE_COND_XXX.
> + * @zone_cond: BLK_ZONE_COND_XXX.
> + *
> + * Description: Centralize block layer function to convert BLK_ZONE_COND_XXX
> + * into string format. Useful in the debugging and tracing zone conditions. For
> + * invalid BLK_ZONE_COND_XXX it returns string "UNKNOWN".
> + */
> +const char *blk_zone_cond_str(enum blk_zone_cond zone_cond)
> +{
> + static const char *zone_cond_str = "UNKNOWN";
> +
> + if (zone_cond < ARRAY_SIZE(zone_cond_name) && zone_cond_name[zone_cond])
> + zone_cond_str = zone_cond_name[zone_cond];
> +
> + return zone_cond_str;
> +}
> +EXPORT_SYMBOL_GPL(blk_zone_cond_str);
> +
> static inline sector_t blk_zone_start(struct request_queue *q,
> sector_t sector)
> {
> diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
> index 053ea4b51988..a40a3a27bfbc 100644
> --- a/include/linux/blkdev.h
> +++ b/include/linux/blkdev.h
> @@ -887,6 +887,16 @@ extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
> /* Helper to convert REQ_OP_XXX to its string format XXX */
> extern const char *blk_op_str(unsigned int op);
>
> +#ifdef CONFIG_BLK_DEV_ZONED
> +/* Helper to convert BLK_ZONE_ZONE_XXX to its string format XXX */
> +extern const char *blk_zone_cond_str(enum blk_zone_cond zone_cond);
> +#else
> +static const char *blk_zone_cond_str(unsigned int zone_cond)
> +{
> + return "NOT SUPPORTED";
> +}
why not inline ? That compiles ? Please check builds with
CONFIG_BLK_DEV_ZONED disabled.
> +#endif /* CONFIG_BLK_DEV_ZONED */
> +
> int blk_status_to_errno(blk_status_t status);
> blk_status_t errno_to_blk_status(int errno);
>
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH V2 2/3] null_blk: add tracepoint helpers for zoned mode
2020-02-18 17:28 [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
2020-02-18 17:28 ` [PATCH V2 1/3] block: add a zone condition debug helper Chaitanya Kulkarni
@ 2020-02-18 17:28 ` Chaitanya Kulkarni
2020-02-18 17:28 ` [PATCH V2 3/3] null_blk: add trace in null_blk_zoned.c Chaitanya Kulkarni
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-18 17:28 UTC (permalink / raw)
To: damien.lemoal, axboe; +Cc: linux-block, Chaitanya Kulkarni
This patch adds two new tracpoints for null_blk_zoned.c that allows us
to trace report-zones, zone-mgmt-op and zone-write operations which has
direct effect on the zone condition state machine.
Also, we update drivers/block/Makefile so that new null_blk related
tracefiles can be compiled.
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
Changes from V1:-
1. Use CONFIG_BLK_DEV_ZONE for null_blk_trace.o.
--
drivers/block/Makefile | 3 ++
drivers/block/null_blk_trace.c | 20 +++++++++
drivers/block/null_blk_trace.h | 78 ++++++++++++++++++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 drivers/block/null_blk_trace.c
create mode 100644 drivers/block/null_blk_trace.h
diff --git a/drivers/block/Makefile b/drivers/block/Makefile
index a53cc1e3a2d3..675eadbb8a91 100644
--- a/drivers/block/Makefile
+++ b/drivers/block/Makefile
@@ -6,6 +6,8 @@
# Rewritten to use lists instead of if-statements.
#
+ccflags-y += -I$(src)
+
obj-$(CONFIG_MAC_FLOPPY) += swim3.o
obj-$(CONFIG_BLK_DEV_SWIM) += swim_mod.o
obj-$(CONFIG_BLK_DEV_FD) += floppy.o
@@ -39,6 +41,7 @@ obj-$(CONFIG_ZRAM) += zram/
obj-$(CONFIG_BLK_DEV_NULL_BLK) += null_blk.o
null_blk-objs := null_blk_main.o
+null_blk-$(CONFIG_BLK_DEV_ZONED) += null_blk_trace.o
null_blk-$(CONFIG_BLK_DEV_ZONED) += null_blk_zoned.o
skd-y := skd_main.o
diff --git a/drivers/block/null_blk_trace.c b/drivers/block/null_blk_trace.c
new file mode 100644
index 000000000000..bd066130ff39
--- /dev/null
+++ b/drivers/block/null_blk_trace.c
@@ -0,0 +1,20 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/*
+ * All trace related helpers for null_blk goes here.
+ */
+#include "null_blk_trace.h"
+
+/*
+ * Helper to use for all null_blk traces to extract disk name.
+ */
+const char *nullb_trace_disk_name(struct trace_seq *p, char *name)
+{
+ const char *ret = trace_seq_buffer_ptr(p);
+
+ if (name && *name)
+ trace_seq_printf(p, "disk=%s, ", name);
+ trace_seq_putc(p, 0);
+
+ return ret;
+}
diff --git a/drivers/block/null_blk_trace.h b/drivers/block/null_blk_trace.h
new file mode 100644
index 000000000000..8171bc26f6d1
--- /dev/null
+++ b/drivers/block/null_blk_trace.h
@@ -0,0 +1,78 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * null_blk device driver tracepoints.
+ */
+
+#undef TRACE_SYSTEM
+#define TRACE_SYSTEM nullb
+
+#if !defined(_TRACE_NULLB_H) || defined(TRACE_HEADER_MULTI_READ)
+#define _TRACE_NULLB_H
+
+#include <linux/tracepoint.h>
+#include <linux/trace_seq.h>
+
+#include "null_blk.h"
+
+const char *nullb_trace_disk_name(struct trace_seq *p, char *name);
+
+#define __print_disk_name(name) \
+ nullb_trace_disk_name(p, name)
+
+#ifndef TRACE_HEADER_MULTI_READ
+static inline void __assign_disk_name(char *name, struct gendisk *disk)
+{
+ if (disk)
+ memcpy(name, disk->disk_name, DISK_NAME_LEN);
+ else
+ memset(name, 0, DISK_NAME_LEN);
+}
+#endif
+
+TRACE_EVENT(nullb_zone_op,
+ TP_PROTO(struct nullb_cmd *cmd, unsigned int zone_no,
+ unsigned int zone_cond),
+ TP_ARGS(cmd, zone_no, zone_cond),
+ TP_STRUCT__entry(
+ __array(char, disk, DISK_NAME_LEN)
+ __field(enum req_opf, op)
+ __field(unsigned int, zone_no)
+ __field(unsigned int, zone_cond)
+ ),
+ TP_fast_assign(
+ __entry->op = req_op(cmd->rq);
+ __entry->zone_no = zone_no;
+ __entry->zone_cond = zone_cond;
+ __assign_disk_name(__entry->disk, cmd->rq->rq_disk);
+ ),
+ TP_printk("%s req=%-15s zone_no=%u zone_cond=%-10s",
+ __print_disk_name(__entry->disk),
+ blk_op_str(__entry->op),
+ __entry->zone_no,
+ blk_zone_cond_str(__entry->zone_cond))
+);
+
+TRACE_EVENT(nullb_report_zones,
+ TP_PROTO(struct nullb *nullb, unsigned int nr_zones),
+ TP_ARGS(nullb, nr_zones),
+ TP_STRUCT__entry(
+ __array(char, disk, DISK_NAME_LEN)
+ __field(unsigned int, nr_zones)
+ ),
+ TP_fast_assign(
+ __entry->nr_zones = nr_zones;
+ __assign_disk_name(__entry->disk, nullb->disk);
+ ),
+ TP_printk("%s nr_zones=%u",
+ __print_disk_name(__entry->disk), __entry->nr_zones)
+);
+
+#endif /* _TRACE_NULLB_H */
+
+#undef TRACE_INCLUDE_PATH
+#define TRACE_INCLUDE_PATH .
+#undef TRACE_INCLUDE_FILE
+#define TRACE_INCLUDE_FILE null_blk_trace
+
+/* This part must be outside protection */
+#include <trace/define_trace.h>
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH V2 3/3] null_blk: add trace in null_blk_zoned.c
2020-02-18 17:28 [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
2020-02-18 17:28 ` [PATCH V2 1/3] block: add a zone condition debug helper Chaitanya Kulkarni
2020-02-18 17:28 ` [PATCH V2 2/3] null_blk: add tracepoint helpers for zoned mode Chaitanya Kulkarni
@ 2020-02-18 17:28 ` Chaitanya Kulkarni
2020-02-19 2:13 ` [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
2020-02-19 16:29 ` Christoph Hellwig
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-18 17:28 UTC (permalink / raw)
To: damien.lemoal, axboe; +Cc: linux-block, Chaitanya Kulkarni
With the help of previously added tracepoints we can now trace
report-zones, zone-write and zone-mgmt ops in null_blk_zoned.c.
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
drivers/block/null_blk_zoned.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/block/null_blk_zoned.c b/drivers/block/null_blk_zoned.c
index ed34785dd64b..673618d8222a 100644
--- a/drivers/block/null_blk_zoned.c
+++ b/drivers/block/null_blk_zoned.c
@@ -2,6 +2,9 @@
#include <linux/vmalloc.h>
#include "null_blk.h"
+#define CREATE_TRACE_POINTS
+#include "null_blk_trace.h"
+
/* zone_size in MBs to sectors. */
#define ZONE_SIZE_SHIFT 11
@@ -80,6 +83,8 @@ int null_report_zones(struct gendisk *disk, sector_t sector,
return 0;
nr_zones = min(nr_zones, dev->nr_zones - first_zone);
+ trace_nullb_report_zones(nullb, nr_zones);
+
for (i = 0; i < nr_zones; i++) {
/*
* Stacked DM target drivers will remap the zone information by
@@ -148,6 +153,8 @@ static blk_status_t null_zone_write(struct nullb_cmd *cmd, sector_t sector,
/* Invalid zone condition */
return BLK_STS_IOERR;
}
+
+ trace_nullb_zone_op(cmd, zno, zone->cond);
return BLK_STS_OK;
}
@@ -155,7 +162,8 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
sector_t sector)
{
struct nullb_device *dev = cmd->nq->dev;
- struct blk_zone *zone = &dev->zones[null_zone_no(dev, sector)];
+ unsigned int zone_no = null_zone_no(dev, sector);
+ struct blk_zone *zone = &dev->zones[zone_no];
size_t i;
switch (op) {
@@ -203,6 +211,8 @@ static blk_status_t null_zone_mgmt(struct nullb_cmd *cmd, enum req_opf op,
default:
return BLK_STS_NOTSUPP;
}
+
+ trace_nullb_zone_op(cmd, zone_no, zone->cond);
return BLK_STS_OK;
}
--
2.22.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode
2020-02-18 17:28 [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
` (2 preceding siblings ...)
2020-02-18 17:28 ` [PATCH V2 3/3] null_blk: add trace in null_blk_zoned.c Chaitanya Kulkarni
@ 2020-02-19 2:13 ` Chaitanya Kulkarni
2020-02-19 16:29 ` Christoph Hellwig
4 siblings, 0 replies; 8+ messages in thread
From: Chaitanya Kulkarni @ 2020-02-19 2:13 UTC (permalink / raw)
To: Damien Le Moal, axboe@kernel.dk; +Cc: linux-block@vger.kernel.org
Jens please ignore this, I'll send a new one.
On 02/18/2020 09:28 AM, Chaitanya Kulkarni wrote:
> Hi,
>
> Recently we've added several new operations for zoned block devices
> blk-zone.c ZBD). These operations have a direct effect on the
> zone-state machine present in the null_blk_zoned.c.
>
> This will allow us to add new testcases in blktests in order to verify
> the correct operations on the driver side.
>
> This is a small patch series which adds tracepoints for the null_blk
> block driver when configured in a zoned mode (with command line
> parameter zoned=1).
>
> The first patch is a prep patch that adds a helper to stringify zone
> conditions which we use in the trace, the second patch adds new
> tracepoint definitions and the third patch allows null_blk_zoned to
> trace operations.
>
> Please have a look at the end for sample output.
>
> The change-log is present in the respective patches.
>
> Regards,
> Chaitanya
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode
2020-02-18 17:28 [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
` (3 preceding siblings ...)
2020-02-19 2:13 ` [PATCH V2 0/3] null_blk: add tracnepoints for zoned mode Chaitanya Kulkarni
@ 2020-02-19 16:29 ` Christoph Hellwig
2020-02-19 17:44 ` Chaitanya Kulkarni
4 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2020-02-19 16:29 UTC (permalink / raw)
To: Chaitanya Kulkarni; +Cc: damien.lemoal, axboe, linux-block
s/tracnepoints/tracepoints/ ?
^ permalink raw reply [flat|nested] 8+ messages in thread