]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Separate running/runnable in wp stats
authorKent Overstreet <kent.overstreet@linux.dev>
Wed, 22 Jan 2025 19:38:59 +0000 (14:38 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 15 Mar 2025 01:02:11 +0000 (21:02 -0400)
We've got per-writepoint statistics to see how well the writepoint index
update threads are pipelining; this separates running vs. runnable so we
can see at a glance if they're blocking.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_types.h
fs/bcachefs/io_write.c

index 4aa8ee026cb847fa402c12ef12e5cf98195252f4..8f79f46c2a78192a9aacdb644aa514d320bbf578 100644 (file)
@@ -90,6 +90,7 @@ struct dev_stripe_state {
        x(stopped)                      \
        x(waiting_io)                   \
        x(waiting_work)                 \
+       x(runnable)                     \
        x(running)
 
 enum write_point_state {
@@ -125,6 +126,7 @@ struct write_point {
                enum write_point_state  state;
                u64                     last_state_change;
                u64                     time[WRITE_POINT_STATE_NR];
+               u64                     last_runtime;
        } __aligned(SMP_CACHE_BYTES);
 };
 
index 970f3f0959a42074747fb43d3f089a356166ad8f..a903f39caa3e8489e1c3b36ed508933128b2bc9a 100644 (file)
@@ -587,7 +587,15 @@ err:
 static inline void __wp_update_state(struct write_point *wp, enum write_point_state state)
 {
        if (state != wp->state) {
+               struct task_struct *p = current;
                u64 now = ktime_get_ns();
+               u64 runtime = p->se.sum_exec_runtime +
+                       (now - p->se.exec_start);
+
+               if (state == WRITE_POINT_runnable)
+                       wp->last_runtime = runtime;
+               else if (wp->state == WRITE_POINT_runnable)
+                       wp->time[WRITE_POINT_running] += runtime - wp->last_runtime;
 
                if (wp->last_state_change &&
                    time_after64(now, wp->last_state_change))
@@ -601,7 +609,7 @@ static inline void wp_update_state(struct write_point *wp, bool running)
 {
        enum write_point_state state;
 
-       state = running                  ? WRITE_POINT_running :
+       state = running                  ? WRITE_POINT_runnable:
                !list_empty(&wp->writes) ? WRITE_POINT_waiting_io
                                         : WRITE_POINT_stopped;