Skip to content

Commit 790666c

Browse files
author
Kent Overstreet
committed
bcachefs: Improve trans_blocked_journal_reclaim tracepoint
include information about the state of the btree key cache Signed-off-by: Kent Overstreet <[email protected]>
1 parent 7254555 commit 790666c

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

fs/bcachefs/btree_key_cache.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ static inline size_t bch2_nr_btree_keys_need_flush(struct bch_fs *c)
1111
return max_t(ssize_t, 0, nr_dirty - max_dirty);
1212
}
1313

14-
static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c)
14+
static inline ssize_t __bch2_btree_key_cache_must_wait(struct bch_fs *c)
1515
{
1616
size_t nr_dirty = atomic_long_read(&c->btree_key_cache.nr_dirty);
1717
size_t nr_keys = atomic_long_read(&c->btree_key_cache.nr_keys);
1818
size_t max_dirty = 4096 + (nr_keys * 3) / 4;
1919

20-
return nr_dirty > max_dirty;
20+
return nr_dirty - max_dirty;
21+
}
22+
23+
static inline bool bch2_btree_key_cache_must_wait(struct bch_fs *c)
24+
{
25+
return __bch2_btree_key_cache_must_wait(c) > 0;
2126
}
2227

2328
static inline bool bch2_btree_key_cache_wait_done(struct bch_fs *c)

fs/bcachefs/trace.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "buckets.h"
55
#include "btree_cache.h"
66
#include "btree_iter.h"
7+
#include "btree_key_cache.h"
78
#include "btree_locking.h"
89
#include "btree_update_interior.h"
910
#include "keylist.h"

fs/bcachefs/trace.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -988,10 +988,33 @@ TRACE_EVENT(trans_restart_split_race,
988988
__entry->u64s_remaining)
989989
);
990990

991-
DEFINE_EVENT(transaction_event, trans_blocked_journal_reclaim,
991+
TRACE_EVENT(trans_blocked_journal_reclaim,
992992
TP_PROTO(struct btree_trans *trans,
993993
unsigned long caller_ip),
994-
TP_ARGS(trans, caller_ip)
994+
TP_ARGS(trans, caller_ip),
995+
996+
TP_STRUCT__entry(
997+
__array(char, trans_fn, 32 )
998+
__field(unsigned long, caller_ip )
999+
1000+
__field(unsigned long, key_cache_nr_keys )
1001+
__field(unsigned long, key_cache_nr_dirty )
1002+
__field(long, must_wait )
1003+
),
1004+
1005+
TP_fast_assign(
1006+
strscpy(__entry->trans_fn, trans->fn, sizeof(__entry->trans_fn));
1007+
__entry->caller_ip = caller_ip;
1008+
__entry->key_cache_nr_keys = atomic_long_read(&trans->c->btree_key_cache.nr_keys);
1009+
__entry->key_cache_nr_dirty = atomic_long_read(&trans->c->btree_key_cache.nr_dirty);
1010+
__entry->must_wait = __bch2_btree_key_cache_must_wait(trans->c);
1011+
),
1012+
1013+
TP_printk("%s %pS key cache keys %lu dirty %lu must_wait %li",
1014+
__entry->trans_fn, (void *) __entry->caller_ip,
1015+
__entry->key_cache_nr_keys,
1016+
__entry->key_cache_nr_dirty,
1017+
__entry->must_wait)
9951018
);
9961019

9971020
TRACE_EVENT(trans_restart_journal_preres_get,

0 commit comments

Comments
 (0)