From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.93 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796310245; b=squU+DiYv+h2WdYZdutcVFhzzESnsPbn2FSs0fuoVpv96ANPKKcR5qbwlfs+JCHnwlGf lWZP/Nr8Baah6pk1d6nEu5IcWjkGtt+HEU/SZ9OHajPRC+YZUqOkLc6zogFk0SRRa2rEs tU8vstn9BCH1ECqIAr/kOCR3swlWdcsprSDFXKLS/WKYXlstuT5VjNBFCLhWYRiFlChI2 ibHkzqb8aJJXXmrdmSSZX50vIhj8wD+fxKkgN8OVJpmM6iL8f2gfpgXTx2s0t+/rIDucx F7Oqn1S3VssmD6t/9oXPXKLPNLadBjM59hNF3qAKCo4iXDYbwCbDfYr86Hx0TMM6AwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796310245; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=nVvvH6Zq7zJL9LhAS/w7j2c/GFLgDtq9+P8BZuJ2jTk=; b=t2G2Vrz6QvKdcluwf8X7x1tqzXHaPBTlNXEJPC03CylCHANsjfkWrNcU9klvxBAho9r6 jSCYwPQiWYzT9IHHo2LrXze5db2mjZh8MtlmXf2PGZ7CEbE0Gj4ifXaKbLtrNgql59Rlc VmqFaaFMzrubmqPpgp8Yn9TubMe9SJBNKY75TizKtZkKizHuuaj/jG7Lnypm9F4afZX/c iwnXerOi6ZGYMR9/2iJsija+lTebAV8HAks5eTON+IDaruJKfR0POkbEuymn2r7/U0412 Ysi1eHXaL1TV2lBZRLM1/bi0wR5cHJ07vAnfvoeS3zTUYAXut3QwGFxyorOwK381nbA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=iKuG1bbr; arc=none smtp.remote-ip=95.215.58.93 Received: from mta1.migadu.com (out-93.mta1.migadu.com [95.215.58.93]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19715606A6B3 for ; Thu, 3 Dec 2026 15:04:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 19715606A6B3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=iKuG1bbr X-Envelope-To: cgroups@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=5RLObNl7QwCsJRqSdodIQlwW7YBlV0CplvJhse99j4I=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796310242; v=1; x=1796915042; b=iKuG1bbrHGWWH5xbbzyTSXnxBiEr9gSZZRQDJBpuAFGG8wS+67YyDOEJPpUCWWn1YonYteBj UUE7128qeKzLWEV3Qc+JjglDzc1pvwgdWRCaqWOv9NmR4Mo0IjvP/HCXHz+FjL9Us42BFuS1fFI sdtSIpDx2jUETEhpoULTTTEw= X-Envelope-To: cgroups@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 500081232cae873b; Thu, 03 Dec 2026 15:04:02 +0000 X-Mizu-Trace-ID: 500081232cae873b X-Migadu-Flow: FLOW_OUT From: Tao Cui To: tj@kernel.org, josef@toxicopanda.com, axboe@kernel.dk, ast@kernel.org, alexei.starovoitov@gmail.com Cc: cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, andrii@kernel.org, eddyz87@gmail.com, daniel@iogearbox.net, linux-kselftest@vger.kernel.org, cui.tao@linux.dev, cuitao@kylinos.cn, ameryhung@gmail.com Subject: [PATCH v15 2/4] blk-iocost: add iocost_ioc_tick tracepoint for per-period device summary Date: Thu, 3 Dec 2026 23:03:36 +0800 Message-ID: <20261203150338.2625598-3-cui.tao@linux.dev> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261203150338.2625598-1-cui.tao@linux.dev> References: <20261203150338.2625598-1-cui.tao@linux.dev> X-Mailing-List: cgroups@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Tao Cui Add iocost_ioc_tick, emitted once per period from ioc_timer_fn() with the overall controller state: period_us, vrate, busy_level, active iocg count and usage percentage. busy_level, cur_period, nr_active and usage_us_sum are complete at the emission point. usage is wall time over wall time, summed over iocgs, and is not capped at 100. vrate and period_us reflect the current controller state, which an io.cost.qos write may have changed mid-period. The event fires every period the controller is running, including steady states, plus one final tick before the controller goes idle, so the transition to dormancy is directly visible. The active iocg count is only gathered when the tracepoint is enabled. Suggested-by: Tejun Heo Signed-off-by: Tao Cui Acked-by: Tejun Heo --- MAINTAINERS | 1 + block/blk-iocost.c | 18 +++++++++++++++ include/trace/events/iocost.h | 43 +++++++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 857ad039c997..7693332a5f88 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -6930,6 +6930,7 @@ F: block/blk-iocost.c F: block/blk-iolatency.c F: block/blk-throttle.c F: include/linux/blk-cgroup.h +F: include/trace/events/iocost.h CONTROL GROUP - CPUSET M: Waiman Long diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 49622bf69fe3..c41bb657a845 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2438,6 +2438,7 @@ static void ioc_timer_fn(struct timer_list *timer) struct ioc_now now; LIST_HEAD(surpluses); int nr_debtors, nr_shortages = 0, nr_lagging = 0; + int nr_active = 0; u64 usage_us_sum = 0; u32 ppm_rthr; u32 ppm_wthr; @@ -2635,6 +2636,23 @@ static void ioc_timer_fn(struct timer_list *timer) ioc->busy_level = clamp(ioc->busy_level, -1000, 1000); + /* + * busy_level, cur_period, nr_active and usage_us_sum are complete + * here. usage is wall time over wall time, summed over iocgs, and + * is not capped at 100. vrate and period_us reflect the current + * controller state, which an io.cost.qos write may have changed + * mid-period. Emit before the refresh and the period transition. + */ + if (trace_iocost_ioc_tick_enabled()) { + struct ioc_gq *active_iocg; + + list_for_each_entry(active_iocg, &ioc->active_iocgs, + active_list) + nr_active++; + + trace_iocost_ioc_tick(ioc, &now, nr_active, usage_us_sum); + } + ioc_adjust_base_vrate(ioc, rq_wait_pct, nr_lagging, nr_shortages, prev_busy_level, missed_ppm); diff --git a/include/trace/events/iocost.h b/include/trace/events/iocost.h index eb711343ce4f..ea7ec3c1da5c 100644 --- a/include/trace/events/iocost.h +++ b/include/trace/events/iocost.h @@ -181,6 +181,49 @@ TRACE_EVENT(iocost_ioc_vrate_adj, ) ); +/* + * Periodic per-device summary, emitted once per period before the vrate + * adjustment and the period transition in ioc_timer_fn(). Unlike the + * state-change events above, this fires every period the controller is + * running, including steady states, and carries the overall controller state + * so basic monitoring doesn't require drgn. + */ +TRACE_EVENT(iocost_ioc_tick, + + TP_PROTO(struct ioc *ioc, const struct ioc_now *now, + int nr_active, u64 usage_us_sum), + + TP_ARGS(ioc, now, nr_active, usage_us_sum), + + TP_STRUCT__entry ( + __string(devname, ioc_name(ioc)) + __field(u64, cur_period) + __field(u32, period_us) + __field(u64, vrate) + __field(int, busy_level) + __field(int, nr_active) + __field(u64, usage_pct) + ), + + TP_fast_assign( + __assign_str(devname); + __entry->cur_period = atomic64_read(&ioc->cur_period); + __entry->period_us = ioc->period_us; + __entry->vrate = ioc->vtime_base_rate; + __entry->busy_level = ioc->busy_level; + __entry->nr_active = nr_active; + __entry->usage_pct = now->now > ioc->period_at ? + div64_u64(usage_us_sum * 100, + now->now - ioc->period_at) : 0; + ), + + TP_printk("[%s] period=%llu:%uus vrate=%llu busy=%d active=%d usage=%llu%%", + __get_str(devname), __entry->cur_period, __entry->period_us, + __entry->vrate, __entry->busy_level, __entry->nr_active, + __entry->usage_pct + ) +); + TRACE_EVENT(iocost_iocg_forgive_debt, TP_PROTO(struct ioc_gq *iocg, const char *path, struct ioc_now *now, -- 2.43.0