Re: [PATCH RFC 2/2] tracing/block: add request operation and flags into trace events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 04 May 2020 18:16:21 +0300
Konstantin Khlebnikov <khlebnikov@xxxxxxxxxxxxxx> wrote:

> +/* Request operations, see enum req_opf */
> +
> +TRACE_DEFINE_ENUM(REQ_OP_READ);
> +TRACE_DEFINE_ENUM(REQ_OP_WRITE);
> +TRACE_DEFINE_ENUM(REQ_OP_FLUSH);
> +TRACE_DEFINE_ENUM(REQ_OP_DISCARD);
> +TRACE_DEFINE_ENUM(REQ_OP_SECURE_ERASE);
> +TRACE_DEFINE_ENUM(REQ_OP_ZONE_RESET);
> +TRACE_DEFINE_ENUM(REQ_OP_WRITE_SAME);
> +TRACE_DEFINE_ENUM(REQ_OP_ZONE_RESET_ALL);
> +TRACE_DEFINE_ENUM(REQ_OP_WRITE_ZEROES);
> +TRACE_DEFINE_ENUM(REQ_OP_ZONE_OPEN);
> +TRACE_DEFINE_ENUM(REQ_OP_ZONE_CLOSE);
> +TRACE_DEFINE_ENUM(REQ_OP_ZONE_FINISH);
> +TRACE_DEFINE_ENUM(REQ_OP_SCSI_IN);
> +TRACE_DEFINE_ENUM(REQ_OP_SCSI_OUT);
> +TRACE_DEFINE_ENUM(REQ_OP_DRV_IN);
> +TRACE_DEFINE_ENUM(REQ_OP_DRV_OUT);
> +
> +#define BLOCK_REQ_OP_STRINGS					\
> +	{ REQ_OP_READ,		"READ" },			\
> +	{ REQ_OP_WRITE,		"WRITE" },			\
> +	{ REQ_OP_FLUSH,		"FLUSH" },			\
> +	{ REQ_OP_DISCARD,	"DISCARD" },			\
> +	{ REQ_OP_SECURE_ERASE,	"SECURE_ERASE" },		\
> +	{ REQ_OP_ZONE_RESET,	"ZONE_RESET" },			\
> +	{ REQ_OP_WRITE_SAME,	"WRITE_SAME" },			\
> +	{ REQ_OP_ZONE_RESET_ALL,"ZONE_RESET_ALL" },		\
> +	{ REQ_OP_WRITE_ZEROES,	"WRITE_ZEROES" },		\
> +	{ REQ_OP_ZONE_OPEN,	"ZONE_OPEN" },			\
> +	{ REQ_OP_ZONE_CLOSE,	"ZONE_CLOSE" },			\
> +	{ REQ_OP_ZONE_FINISH,	"ZONE_FINISH" },		\
> +	{ REQ_OP_SCSI_IN,	"SCSI_IN" },			\
> +	{ REQ_OP_SCSI_OUT,	"SCSI_OUT" },			\
> +	{ REQ_OP_DRV_IN,	"DRV_IN" },			\
> +	{ REQ_OP_DRV_OUT,	"DRV_OUT" }
> +
> +#define show_block_req_op(req)					\
> +	__print_symbolic((req) & REQ_OP_MASK, BLOCK_REQ_OP_STRINGS)
> +

A common trick to avoid the duplication from above is to do this:

#define BLOCK_REQ_OP_STRINGS					\
	EM( REQ_OP_READ,	"READ" )			\
	EM( REQ_OP_WRITE,	"WRITE" )			\
	EM( REQ_OP_FLUSH,	"FLUSH" )			\
	EM( REQ_OP_DISCARD,	"DISCARD" )			\
	EM( REQ_OP_SECURE_ERASE, "SECURE_ERASE" )		\
	EM( REQ_OP_ZONE_RESET,	"ZONE_RESET" )			\
	EM( REQ_OP_WRITE_SAME,	"WRITE_SAME" )			\
	EM( REQ_OP_ZONE_RESET_ALL,"ZONE_RESET_ALL" )		\
	EM( REQ_OP_WRITE_ZEROES, "WRITE_ZEROES" )		\
	EM( REQ_OP_ZONE_OPEN,	"ZONE_OPEN" )			\
	EM( REQ_OP_ZONE_CLOSE,	"ZONE_CLOSE" )			\
	EM( REQ_OP_ZONE_FINISH,	"ZONE_FINISH" )			\
	EM( REQ_OP_SCSI_IN,	"SCSI_IN" )			\
	EM( REQ_OP_SCSI_OUT,	"SCSI_OUT" )			\
	EM( REQ_OP_DRV_IN,	"DRV_IN" )			\
	EMe( REQ_OP_DRV_OUT,	"DRV_OUT" )

#undef EM
#undef EMe

#define EM(a, b) TRACE_DEFINE_ENUM(a);
#define EMe(a, b) TRACE_DEFINE_ENUM(a);

BLOCK_REQ_OP_STRINGS

#undef EM
#undef EMe

#define EM(a, b) { a, b },
#define EMe(a, b)  { a , b }

#define show_block_req_op(req)
	__print_symbolic((req) & REQ_OP_MASK, BLOCK_REQ_OP_STRINGS)


Several other event files in include/trace/events do this.

-- Steve




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux