bcachefs: Switch to __func__for recording where btree_trans was initialized

Symbol decoding, via %ps, isn't supported in userspace - this will also
be faster when we're using trans->fn in the fast path, as with the new
BCH_JSET_ENTRY_log journal messages.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
This commit is contained in:
Kent Overstreet 2022-01-04 00:33:52 -05:00 committed by Kent Overstreet
parent 98c80d6df6
commit 669f87a5da
9 changed files with 102 additions and 109 deletions

View File

@ -857,7 +857,7 @@ lock_node:
if (bch2_btree_node_relock(trans, path, level + 1))
goto retry;
trace_trans_restart_btree_node_reused(trans->ip,
trace_trans_restart_btree_node_reused(trans->fn,
trace_ip,
path->btree_id,
&path->pos);

View File

@ -350,7 +350,7 @@ bool __bch2_btree_node_lock(struct btree_trans *trans,
}
if (unlikely(deadlock_path)) {
trace_trans_restart_would_deadlock(trans->ip, ip,
trace_trans_restart_would_deadlock(trans->fn, ip,
trans->in_traverse_all, reason,
deadlock_path->btree_id,
deadlock_path->cached,
@ -535,7 +535,7 @@ bool bch2_trans_relock(struct btree_trans *trans)
trans_for_each_path(trans, path)
if (path->should_be_locked &&
!bch2_btree_path_relock(trans, path, _RET_IP_)) {
trace_trans_restart_relock(trans->ip, _RET_IP_,
trace_trans_restart_relock(trans->fn, _RET_IP_,
path->btree_id, &path->pos);
BUG_ON(!trans->restarted);
return false;
@ -1505,7 +1505,9 @@ retry_all:
out:
bch2_btree_cache_cannibalize_unlock(c);
trace_trans_traverse_all(trans->ip, trace_ip);
trans->in_traverse_all = false;
trace_trans_traverse_all(trans->fn, trace_ip);
return ret;
}
@ -2842,7 +2844,7 @@ void *bch2_trans_kmalloc(struct btree_trans *trans, size_t size)
trans->mem_bytes = new_bytes;
if (old_bytes) {
trace_trans_restart_mem_realloced(trans->ip, _RET_IP_, new_bytes);
trace_trans_restart_mem_realloced(trans->fn, _RET_IP_, new_bytes);
btree_trans_restart(trans);
return ERR_PTR(-EINTR);
}
@ -2925,14 +2927,15 @@ static void bch2_trans_alloc_paths(struct btree_trans *trans, struct bch_fs *c)
trans->updates = p; p += updates_bytes;
}
void bch2_trans_init(struct btree_trans *trans, struct bch_fs *c,
unsigned expected_nr_iters,
size_t expected_mem_bytes)
void __bch2_trans_init(struct btree_trans *trans, struct bch_fs *c,
unsigned expected_nr_iters,
size_t expected_mem_bytes,
const char *fn)
__acquires(&c->btree_trans_barrier)
{
memset(trans, 0, sizeof(*trans));
trans->c = c;
trans->ip = _RET_IP_;
trans->fn = fn;
trans->journal_replay_not_finished =
!test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags);
@ -2971,7 +2974,7 @@ static void check_btree_paths_leaked(struct btree_trans *trans)
goto leaked;
return;
leaked:
bch_err(c, "btree paths leaked from %pS!", (void *) trans->ip);
bch_err(c, "btree paths leaked from %s!", trans->fn);
trans_for_each_path(trans, path)
if (path->ref)
printk(KERN_ERR " btree %s %pS\n",
@ -3069,7 +3072,7 @@ void bch2_btree_trans_to_text(struct printbuf *out, struct bch_fs *c)
if (!trans_has_locks(trans))
continue;
pr_buf(out, "%i %ps\n", trans->pid, (void *) trans->ip);
pr_buf(out, "%i %s\n", trans->pid, trans->fn);
trans_for_each_path(trans, path) {
if (!path->nodes_locked)

View File

@ -379,9 +379,12 @@ __bch2_btree_iter_peek_and_restart(struct btree_trans *trans,
/* new multiple iterator interface: */
void bch2_dump_trans_paths_updates(struct btree_trans *);
void bch2_trans_init(struct btree_trans *, struct bch_fs *, unsigned, size_t);
void __bch2_trans_init(struct btree_trans *, struct bch_fs *,
unsigned, size_t, const char *);
void bch2_trans_exit(struct btree_trans *);
#define bch2_trans_init(...) __bch2_trans_init(__VA_ARGS__, __func__)
void bch2_btree_trans_to_text(struct printbuf *, struct bch_fs *);
void bch2_fs_btree_iter_exit(struct bch_fs *);

View File

@ -224,7 +224,7 @@ static int btree_key_cache_fill(struct btree_trans *trans,
goto err;
if (!bch2_btree_node_relock(trans, ck_path, 0)) {
trace_transaction_restart_ip(trans->ip, _THIS_IP_);
trace_transaction_restart_ip(trans->fn, _THIS_IP_);
ret = btree_trans_restart(trans);
goto err;
}
@ -319,7 +319,7 @@ retry:
if (!trans->restarted)
goto retry;
trace_transaction_restart_ip(trans->ip, _THIS_IP_);
trace_transaction_restart_ip(trans->fn, _THIS_IP_);
ret = -EINTR;
goto err;
}
@ -339,7 +339,7 @@ fill:
if (!ck->valid && !(flags & BTREE_ITER_CACHED_NOFILL)) {
if (!path->locks_want &&
!__bch2_btree_path_upgrade(trans, path, 1)) {
trace_transaction_restart_ip(trans->ip, _THIS_IP_);
trace_transaction_restart_ip(trans->fn, _THIS_IP_);
ret = btree_trans_restart(trans);
goto err;
}

View File

@ -365,6 +365,7 @@ struct btree_trans_commit_hook {
struct btree_trans {
struct bch_fs *c;
const char *fn;
struct list_head list;
struct btree *locking;
unsigned locking_path_idx;
@ -372,7 +373,6 @@ struct btree_trans {
u8 locking_btree_id;
u8 locking_level;
pid_t pid;
unsigned long ip;
int srcu_idx;
u8 nr_sorted;

View File

@ -955,7 +955,7 @@ retry:
* instead of locking/reserving all the way to the root:
*/
if (!bch2_btree_path_upgrade(trans, path, U8_MAX)) {
trace_trans_restart_iter_upgrade(trans->ip, _RET_IP_,
trace_trans_restart_iter_upgrade(trans->fn, _RET_IP_,
path->btree_id, &path->pos);
ret = btree_trans_restart(trans);
return ERR_PTR(ret);
@ -1019,7 +1019,7 @@ retry:
BTREE_UPDATE_JOURNAL_RES,
journal_flags);
if (ret) {
trace_trans_restart_journal_preres_get(trans->ip, _RET_IP_);
trace_trans_restart_journal_preres_get(trans->fn, _RET_IP_);
goto err;
}

View File

@ -266,7 +266,7 @@ bch2_trans_journal_preres_get_cold(struct btree_trans *trans, unsigned u64s,
return ret;
if (!bch2_trans_relock(trans)) {
trace_trans_restart_journal_preres_get(trans->ip, trace_ip);
trace_trans_restart_journal_preres_get(trans->fn, trace_ip);
return -EINTR;
}
@ -305,7 +305,8 @@ static noinline void journal_transaction_name(struct btree_trans *trans)
l->entry.pad[0] = 0;
l->entry.pad[1] = 0;
l->entry.pad[2] = 0;
b = snprintf(l->d, buflen, "%ps", (void *) trans->ip);
b = min_t(unsigned, strlen(trans->fn), buflen);
memcpy(l->d, trans->fn, b);
while (b < buflen)
l->d[b++] = '\0';
@ -426,7 +427,7 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
int ret;
if (race_fault()) {
trace_trans_restart_fault_inject(trans->ip, trace_ip);
trace_trans_restart_fault_inject(trans->fn, trace_ip);
trans->restarted = true;
return -EINTR;
}
@ -619,7 +620,7 @@ fail:
bch2_btree_node_unlock_write_inlined(trans, i->path, insert_l(i)->b);
}
trace_trans_restart_would_deadlock_write(trans->ip);
trace_trans_restart_would_deadlock_write(trans->fn);
return btree_trans_restart(trans);
}
@ -650,9 +651,8 @@ static inline int do_bch2_trans_commit(struct btree_trans *trans,
char buf[200];
bch2_bkey_val_to_text(&PBUF(buf), c, bkey_i_to_s_c(i->k));
bch_err(c, "invalid bkey %s on insert from %ps -> %ps: %s\n",
buf, (void *) trans->ip,
(void *) i->ip_allocated, invalid);
bch_err(c, "invalid bkey %s on insert from %s -> %ps: %s\n",
buf, trans->fn, (void *) i->ip_allocated, invalid);
bch2_fatal_error(c);
return -EINVAL;
}
@ -758,7 +758,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
return 0;
if (ret == -EINTR)
trace_trans_restart_btree_node_split(trans->ip, trace_ip,
trace_trans_restart_btree_node_split(trans->fn, trace_ip,
i->btree_id, &i->path->pos);
break;
case BTREE_INSERT_NEED_MARK_REPLICAS:
@ -771,7 +771,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (bch2_trans_relock(trans))
return 0;
trace_trans_restart_mark_replicas(trans->ip, trace_ip);
trace_trans_restart_mark_replicas(trans->fn, trace_ip);
ret = -EINTR;
break;
case BTREE_INSERT_NEED_JOURNAL_RES:
@ -791,13 +791,13 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (bch2_trans_relock(trans))
return 0;
trace_trans_restart_journal_res_get(trans->ip, trace_ip);
trace_trans_restart_journal_res_get(trans->fn, trace_ip);
ret = -EINTR;
break;
case BTREE_INSERT_NEED_JOURNAL_RECLAIM:
bch2_trans_unlock(trans);
trace_trans_blocked_journal_reclaim(trans->ip, trace_ip);
trace_trans_blocked_journal_reclaim(trans->fn, trace_ip);
wait_event_freezable(c->journal.reclaim_wait,
(ret = journal_reclaim_wait_done(c)));
@ -807,7 +807,7 @@ int bch2_trans_commit_error(struct btree_trans *trans,
if (bch2_trans_relock(trans))
return 0;
trace_trans_restart_journal_reclaim(trans->ip, trace_ip);
trace_trans_restart_journal_reclaim(trans->fn, trace_ip);
ret = -EINTR;
break;
default:
@ -902,7 +902,7 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans)
}
if (ret == -EINTR)
trace_trans_restart_mark(trans->ip, _RET_IP_,
trace_trans_restart_mark(trans->fn, _RET_IP_,
i->btree_id, &i->path->pos);
if (ret)
return ret;
@ -932,7 +932,7 @@ static int bch2_trans_commit_run_triggers(struct btree_trans *trans)
BTREE_TRIGGER_OVERWRITE|i->flags);
if (ret == -EINTR)
trace_trans_restart_mark(trans->ip, _RET_IP_,
trace_trans_restart_mark(trans->fn, _RET_IP_,
i->btree_id, &i->path->pos);
if (ret)
return ret;
@ -999,7 +999,7 @@ int __bch2_trans_commit(struct btree_trans *trans)
BUG_ON(!i->path->should_be_locked);
if (unlikely(!bch2_btree_path_upgrade(trans, i->path, i->level + 1))) {
trace_trans_restart_upgrade(trans->ip, _RET_IP_,
trace_trans_restart_upgrade(trans->fn, _RET_IP_,
i->btree_id, &i->path->pos);
ret = btree_trans_restart(trans);
goto out;

View File

@ -135,7 +135,6 @@ int __must_check bch2_write_inode(struct bch_fs *c,
int ret;
bch2_trans_init(&trans, c, 0, 512);
trans.ip = _RET_IP_;
retry:
bch2_trans_begin(&trans);

View File

@ -546,94 +546,81 @@ TRACE_EVENT(copygc_wait,
__entry->wait_amount, __entry->until)
);
TRACE_EVENT(transaction_restart_ip,
TP_PROTO(unsigned long caller, unsigned long ip),
TP_ARGS(caller, ip),
TP_STRUCT__entry(
__field(unsigned long, caller )
__field(unsigned long, ip )
),
TP_fast_assign(
__entry->caller = caller;
__entry->ip = ip;
),
TP_printk("%pS %pS", (void *) __entry->caller, (void *) __entry->ip)
);
DECLARE_EVENT_CLASS(transaction_restart,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip),
TP_ARGS(trans_fn, caller_ip),
TP_STRUCT__entry(
__field(unsigned long, trans_ip )
__array(char, trans_fn, 24 )
__field(unsigned long, caller_ip )
),
TP_fast_assign(
__entry->trans_ip = trans_ip;
strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
__entry->caller_ip = caller_ip;
),
TP_printk("%pS %pS",
(void *) __entry->trans_ip,
(void *) __entry->caller_ip)
TP_printk("%s %pS", __entry->trans_fn, (void *) __entry->caller_ip)
);
DEFINE_EVENT(transaction_restart, transaction_restart_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_blocked_journal_reclaim,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_restart_journal_res_get,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_restart_journal_preres_get,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_restart_journal_reclaim,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_restart_fault_inject,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_traverse_all,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DEFINE_EVENT(transaction_restart, trans_restart_mark_replicas,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip),
TP_ARGS(trans_ip, caller_ip)
TP_ARGS(trans_fn, caller_ip)
);
DECLARE_EVENT_CLASS(transaction_restart_iter,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos),
TP_ARGS(trans_fn, caller_ip, btree_id, pos),
TP_STRUCT__entry(
__field(unsigned long, trans_ip )
__array(char, trans_fn, 24 )
__field(unsigned long, caller_ip )
__field(u8, btree_id )
__field(u64, pos_inode )
@ -642,7 +629,7 @@ DECLARE_EVENT_CLASS(transaction_restart_iter,
),
TP_fast_assign(
__entry->trans_ip = trans_ip;
strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
__entry->caller_ip = caller_ip;
__entry->btree_id = btree_id;
__entry->pos_inode = pos->inode;
@ -650,8 +637,8 @@ DECLARE_EVENT_CLASS(transaction_restart_iter,
__entry->pos_snapshot = pos->snapshot;
),
TP_printk("%ps %pS btree %u pos %llu:%llu:%u",
(void *) __entry->trans_ip,
TP_printk("%s %pS btree %u pos %llu:%llu:%u",
__entry->trans_fn,
(void *) __entry->caller_ip,
__entry->btree_id,
__entry->pos_inode,
@ -660,63 +647,63 @@ DECLARE_EVENT_CLASS(transaction_restart_iter,
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_reused,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_btree_node_split,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_mark,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_upgrade,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_iter_upgrade,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_relock,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
DEFINE_EVENT(transaction_restart_iter, trans_restart_traverse,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
enum btree_id btree_id,
struct bpos *pos),
TP_ARGS(trans_ip, caller_ip, btree_id, pos)
TP_ARGS(trans_fn, caller_ip, btree_id, pos)
);
TRACE_EVENT(trans_restart_would_deadlock,
TP_PROTO(unsigned long trans_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
bool in_traverse_all,
unsigned reason,
@ -726,12 +713,12 @@ TRACE_EVENT(trans_restart_would_deadlock,
enum btree_id want_btree_id,
unsigned want_iter_type,
struct bpos *want_pos),
TP_ARGS(trans_ip, caller_ip, in_traverse_all, reason,
TP_ARGS(trans_fn, caller_ip, in_traverse_all, reason,
have_btree_id, have_iter_type, have_pos,
want_btree_id, want_iter_type, want_pos),
TP_STRUCT__entry(
__field(unsigned long, trans_ip )
__array(char, trans_fn, 24 )
__field(unsigned long, caller_ip )
__field(u8, in_traverse_all )
__field(u8, reason )
@ -749,7 +736,7 @@ TRACE_EVENT(trans_restart_would_deadlock,
),
TP_fast_assign(
__entry->trans_ip = trans_ip;
strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
__entry->caller_ip = caller_ip;
__entry->in_traverse_all = in_traverse_all;
__entry->reason = reason;
@ -767,8 +754,8 @@ TRACE_EVENT(trans_restart_would_deadlock,
__entry->want_pos_snapshot = want_pos->snapshot;
),
TP_printk("%pS %pS traverse_all %u because %u have %u:%u %llu:%llu:%u want %u:%u %llu:%llu:%u",
(void *) __entry->trans_ip,
TP_printk("%s %pS traverse_all %u because %u have %u:%u %llu:%llu:%u want %u:%u %llu:%llu:%u",
__entry->trans_fn,
(void *) __entry->caller_ip,
__entry->in_traverse_all,
__entry->reason,
@ -785,39 +772,40 @@ TRACE_EVENT(trans_restart_would_deadlock,
);
TRACE_EVENT(trans_restart_would_deadlock_write,
TP_PROTO(unsigned long trans_ip),
TP_ARGS(trans_ip),
TP_PROTO(const char *trans_fn),
TP_ARGS(trans_fn),
TP_STRUCT__entry(
__field(unsigned long, trans_ip )
__array(char, trans_fn, 24 )
),
TP_fast_assign(
__entry->trans_ip = trans_ip;
strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
),
TP_printk("%ps", (void *) __entry->trans_ip)
TP_printk("%s", __entry->trans_fn)
);
TRACE_EVENT(trans_restart_mem_realloced,
TP_PROTO(unsigned long trans_ip, unsigned long caller_ip,
TP_PROTO(const char *trans_fn,
unsigned long caller_ip,
unsigned long bytes),
TP_ARGS(trans_ip, caller_ip, bytes),
TP_ARGS(trans_fn, caller_ip, bytes),
TP_STRUCT__entry(
__field(unsigned long, trans_ip )
__array(char, trans_fn, 24 )
__field(unsigned long, caller_ip )
__field(unsigned long, bytes )
),
TP_fast_assign(
__entry->trans_ip = trans_ip;
strncpy(__entry->trans_fn, trans_fn, sizeof(__entry->trans_fn));
__entry->caller_ip = caller_ip;
__entry->bytes = bytes;
),
TP_printk("%pS %pS bytes %lu",
(void *) __entry->trans_ip,
TP_printk("%s %pS bytes %lu",
__entry->trans_fn,
(void *) __entry->caller_ip,
__entry->bytes)
);