linux-trace-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Damien Le Moal <dlemoal@kernel.org>
To: Johannes Thumshirn <johannes.thumshirn@wdc.com>, axboe@kernel.dk
Cc: chaitanyak@nvidia.com, hare@suse.de, hch@lst.de,
	john.g.garry@oracle.com, linux-block@vger.kernel.org,
	linux-btrace@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-trace-kernel@vger.kernel.org, martin.petersen@oracle.com,
	mathieu.desnoyers@efficios.com, mhiramat@kernel.org,
	naohiro.aota@wdc.com, rostedt@goodmis.org,
	shinichiro.kawasaki@wdc.com
Subject: Re: [PATCH v4 13/16] blktrace: add block trace commands for zone operations
Date: Wed, 22 Oct 2025 05:57:59 +0900	[thread overview]
Message-ID: <cc2b4fda-9e7c-4b97-b83b-1297ea931aea@kernel.org> (raw)
In-Reply-To: <20251020134123.119058-14-johannes.thumshirn@wdc.com>

On 10/20/25 22:41, Johannes Thumshirn wrote:
> Add block trace commands for zone operations. These commands can only be
> handled with version 2 of the blktrace protocol. For version 1, warn if a
> command that does not fit into the 16 bits reserved for the command in
> this version is passed in.
> 
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
> ---
>  include/uapi/linux/blktrace_api.h | 13 +++++++++++--
>  kernel/trace/blktrace.c           | 28 ++++++++++++++++++++++++----
>  2 files changed, 35 insertions(+), 6 deletions(-)
> 
> diff --git a/include/uapi/linux/blktrace_api.h b/include/uapi/linux/blktrace_api.h
> index 3a771b9802aa..925f78af939e 100644
> --- a/include/uapi/linux/blktrace_api.h
> +++ b/include/uapi/linux/blktrace_api.h
> @@ -26,11 +26,20 @@ enum blktrace_cat {
>  	BLK_TC_DRV_DATA	= 1 << 14,	/* binary per-driver data */
>  	BLK_TC_FUA	= 1 << 15,	/* fua requests */
>  
> -	BLK_TC_END	= 1 << 15,	/* we've run out of bits! */
> +	BLK_TC_END_V1	= 1 << 15,	/* we've run out of bits! */
> +
> +	BLK_TC_ZONE_APPEND	= 1ull << 16,  	/* zone append */
> +	BLK_TC_ZONE_RESET	= 1ull << 17,	/* zone reset */
> +	BLK_TC_ZONE_RESET_ALL	= 1ull << 18,	/* zone reset all */
> +	BLK_TC_ZONE_FINISH	= 1ull << 19,	/* zone finish */
> +	BLK_TC_ZONE_OPEN	= 1ull << 20,	/* zone open */
> +	BLK_TC_ZONE_CLOSE	= 1ull << 21,	/* zone close */
> +
> +	BLK_TC_END_V2		= 1ull << 21,
>  };
>  
>  #define BLK_TC_SHIFT		(16)
> -#define BLK_TC_ACT(act)		((act) << BLK_TC_SHIFT)
> +#define BLK_TC_ACT(act)		((u64)(act) << BLK_TC_SHIFT)
>  
>  /*
>   * Basic trace actions
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 8ffb218e9fb7..e8effb6cb393 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -163,8 +163,8 @@ static void relay_blktrace_event(struct blk_trace *bt, unsigned long sequence,
>  					     bytes, what, error, cgid, cgid_len,
>  					     pdu_data, pdu_len);
>  	return relay_blktrace_event1(bt, sequence, pid, cpu, sector, bytes,
> -				     lower_32_bits(what), error, cgid, cgid_len,
> -				     pdu_data, pdu_len);
> +				     what, error, cgid, cgid_len, pdu_data,
> +				     pdu_len);
>  }
>  
>  /*
> @@ -342,10 +342,31 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
>  	case REQ_OP_FLUSH:
>  		what |= BLK_TC_ACT(BLK_TC_FLUSH);
>  		break;
> +	case REQ_OP_ZONE_APPEND:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_APPEND);
> +		break;
> +	case REQ_OP_ZONE_RESET:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_RESET);
> +		break;
> +	case REQ_OP_ZONE_RESET_ALL:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_RESET_ALL);
> +		break;
> +	case REQ_OP_ZONE_FINISH:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_FINISH);
> +		break;
> +	case REQ_OP_ZONE_OPEN:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_OPEN);
> +		break;
> +	case REQ_OP_ZONE_CLOSE:
> +		what |= BLK_TC_ACT(BLK_TC_ZONE_CLOSE);
> +		break;
>  	default:
>  		break;
>  	}
>  
> +	WARN_ON_ONCE(bt->version == 1 &&
> +		     (what >> BLK_TC_SHIFT) > BLK_TC_END_V1);

Shouldn't this be a "if (WARN_ON_ONCE())" and return doing nothing if true ?

> +
>  	if (cgid)
>  		what |= __BLK_TA_CGROUP;
>  
> @@ -386,8 +407,7 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes,
>  	sequence = per_cpu_ptr(bt->sequence, cpu);
>  	(*sequence)++;
>  	relay_blktrace_event(bt, *sequence, pid, cpu, sector, bytes,
> -			     lower_32_bits(what), error, cgid, cgid_len,
> -			     pdu_data, pdu_len);
> +			     what, error, cgid, cgid_len, pdu_data, pdu_len);
>  	local_irq_restore(flags);
>  }
>  


-- 
Damien Le Moal
Western Digital Research

  reply	other threads:[~2025-10-21 20:58 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 13:41 [PATCH v4 00/16] block: add blktrace support for zoned block devies Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 01/16] blktrace: only calculate trace length once Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 02/16] blktrace: factor out recording a blktrace event Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 03/16] blktrace: split out relaying " Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 04/16] blktrace: untangle if/else sequence in __blk_add_trace Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 05/16] blktrace: change the internal action to 64bit Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 06/16] blktrace: split do_blk_trace_setup into two functions Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 07/16] blktrace: add definitions for blk_user_trace_setup2 Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 08/16] blktrace: pass blk_user_trace2 to setup functions Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 09/16] blktrace: add definitions for struct blk_io_trace2 Johannes Thumshirn
2025-10-21 20:51   ` Damien Le Moal
2025-10-20 13:41 ` [PATCH v4 10/16] blktrace: differentiate between blk_io_trace versions Johannes Thumshirn
2025-10-21 20:54   ` Damien Le Moal
2025-10-20 13:41 ` [PATCH v4 11/16] blktrace: move trace_note to blk_io_trace2 Johannes Thumshirn
2025-10-21 20:55   ` Damien Le Moal
2025-10-20 13:41 ` [PATCH v4 12/16] blktrace: move ftrace blk_io_tracer " Johannes Thumshirn
2025-10-21 20:55   ` Damien Le Moal
2025-10-20 13:41 ` [PATCH v4 13/16] blktrace: add block trace commands for zone operations Johannes Thumshirn
2025-10-21 20:57   ` Damien Le Moal [this message]
2025-10-20 13:41 ` [PATCH v4 14/16] blktrace: expose ZONE APPEND completions to blktrace Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 15/16] blktrace: trace zone write plugging operations Johannes Thumshirn
2025-10-20 13:41 ` [PATCH v4 16/16] blktrace: handle BLKTRACESETUP2 ioctl Johannes Thumshirn
2025-10-21  2:25 ` [PATCH v4 00/16] block: add blktrace support for zoned block devies Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=cc2b4fda-9e7c-4b97-b83b-1297ea931aea@kernel.org \
    --to=dlemoal@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=chaitanyak@nvidia.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=johannes.thumshirn@wdc.com \
    --cc=john.g.garry@oracle.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrace@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=rostedt@goodmis.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).