summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-11-23 20:11:46 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-05-12 19:42:20 -0400
commit24a832080f142eb8d3ea28d7dbd15c25784e60bf (patch)
tree3e8f68ca87ed4c57bcf0ece48f14a5f475013615
parent2364af5077436fc5423f5c05d53cd57e52e2929b (diff)
bcachefs: Add some unlikely() annotations
Add a few easy unlikely() optimizations. These are mainly worthwhile because the compiler will (usually) put the branch-not-taken path at the end of the function, meaning better icache utilization. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r--fs/bcachefs/bkey.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/fs/bcachefs/bkey.c b/fs/bcachefs/bkey.c
index 8e6ce2b09e4b..ff5d01e6e674 100644
--- a/fs/bcachefs/bkey.c
+++ b/fs/bcachefs/bkey.c
@@ -488,18 +488,18 @@ enum bkey_pack_pos_ret bch2_bkey_pack_pos_lossy(struct bkey_packed *out,
le64_to_cpu(f->field_offset[BKEY_FIELD_INODE])))
return BKEY_PACK_POS_FAIL;
- if (!set_inc_field_lossy(&state, BKEY_FIELD_INODE, in.inode)) {
+ if (unlikely(!set_inc_field_lossy(&state, BKEY_FIELD_INODE, in.inode))) {
in.offset = KEY_OFFSET_MAX;
in.snapshot = KEY_SNAPSHOT_MAX;
exact = false;
}
- if (!set_inc_field_lossy(&state, BKEY_FIELD_OFFSET, in.offset)) {
+ if (unlikely(!set_inc_field_lossy(&state, BKEY_FIELD_OFFSET, in.offset))) {
in.snapshot = KEY_SNAPSHOT_MAX;
exact = false;
}
- if (!set_inc_field_lossy(&state, BKEY_FIELD_SNAPSHOT, in.snapshot))
+ if (unlikely(!set_inc_field_lossy(&state, BKEY_FIELD_SNAPSHOT, in.snapshot)))
exact = false;
pack_state_finish(&state, out);