summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-06-17 21:06:58 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2025-06-30 17:52:45 -0400
commitcf91b15f6297b27c6abd01ec155518084b352b68 (patch)
treed2b34ca067d136b281966a50cf455e493f22b7d0
parent7f643a40f6bc80a9432e6ccf1496756fb10d4f98 (diff)
bcachefs: Plumb trans_kmalloc ip to trans_log_msg
the 'ip' parameter to bch2_trans_kmalloc() is used for bump allocator tracing: when we exceed the bump allocator limit, it dumps a list of allocations and what function did them. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/btree_update.c15
-rw-r--r--fs/bcachefs/btree_update.h26
2 files changed, 28 insertions, 13 deletions
diff --git a/fs/bcachefs/btree_update.c b/fs/bcachefs/btree_update.c
index ee657b9f4b96..192c1e5e3ed9 100644
--- a/fs/bcachefs/btree_update.c
+++ b/fs/bcachefs/btree_update.c
@@ -546,7 +546,7 @@ int bch2_btree_insert_clone_trans(struct btree_trans *trans,
void *__bch2_trans_subbuf_alloc(struct btree_trans *trans,
struct btree_trans_subbuf *buf,
- unsigned u64s)
+ unsigned u64s, ulong ip)
{
unsigned new_top = buf->u64s + u64s;
unsigned new_size = buf->size;
@@ -556,7 +556,7 @@ void *__bch2_trans_subbuf_alloc(struct btree_trans *trans,
if (new_top > new_size)
new_size = roundup_pow_of_two(new_top);
- void *n = bch2_trans_kmalloc_nomemzero(trans, new_size * sizeof(u64));
+ void *n = bch2_trans_kmalloc_nomemzero_ip(trans, new_size * sizeof(u64), ip);
if (IS_ERR(n))
return n;
@@ -813,11 +813,11 @@ int bch2_btree_bit_mod_buffered(struct btree_trans *trans, enum btree_id btree,
return bch2_trans_update_buffered(trans, btree, &k);
}
-static int __bch2_trans_log_str(struct btree_trans *trans, const char *str, unsigned len)
+static int __bch2_trans_log_str(struct btree_trans *trans, const char *str, unsigned len, ulong ip)
{
unsigned u64s = DIV_ROUND_UP(len, sizeof(u64));
- struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, jset_u64s(u64s));
+ struct jset_entry *e = bch2_trans_jset_entry_alloc_ip(trans, jset_u64s(u64s), ip);
int ret = PTR_ERR_OR_ZERO(e);
if (ret)
return ret;
@@ -830,7 +830,7 @@ static int __bch2_trans_log_str(struct btree_trans *trans, const char *str, unsi
int bch2_trans_log_str(struct btree_trans *trans, const char *str)
{
- return __bch2_trans_log_str(trans, str, strlen(str));
+ return __bch2_trans_log_str(trans, str, strlen(str), _RET_IP_);
}
int bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf)
@@ -839,13 +839,14 @@ int bch2_trans_log_msg(struct btree_trans *trans, struct printbuf *buf)
if (ret)
return ret;
- return __bch2_trans_log_str(trans, buf->buf, buf->pos);
+ return __bch2_trans_log_str(trans, buf->buf, buf->pos, _RET_IP_);
}
int bch2_trans_log_bkey(struct btree_trans *trans, enum btree_id btree,
unsigned level, struct bkey_i *k)
{
- struct jset_entry *e = bch2_trans_jset_entry_alloc(trans, jset_u64s(k->k.u64s));
+ struct jset_entry *e = bch2_trans_jset_entry_alloc_ip(trans,
+ jset_u64s(k->k.u64s), _RET_IP_);
int ret = PTR_ERR_OR_ZERO(e);
if (ret)
return ret;
diff --git a/fs/bcachefs/btree_update.h b/fs/bcachefs/btree_update.h
index 0b98ab959719..17a6abd7d9cb 100644
--- a/fs/bcachefs/btree_update.h
+++ b/fs/bcachefs/btree_update.h
@@ -137,21 +137,29 @@ static inline void *btree_trans_subbuf_top(struct btree_trans *trans,
void *__bch2_trans_subbuf_alloc(struct btree_trans *,
struct btree_trans_subbuf *,
- unsigned);
+ unsigned, ulong);
static inline void *
-bch2_trans_subbuf_alloc(struct btree_trans *trans,
- struct btree_trans_subbuf *buf,
- unsigned u64s)
+bch2_trans_subbuf_alloc_ip(struct btree_trans *trans,
+ struct btree_trans_subbuf *buf,
+ unsigned u64s, ulong ip)
{
if (buf->u64s + u64s > buf->size)
- return __bch2_trans_subbuf_alloc(trans, buf, u64s);
+ return __bch2_trans_subbuf_alloc(trans, buf, u64s, ip);
void *p = btree_trans_subbuf_top(trans, buf);
buf->u64s += u64s;
return p;
}
+static inline void *
+bch2_trans_subbuf_alloc(struct btree_trans *trans,
+ struct btree_trans_subbuf *buf,
+ unsigned u64s)
+{
+ return bch2_trans_subbuf_alloc_ip(trans, buf, u64s, _THIS_IP_);
+}
+
static inline struct jset_entry *btree_trans_journal_entries_start(struct btree_trans *trans)
{
return btree_trans_subbuf_base(trans, &trans->journal_entries);
@@ -163,9 +171,15 @@ static inline struct jset_entry *btree_trans_journal_entries_top(struct btree_tr
}
static inline struct jset_entry *
+bch2_trans_jset_entry_alloc_ip(struct btree_trans *trans, unsigned u64s, ulong ip)
+{
+ return bch2_trans_subbuf_alloc_ip(trans, &trans->journal_entries, u64s, ip);
+}
+
+static inline struct jset_entry *
bch2_trans_jset_entry_alloc(struct btree_trans *trans, unsigned u64s)
{
- return bch2_trans_subbuf_alloc(trans, &trans->journal_entries, u64s);
+ return bch2_trans_jset_entry_alloc_ip(trans, u64s, _THIS_IP_);
}
int bch2_btree_insert_clone_trans(struct btree_trans *, enum btree_id, struct bkey_i *);