bcachefs: trace_key_cache_fill
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 13 Dec 2024 10:43:00 +0000 (05:43 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 29 Dec 2024 18:30:39 +0000 (13:30 -0500)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/btree_key_cache.c
fs/bcachefs/trace.h

index 3bd40ea0fa3dba73915e882f285b2eb038d75559..4eba2871f28933660b25d245dda2274e9d0db850 100644 (file)
@@ -309,6 +309,16 @@ static noinline int btree_key_cache_fill(struct btree_trans *trans,
        ret = btree_key_cache_create(trans, ck_path, k);
        if (ret)
                goto err;
+
+       if (trace_key_cache_fill_enabled()) {
+               struct printbuf buf = PRINTBUF;
+
+               bch2_bpos_to_text(&buf, ck_path->pos);
+               prt_char(&buf, ' ');
+               bch2_bkey_val_to_text(&buf, trans->c, k);
+               trace_key_cache_fill(trans, buf.buf);
+               printbuf_exit(&buf);
+       }
 out:
        /* We're not likely to need this iterator again: */
        bch2_set_btree_iter_dontneed(&iter);
index 11e6547f91d6ab3812f7be4b001a69e7c6fa8a35..9d40b7d4ea29690dffd4933deaab32324bf0fa3d 100644 (file)
@@ -1338,6 +1338,12 @@ TRACE_EVENT(trans_restart_key_cache_key_realloced,
                  __entry->new_u64s)
 );
 
+DEFINE_EVENT(transaction_event,        trans_restart_write_buffer_flush,
+       TP_PROTO(struct btree_trans *trans,
+                unsigned long caller_ip),
+       TP_ARGS(trans, caller_ip)
+);
+
 TRACE_EVENT(path_downgrade,
        TP_PROTO(struct btree_trans *trans,
                 unsigned long caller_ip,
@@ -1374,10 +1380,21 @@ TRACE_EVENT(path_downgrade,
                  __entry->pos_snapshot)
 );
 
-DEFINE_EVENT(transaction_event,        trans_restart_write_buffer_flush,
-       TP_PROTO(struct btree_trans *trans,
-                unsigned long caller_ip),
-       TP_ARGS(trans, caller_ip)
+TRACE_EVENT(key_cache_fill,
+       TP_PROTO(struct btree_trans *trans, const char *key),
+       TP_ARGS(trans, key),
+
+       TP_STRUCT__entry(
+               __array(char,           trans_fn, 32    )
+               __string(key,           key                     )
+       ),
+
+       TP_fast_assign(
+               strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
+               __assign_str(key);
+       ),
+
+       TP_printk("%s %s", __entry->trans_fn, __get_str(key))
 );
 
 TRACE_EVENT(write_buffer_flush,
@@ -1443,7 +1460,7 @@ TRACE_EVENT(write_buffer_maybe_flush,
        TP_STRUCT__entry(
                __array(char,                   trans_fn, 32    )
                __field(unsigned long,          caller_ip       )
-               __string(key,           key                     )
+               __string(key,                   key             )
        ),
 
        TP_fast_assign(