diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-06-16 18:55:07 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:10:01 -0400 |
commit | f375d6ca58d5f28b9c0a3af449a0dd640ddcc6a1 (patch) | |
tree | f8550bdcb9a554a13d514c173ec61814e563ffaf /fs/bcachefs/btree_iter.c | |
parent | 962210b281b327b236215c736b9f648369f0d39d (diff) | |
download | lwn-f375d6ca58d5f28b9c0a3af449a0dd640ddcc6a1.tar.gz lwn-f375d6ca58d5f28b9c0a3af449a0dd640ddcc6a1.zip |
bcachefs: Don't call local_clock() twice in trans_begin()
local_clock() is not as cheap as we'd like it to be, alas
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/btree_iter.c')
-rw-r--r-- | fs/bcachefs/btree_iter.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/bcachefs/btree_iter.c b/fs/bcachefs/btree_iter.c index 0a62f55a3aa8..d906bfb6754d 100644 --- a/fs/bcachefs/btree_iter.c +++ b/fs/bcachefs/btree_iter.c @@ -2850,6 +2850,7 @@ static noinline void bch2_trans_reset_srcu_lock(struct btree_trans *trans) u32 bch2_trans_begin(struct btree_trans *trans) { struct btree_path *path; + u64 now; bch2_trans_reset_updates(trans); @@ -2878,13 +2879,16 @@ u32 bch2_trans_begin(struct btree_trans *trans) path->preserve = false; } + now = local_clock(); if (!trans->restarted && (need_resched() || - local_clock() - trans->last_begin_time > BTREE_TRANS_MAX_LOCK_HOLD_TIME_NS)) { + now - trans->last_begin_time > BTREE_TRANS_MAX_LOCK_HOLD_TIME_NS)) { bch2_trans_unlock(trans); cond_resched(); bch2_trans_relock(trans); + now = local_clock(); } + trans->last_begin_time = now; if (unlikely(time_after(jiffies, trans->srcu_lock_time + msecs_to_jiffies(10)))) bch2_trans_reset_srcu_lock(trans); @@ -2895,7 +2899,6 @@ u32 bch2_trans_begin(struct btree_trans *trans) trans->notrace_relock_fail = false; } - trans->last_begin_time = local_clock(); return trans->restart_count; } |