Message ID | 20210225070231.21136-10-chaitanya.kulkarni@wdc.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC,01/39] blktrace_api: add new trace definitions | expand |
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 280ad94f99b6..906afa0982c2 100644 > --- a/kernel/trace/blktrace.c > +++ b/kernel/trace/blktrace.c > @@ -1134,7 +1134,25 @@ static void blk_add_trace_rq(struct request *rq, int error, > > static void blk_add_trace_rq_insert(void *ignore, struct request *rq) > { > - blk_add_trace_rq(rq, 0, blk_rq_bytes(rq), BLK_TA_INSERT, > + u64 ta = 0; > + 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_INSERT; > + } else if (bte) { > + ta = BLK_TA_INSERT_EXT; > + } Braces are not needed here. Removing blk_trace_ext and reusing blk_trace would make all of this unnecessary. > + rcu_read_unlock(); > + blk_add_trace_rq(rq, 0, blk_rq_bytes(rq), ta, > blk_trace_request_get_cgid(rq)); > } > >
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 280ad94f99b6..906afa0982c2 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -1134,7 +1134,25 @@ static void blk_add_trace_rq(struct request *rq, int error, static void blk_add_trace_rq_insert(void *ignore, struct request *rq) { - blk_add_trace_rq(rq, 0, blk_rq_bytes(rq), BLK_TA_INSERT, + u64 ta = 0; + 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_INSERT; + } else if (bte) { + ta = BLK_TA_INSERT_EXT; + } + rcu_read_unlock(); + blk_add_trace_rq(rq, 0, blk_rq_bytes(rq), ta, blk_trace_request_get_cgid(rq)); }
Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> --- kernel/trace/blktrace.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)