summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-10-22 17:35:35 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2019-10-23 14:57:45 -0400
commit7829a5d7ddfa3d7367fc11a9c35f60843ec4feea (patch)
tree183a25c1ed961d6ec180d3e75df09a01362c4868
parent7199f1dbf7426e5a81357326eefc709f2694903f (diff)
bcachefs: Don't use rep movsq for small memcopies
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
-rw-r--r--fs/bcachefs/bkey.h4
-rw-r--r--fs/bcachefs/extents.c4
-rw-r--r--fs/bcachefs/util.h28
3 files changed, 32 insertions, 4 deletions
diff --git a/fs/bcachefs/bkey.h b/fs/bcachefs/bkey.h
index 5ef66aed338d..b26f4934b264 100644
--- a/fs/bcachefs/bkey.h
+++ b/fs/bcachefs/bkey.h
@@ -87,8 +87,8 @@ do { \
(u64 *) (_dst) < (u64 *) (_src) + \
((struct bkey *) (_src))->u64s); \
\
- __memmove_u64s_down((_dst), (_src), \
- ((struct bkey *) (_src))->u64s); \
+ memcpy_u64s_small((_dst), (_src), \
+ ((struct bkey *) (_src))->u64s); \
} while (0)
struct btree;
diff --git a/fs/bcachefs/extents.c b/fs/bcachefs/extents.c
index 4d06f1613d79..384180ccad6a 100644
--- a/fs/bcachefs/extents.c
+++ b/fs/bcachefs/extents.c
@@ -1458,8 +1458,8 @@ static inline void __extent_entry_insert(struct bkey_i *k,
{
union bch_extent_entry *end = bkey_val_end(bkey_i_to_s(k));
- memmove_u64s_up((u64 *) dst + extent_entry_u64s(new),
- dst, (u64 *) end - (u64 *) dst);
+ memmove_u64s_up_small((u64 *) dst + extent_entry_u64s(new),
+ dst, (u64 *) end - (u64 *) dst);
k->k.u64s += extent_entry_u64s(new);
memcpy(dst, new, extent_entry_bytes(new));
}
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index fa3a991453e9..66bc9be830fc 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -550,6 +550,16 @@ size_t bch2_rand_range(size_t);
void memcpy_to_bio(struct bio *, struct bvec_iter, void *);
void memcpy_from_bio(void *, struct bio *, struct bvec_iter);
+static inline void memcpy_u64s_small(void *dst, const void *src,
+ unsigned u64s)
+{
+ u64 *d = dst;
+ const u64 *s = src;
+
+ while (u64s--)
+ *d++ = *s++;
+}
+
static inline void __memcpy_u64s(void *dst, const void *src,
unsigned u64s)
{
@@ -591,6 +601,24 @@ static inline void memmove_u64s_down(void *dst, const void *src,
__memmove_u64s_down(dst, src, u64s);
}
+static inline void __memmove_u64s_up_small(void *_dst, const void *_src,
+ unsigned u64s)
+{
+ u64 *dst = (u64 *) _dst + u64s;
+ u64 *src = (u64 *) _src + u64s;
+
+ while (u64s--)
+ *--dst = *--src;
+}
+
+static inline void memmove_u64s_up_small(void *dst, const void *src,
+ unsigned u64s)
+{
+ EBUG_ON(dst < src);
+
+ __memmove_u64s_up_small(dst, src, u64s);
+}
+
static inline void __memmove_u64s_up(void *_dst, const void *_src,
unsigned u64s)
{