Reducing stack frame usage; this moves the printbuf out of the main
stack frame.

Signed-off-by: Kent Overstreet <[email protected]>
---
 fs/bcachefs/btree_key_cache.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)

diff --git a/fs/bcachefs/btree_key_cache.c b/fs/bcachefs/btree_key_cache.c
index b6b64af826be..2b186584a291 100644
--- a/fs/bcachefs/btree_key_cache.c
+++ b/fs/bcachefs/btree_key_cache.c
@@ -287,6 +287,19 @@ static int btree_key_cache_create(struct btree_trans 
*trans,
        return ret;
 }
 
+static noinline_for_stack void do_trace_key_cache_fill(struct btree_trans 
*trans,
+                                                      struct btree_path 
*ck_path,
+                                                      struct bkey_s_c k)
+{
+       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);
+}
+
 static noinline int btree_key_cache_fill(struct btree_trans *trans,
                                         struct btree_path *ck_path,
                                         unsigned flags)
@@ -320,15 +333,8 @@ static noinline int btree_key_cache_fill(struct 
btree_trans *trans,
        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);
-       }
+       if (trace_key_cache_fill_enabled())
+               do_trace_key_cache_fill(trans, ck_path, k);
 out:
        /* We're not likely to need this iterator again: */
        bch2_set_btree_iter_dontneed(trans, &iter);
-- 
2.49.0


Reply via email to