summaryrefslogtreecommitdiff
path: root/c_src
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-05-28 19:46:30 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-05-28 19:49:16 -0400
commit72f550f2daad9962733aa2f58a506f8e7b55c455 (patch)
treea94ba1db50d7f1c5f2a8b9c77794ee3461fcfc9f /c_src
parent6cb4160e0c1de2562b40f30206f80f96303c1ee8 (diff)
cmd_fs_top(): skip non firing counters, add column for total
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'c_src')
-rw-r--r--c_src/cmd_top.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/c_src/cmd_top.c b/c_src/cmd_top.c
index 05845340..4536a1f7 100644
--- a/c_src/cmd_top.c
+++ b/c_src/cmd_top.c
@@ -30,9 +30,9 @@ static void fs_top(const char *path, bool human_readable)
{
struct bchfs_handle fs = bcache_fs_open(path);
- struct bch_ioctl_query_counters *curr, *prev = NULL;
-
- curr = read_counters(fs);
+ struct bch_ioctl_query_counters *start = read_counters(fs);
+ struct bch_ioctl_query_counters *curr = read_counters(fs);
+ struct bch_ioctl_query_counters *prev = NULL;
while (true) {
sleep(1);
@@ -42,15 +42,25 @@ static void fs_top(const char *path, bool human_readable)
printf("\033[2J");
printf("\033[H");
+ printf("%-40s %8s %12s\n", "", "2s", "total");
for (unsigned i = 0; i < BCH_COUNTER_NR; i++) {
unsigned stable = counters_to_stable_map[i];
- u64 v = stable < curr->nr
- ? curr->d[stable] - prev->d[stable]
+
+ u64 v1 = stable < curr->nr
+ ? curr->d[stable] - prev->d[stable]
+ : 0;
+
+ u64 v2 = stable < curr->nr
+ ? curr->d[stable] - start->d[stable]
: 0;
- printf("%-48s %llu\n",
+
+ if (!v2)
+ continue;
+
+ printf("%-40s %8llu %12llu\n",
bch2_counter_names[i],
- v);
+ v1, v2);
}
}