diff mbox series

[RFC,08/39] blktrace: update blk_add_trace_rq()

Message ID 20210225070231.21136-9-chaitanya.kulkarni@wdc.com (mailing list archive)
State New
Headers show
Series blktrace: add block trace extension support | expand

Commit Message

Chaitanya Kulkarni Feb. 25, 2021, 7:02 a.m. UTC
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
---
 kernel/trace/blktrace.c | 30 +++++++++++++++++++++---------
 1 file changed, 21 insertions(+), 9 deletions(-)

Comments

Damien Le Moal Feb. 26, 2021, 4:46 a.m. UTC | #1
On 2021/02/25 16:04, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>

No commit message.

> ---
>  kernel/trace/blktrace.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 1aef55fdefa9..280ad94f99b6 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -1099,24 +1099,36 @@ blk_trace_request_get_cgid(struct request *rq)
>   *
>   **/
>  static void blk_add_trace_rq(struct request *rq, int error,
> -			     unsigned int nr_bytes, u32 what, u64 cgid)
> +			     unsigned int nr_bytes, u64 what, u64 cgid)
>  {
>  	struct blk_trace *bt;
> +	struct blk_trace_ext *bte;
>  
>  	rcu_read_lock();
>  	bt = rcu_dereference(rq->q->blk_trace);
> -	if (likely(!bt)) {
> +	bte = rcu_dereference(rq->q->blk_trace_ext);
> +	if (likely(!bt) && likely(!bte)) {
>  		rcu_read_unlock();
>  		return;
>  	}
>  
> -	if (blk_rq_is_passthrough(rq))
> -		what |= BLK_TC_ACT(BLK_TC_PC);
> -	else
> -		what |= BLK_TC_ACT(BLK_TC_FS);
> -
> -	__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq),
> -			rq->cmd_flags, what, error, 0, NULL, cgid);
> +	if (bt) {
> +		if (blk_rq_is_passthrough(rq))
> +			what |= BLK_TC_ACT(BLK_TC_PC);
> +		else
> +			what |= BLK_TC_ACT(BLK_TC_FS);
> +		__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes,
> +				req_op(rq), rq->cmd_flags, (u32)what, error, 0,
> +				NULL, cgid);
> +	} else if (bte) {
> +		if (blk_rq_is_passthrough(rq))
> +			what |= BLK_TC_ACT_EXT(BLK_TC_PC);
> +		else
> +			what |= BLK_TC_ACT_EXT(BLK_TC_FS);
> +		__blk_add_trace_ext(bte, blk_rq_trace_sector(rq), nr_bytes,
> +				    req_op(rq), rq->cmd_flags, what, error, 0,
> +				    NULL, cgid, req_get_ioprio(rq));
> +	}

I fail to see why you cannot reuse __blk_add_trace() with the what argument
changed to a 64bit, exactly like you did for this blk_add_trace_rq() function.

>  	rcu_read_unlock();
>  }
>  
>
diff mbox series

Patch

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 1aef55fdefa9..280ad94f99b6 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1099,24 +1099,36 @@  blk_trace_request_get_cgid(struct request *rq)
  *
  **/
 static void blk_add_trace_rq(struct request *rq, int error,
-			     unsigned int nr_bytes, u32 what, u64 cgid)
+			     unsigned int nr_bytes, u64 what, u64 cgid)
 {
 	struct blk_trace *bt;
+	struct blk_trace_ext *bte;
 
 	rcu_read_lock();
 	bt = rcu_dereference(rq->q->blk_trace);
-	if (likely(!bt)) {
+	bte = rcu_dereference(rq->q->blk_trace_ext);
+	if (likely(!bt) && likely(!bte)) {
 		rcu_read_unlock();
 		return;
 	}
 
-	if (blk_rq_is_passthrough(rq))
-		what |= BLK_TC_ACT(BLK_TC_PC);
-	else
-		what |= BLK_TC_ACT(BLK_TC_FS);
-
-	__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq),
-			rq->cmd_flags, what, error, 0, NULL, cgid);
+	if (bt) {
+		if (blk_rq_is_passthrough(rq))
+			what |= BLK_TC_ACT(BLK_TC_PC);
+		else
+			what |= BLK_TC_ACT(BLK_TC_FS);
+		__blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes,
+				req_op(rq), rq->cmd_flags, (u32)what, error, 0,
+				NULL, cgid);
+	} else if (bte) {
+		if (blk_rq_is_passthrough(rq))
+			what |= BLK_TC_ACT_EXT(BLK_TC_PC);
+		else
+			what |= BLK_TC_ACT_EXT(BLK_TC_FS);
+		__blk_add_trace_ext(bte, blk_rq_trace_sector(rq), nr_bytes,
+				    req_op(rq), rq->cmd_flags, what, error, 0,
+				    NULL, cgid, req_get_ioprio(rq));
+	}
 	rcu_read_unlock();
 }