diff mbox series

[RFC,12/39] blktrace: update blk_add_trace_rq_complete()

Message ID 20210225070231.21136-13-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 | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

Comments

Damien Le Moal Feb. 26, 2021, 4:48 a.m. UTC | #1
On 2021/02/25 16:04, Chaitanya Kulkarni wrote:
> Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
> ---
>  kernel/trace/blktrace.c | 20 +++++++++++++++++++-
>  1 file changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
> index 8a7fedfac6b3..07f71a052a0d 100644
> --- a/kernel/trace/blktrace.c
> +++ b/kernel/trace/blktrace.c
> @@ -1213,7 +1213,25 @@ static void blk_add_trace_rq_requeue(void *ignore, struct request *rq)
>  static void blk_add_trace_rq_complete(void *ignore, struct request *rq,
>  			int error, unsigned int nr_bytes)
>  {
> -	blk_add_trace_rq(rq, error, nr_bytes, BLK_TA_COMPLETE,
> +	u64 ta;
> +	struct blk_trace *bt;
> +	struct blk_trace_ext *bte;
> +
> +	rcu_read_lock();
> +	bt = rcu_dereference(rq->q->blk_trace);
> +	bte = rcu_dereference(rq->q->blk_trace_ext);
> +	if (likely(!bt) && likely(!bte)) {
> +		rcu_read_unlock();
> +		return;
> +	}
> +
> +	if (bt) {
> +		ta = BLK_TA_COMPLETE;
> +	} else if (bte) {
> +		ta = BLK_TA_COMPLETE_EXT;
> +	}
> +	rcu_read_unlock();
> +	blk_add_trace_rq(rq, error, nr_bytes, ta,
>  			 blk_trace_request_get_cgid(rq));
>  }
>  
> 

Same comment as for patch 9.
diff mbox series

Patch

diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
index 8a7fedfac6b3..07f71a052a0d 100644
--- a/kernel/trace/blktrace.c
+++ b/kernel/trace/blktrace.c
@@ -1213,7 +1213,25 @@  static void blk_add_trace_rq_requeue(void *ignore, struct request *rq)
 static void blk_add_trace_rq_complete(void *ignore, struct request *rq,
 			int error, unsigned int nr_bytes)
 {
-	blk_add_trace_rq(rq, error, nr_bytes, BLK_TA_COMPLETE,
+	u64 ta;
+	struct blk_trace *bt;
+	struct blk_trace_ext *bte;
+
+	rcu_read_lock();
+	bt = rcu_dereference(rq->q->blk_trace);
+	bte = rcu_dereference(rq->q->blk_trace_ext);
+	if (likely(!bt) && likely(!bte)) {
+		rcu_read_unlock();
+		return;
+	}
+
+	if (bt) {
+		ta = BLK_TA_COMPLETE;
+	} else if (bte) {
+		ta = BLK_TA_COMPLETE_EXT;
+	}
+	rcu_read_unlock();
+	blk_add_trace_rq(rq, error, nr_bytes, ta,
 			 blk_trace_request_get_cgid(rq));
 }