iocost: add iocg_forgive_debt tracepoint
authorTejun Heo <tj@kernel.org>
Fri, 18 Sep 2020 00:44:56 +0000 (20:44 -0400)
committerJens Axboe <axboe@kernel.dk>
Fri, 25 Sep 2020 14:35:02 +0000 (08:35 -0600)
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-iocost.c
include/trace/events/iocost.h

index 9b1f944..328ae80 100644 (file)
@@ -2046,12 +2046,24 @@ static void ioc_forgive_debts(struct ioc *ioc, u64 usage_us_sum, int nr_debtors,
        ioc->dfgv_period_rem = do_div(nr_cycles, DFGV_PERIOD);
 
        list_for_each_entry(iocg, &ioc->active_iocgs, active_list) {
+               u64 __maybe_unused old_debt, __maybe_unused old_delay;
+
                if (!iocg->abs_vdebt)
                        continue;
+
                spin_lock(&iocg->waitq.lock);
+
+               old_debt = iocg->abs_vdebt;
+               old_delay = iocg->delay;
+
                iocg->abs_vdebt >>= nr_cycles;
                iocg->delay = 0; /* kick_waitq will recalc */
                iocg_kick_waitq(iocg, true, now);
+
+               TRACE_IOCG_PATH(iocg_forgive_debt, iocg, now, usage_pct,
+                               old_debt, iocg->abs_vdebt,
+                               old_delay, iocg->delay);
+
                spin_unlock(&iocg->waitq.lock);
        }
 }
index b350860..0b68699 100644 (file)
@@ -164,6 +164,47 @@ TRACE_EVENT(iocost_ioc_vrate_adj,
        )
 );
 
+TRACE_EVENT(iocost_iocg_forgive_debt,
+
+       TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now,
+               u32 usage_pct, u64 old_debt, u64 new_debt,
+               u64 old_delay, u64 new_delay),
+
+       TP_ARGS(iocg, path, now, usage_pct,
+               old_debt, new_debt, old_delay, new_delay),
+
+       TP_STRUCT__entry (
+               __string(devname, ioc_name(iocg->ioc))
+               __string(cgroup, path)
+               __field(u64, now)
+               __field(u64, vnow)
+               __field(u32, usage_pct)
+               __field(u64, old_debt)
+               __field(u64, new_debt)
+               __field(u64, old_delay)
+               __field(u64, new_delay)
+       ),
+
+       TP_fast_assign(
+               __assign_str(devname, ioc_name(iocg->ioc));
+               __assign_str(cgroup, path);
+               __entry->now = now->now;
+               __entry->vnow = now->vnow;
+               __entry->usage_pct = usage_pct;
+               __entry->old_debt = old_debt;
+               __entry->new_debt = new_debt;
+               __entry->old_delay = old_delay;
+               __entry->new_delay = new_delay;
+       ),
+
+       TP_printk("[%s:%s] now=%llu:%llu usage=%u debt=%llu->%llu delay=%llu->%llu",
+               __get_str(devname), __get_str(cgroup),
+               __entry->now, __entry->vnow, __entry->usage_pct,
+               __entry->old_debt, __entry->new_debt,
+               __entry->old_delay, __entry->new_delay
+       )
+);
+
 #endif /* _TRACE_BLK_IOCOST_H */
 
 /* This part must be outside protection */