diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-21 15:19:08 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-06-13 16:42:45 -0400 |
commit | b7dd342447c028e7f396f3c799eba88508e86472 (patch) | |
tree | 77a8b718238205cec91b5144b46c04bf41d136ea | |
parent | 30bd9ded2759e758cf227352c6a25fd2e3374659 (diff) |
bcachefs: Cacheline align & prefetch journal reservationsbcachefs-garbage
Writing to the new journal entries is currently a major cacheline miss
in the transaction commit path - this helps. Additionally, this patch
cacheline aligns journal reservations, so that when multiple threads are
doing transaction commits they won't conflict.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/journal.h | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/fs/bcachefs/journal.h b/fs/bcachefs/journal.h index 3d5385f2fe3b..ab0cf8bcd4a1 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -328,17 +328,27 @@ static inline int journal_res_get_fast(struct journal *j, unsigned flags) { union journal_res_state old, new; - unsigned offset; + unsigned u64s, offset; old.v = atomic64_read(&j->reservations.counter); do { new.v = old.v; /* + * Round up the end of the journal reservation to the next + * cacheline boundary: + */ + u64s = res->u64s; + offset = sizeof(struct jset) / sizeof(u64) + + new.cur_entry_offset + u64s; + u64s += ((offset - 1) & ((SMP_CACHE_BYTES / sizeof(u64)) - 1)) + 1; + + + /* * Check if there is still room in the current journal * entry: */ - if (new.cur_entry_offset + res->u64s > j->cur_entry_u64s) + if (new.cur_entry_offset + u64s > j->cur_entry_u64s) return 0; EBUG_ON(!journal_state_count(new, new.idx)); @@ -346,7 +356,7 @@ static inline int journal_res_get_fast(struct journal *j, if ((flags & BCH_WATERMARK_MASK) < j->watermark) return 0; - new.cur_entry_offset += res->u64s; + new.cur_entry_offset += u64s; journal_state_inc(&new); /* @@ -363,6 +373,7 @@ static inline int journal_res_get_fast(struct journal *j, res->ref = true; res->idx = old.idx; + res->u64s = u64s; res->offset = old.cur_entry_offset; res->seq = le64_to_cpu(j->buf[old.idx].data->seq); |