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>
This commit is contained in:
parent
962210b281
commit
f375d6ca58
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user