diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2022-10-21 15:19:08 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-05-08 19:26:33 -0400 |
commit | c480e49281dbad7dec46f7c10c4da1eed4e5c81f (patch) | |
tree | 2b07ca63a08d466dd00225de735214f0239f151a | |
parent | f5ebb92005edc288b1b882b9f60cc22bd16fc749 (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 de5ede1fa311..4f819650136c 100644 --- a/fs/bcachefs/journal.h +++ b/fs/bcachefs/journal.h @@ -329,16 +329,26 @@ static inline int journal_res_get_fast(struct journal *j, { union journal_res_state old, new; u64 v = atomic64_read(&j->reservations.counter); - unsigned offset; + unsigned u64s, offset; do { old.v = new.v = 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); |