Skip to contentSkip to conversation

delayacct: improve the average delay precision of getdelay tool to microsecond

PATCH Applied [email protected] 2 participants 3 messages Feb 13, 2023 – Mar 2, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 delayacct: improve the average delay precision of getdelay tool to microsecond

From: Wang Yong <[email protected]>

Improve the average delay precision of getdelay tool to microsecond. When using the getdelay tool, it is sometimes found that the average delay except CPU is not 0, but display is 0, because the precison is too low. For example, see delay average of SWAP below when using ZRAM.

print delayacct stats ON
PID 32915
CPU count real total virtual total delay total delay average

               339202     2793871936     9233585504        7951112          0.000ms
IO              count    delay total  delay average
                   41      419296904             10ms
SWAP            count    delay total  delay average
               242589     1045792384              0ms

This wrong display is misleading, so improve the millisecond precision of the average delay to microsecond just like CPU. Then user would get more accurate information of delay time.

---
 Documentation/accounting/delay-accounting.rst      | 14 ++++++-------
 .../zh_CN/accounting/delay-accounting.rst          | 14 ++++++-------
 tools/accounting/getdelays.c                       | 24 +++++++++++-----------
 3 files changed, 26 insertions(+), 26 deletions(-)
Documentation/accounting/delay-accounting.rst +7 -7
index 7103b62ba6d7..c4ac482262f8 100644
@@ -109,17 +109,17 @@ Get sum of delays, since system boot, for all pids with tgid 5::
    CPU             count     real total  virtual total    delay total  delay average
                        8        7000000        6872122        3382277          0.423ms
    IO              count    delay total  delay average
-                   0              0              0ms
+                   0              0          0.000ms
    SWAP            count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    RECLAIM         count    delay total  delay average
-                   0              0              0ms
+                   0              0          0.000ms
    THRASHING       count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    COMPACT         count    delay total  delay average
-                       0              0              0ms
-        WPCOPY          count    delay total  delay average
-                            0              0              0ms
+                       0              0          0.000ms
+   WPCOPY          count    delay total  delay average
+                       0              0          0.000ms
 
 Get IO accounting for pid 1, it works only with -p::
 
Documentation/translations/zh_CN/accounting/delay-accounting.rst +7 -7
index a01dc3d5b0db..3c952fde09ff 100644
@@ -92,17 +92,17 @@ getdelays命令的一般格式::
    CPU             count     real total  virtual total    delay total  delay average
                        8        7000000        6872122        3382277          0.423ms
    IO              count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    SWAP            count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    RECLAIM         count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    THRASHING       count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
    COMPACT         count    delay total  delay average
-                       0              0              0ms
-    WPCOPY          count    delay total  delay average
-                       0              0              0ms
+                       0              0          0.000ms
+   WPCOPY          count    delay total  delay average
+                       0              0          0.000ms
 
 获取pid为1的IO计数,它只和-p一起使用::
    # ./getdelays -i -p 1
tools/accounting/getdelays.c +12 -12
index 938dec0dfaad..89324db33be3 100644
@@ -198,17 +198,17 @@ static void print_delayacct(struct taskstats *t)
    printf("\n\nCPU   %15s%15s%15s%15s%15s\n"
           "      %15llu%15llu%15llu%15llu%15.3fms\n"
           "IO    %15s%15s%15s\n"
-          "      %15llu%15llu%15llums\n"
+          "      %15llu%15llu%15.3fms\n"
           "SWAP  %15s%15s%15s\n"
-          "      %15llu%15llu%15llums\n"
+          "      %15llu%15llu%15.3fms\n"
           "RECLAIM  %12s%15s%15s\n"
-          "      %15llu%15llu%15llums\n"
+          "      %15llu%15llu%15.3fms\n"
           "THRASHING%12s%15s%15s\n"
-          "      %15llu%15llu%15llums\n"
+          "      %15llu%15llu%15.3fms\n"
           "COMPACT  %12s%15s%15s\n"
-          "      %15llu%15llu%15llums\n"
+          "      %15llu%15llu%15.3fms\n"
           "WPCOPY   %12s%15s%15s\n"
-          "      %15llu%15llu%15llums\n",
+          "      %15llu%15llu%15.3fms\n",
           "count", "real total", "virtual total",
           "delay total", "delay average",
           (unsigned long long)t->cpu_count,
@@ -219,27 +219,27 @@ static void print_delayacct(struct taskstats *t)
           "count", "delay total", "delay average",
           (unsigned long long)t->blkio_count,
           (unsigned long long)t->blkio_delay_total,
-          average_ms(t->blkio_delay_total, t->blkio_count),
+          average_ms((double)t->blkio_delay_total, t->blkio_count),
           "count", "delay total", "delay average",
           (unsigned long long)t->swapin_count,
           (unsigned long long)t->swapin_delay_total,
-          average_ms(t->swapin_delay_total, t->swapin_count),
+          average_ms((double)t->swapin_delay_total, t->swapin_count),
           "count", "delay total", "delay average",
           (unsigned long long)t->freepages_count,
           (unsigned long long)t->freepages_delay_total,
-          average_ms(t->freepages_delay_total, t->freepages_count),
+          average_ms((double)t->freepages_delay_total, t->freepages_count),
           "count", "delay total", "delay average",
           (unsigned long long)t->thrashing_count,
           (unsigned long long)t->thrashing_delay_total,
-          average_ms(t->thrashing_delay_total, t->thrashing_count),
+          average_ms((double)t->thrashing_delay_total, t->thrashing_count),
           "count", "delay total", "delay average",
           (unsigned long long)t->compact_count,
           (unsigned long long)t->compact_delay_total,
-          average_ms(t->compact_delay_total, t->compact_count),
+          average_ms((double)t->compact_delay_total, t->compact_count),
           "count", "delay total", "delay average",
           (unsigned long long)t->wpcopy_count,
           (unsigned long long)t->wpcopy_delay_total,
-          average_ms(t->wpcopy_delay_total, t->wpcopy_count));
+          average_ms((double)t->wpcopy_delay_total, t->wpcopy_count));
 }
 
 static void task_context_switch_counts(struct taskstats *t)

--
2.15.2

#1 lore raw
Quoted 10 lines · On Mon, Feb 13, 2023 at 02:08:08PM +0800, [email protected] wrote:

From: Wang Yong <[email protected]>

Improve the average delay precision of getdelay tool to microsecond. When using the getdelay tool, it is sometimes found that the average delay except CPU is not 0, but display is 0, because the precison is too low. For example, see delay average of SWAP below when using ZRAM.

print delayacct stats ON
PID 32915
CPU count real total virtual total delay total delay average

Quoted 8 lines
               339202     2793871936     9233585504        7951112          0.000ms
IO              count    delay total  delay average
                   41      419296904             10ms
SWAP            count    delay total  delay average
               242589     1045792384              0ms

This wrong display is misleading, so improve the millisecond precision of the average delay to microsecond just like CPU. Then user would get more accurate information of delay time.

I'm kinda confused. 0.000ms is same as 0ms, right?

And did you mean accuracy of delay average is to be same as CPU time?

Signature · 1 line
An old man doll... just what I always wanted! - Clara
#2 lore raw
Quoted 1 line

I'm kinda confused. 0.000ms is same as 0ms, right?

Not really. The types of these two results are different, so the precision of representation is different.

Quoted 1 line

And did you mean accuracy of delay average is to be same as CPU time?

Yes.