Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

getdelays: show average CPU/IO/SWAP/RECLAIM delays

I find it very handy to show the average delays in milliseconds.

Example output (on 100 concurrent dd reading sparse files):

CPU count real total virtual total delay total delay average
986 3223509952 3207643301 38863410579 39.415ms
IO count delay total delay average
0 0 0ms
SWAP count delay total delay average
0 0 0ms
RECLAIM count delay total delay average
1059 5131834899 4ms
dd: read=0, write=0, cancelled_write=0

Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
Cc: Mel Gorman <mel@linux.vnet.ibm.com>
Cc: Balbir Singh <balbir@in.ibm.com>
Reviewed-by: Satoru Moriya <satoru.moriya@hds.com>
Reviewed-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Wu Fengguang and committed by
Linus Torvalds
02d54f09 4ed960b1

+20 -13
+20 -13
Documentation/accounting/getdelays.c
··· 193 193 return id; 194 194 } 195 195 196 + #define average_ms(t, c) (t / 1000000ULL / (c ? c : 1)) 197 + 196 198 static void print_delayacct(struct taskstats *t) 197 199 { 198 - printf("\n\nCPU %15s%15s%15s%15s\n" 199 - " %15llu%15llu%15llu%15llu\n" 200 - "IO %15s%15s\n" 201 - " %15llu%15llu\n" 202 - "SWAP %15s%15s\n" 203 - " %15llu%15llu\n" 204 - "RECLAIM %12s%15s\n" 205 - " %15llu%15llu\n", 206 - "count", "real total", "virtual total", "delay total", 200 + printf("\n\nCPU %15s%15s%15s%15s%15s\n" 201 + " %15llu%15llu%15llu%15llu%15.3fms\n" 202 + "IO %15s%15s%15s\n" 203 + " %15llu%15llu%15llums\n" 204 + "SWAP %15s%15s%15s\n" 205 + " %15llu%15llu%15llums\n" 206 + "RECLAIM %12s%15s%15s\n" 207 + " %15llu%15llu%15llums\n", 208 + "count", "real total", "virtual total", 209 + "delay total", "delay average", 207 210 (unsigned long long)t->cpu_count, 208 211 (unsigned long long)t->cpu_run_real_total, 209 212 (unsigned long long)t->cpu_run_virtual_total, 210 213 (unsigned long long)t->cpu_delay_total, 211 - "count", "delay total", 214 + average_ms((double)t->cpu_delay_total, t->cpu_count), 215 + "count", "delay total", "delay average", 212 216 (unsigned long long)t->blkio_count, 213 217 (unsigned long long)t->blkio_delay_total, 214 - "count", "delay total", 218 + average_ms(t->blkio_delay_total, t->blkio_count), 219 + "count", "delay total", "delay average", 215 220 (unsigned long long)t->swapin_count, 216 221 (unsigned long long)t->swapin_delay_total, 217 - "count", "delay total", 222 + average_ms(t->swapin_delay_total, t->swapin_count), 223 + "count", "delay total", "delay average", 218 224 (unsigned long long)t->freepages_count, 219 - (unsigned long long)t->freepages_delay_total); 225 + (unsigned long long)t->freepages_delay_total, 226 + average_ms(t->freepages_delay_total, t->freepages_count)); 220 227 } 221 228 222 229 static void task_context_switch_counts(struct taskstats *t)