summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2018-12-17 08:44:56 -0500
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:14 -0400
commit23f80d2b3bf7898579c841786c49842789f32ff5 (patch)
tree685a39d5dca93c04939b2a8b56de2cd949c5d25a /fs/bcachefs/util.h
parente47c017144fe302dfba09ba9f6629ed5dca6d77f (diff)
downloadlinux-stable-23f80d2b3bf7898579c841786c49842789f32ff5.tar.gz
linux-stable-23f80d2b3bf7898579c841786c49842789f32ff5.tar.bz2
linux-stable-23f80d2b3bf7898579c841786c49842789f32ff5.zip
bcachefs: Factor out acc_u64s()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/util.h')
-rw-r--r--fs/bcachefs/util.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index 7d1e6cc6afda..094c35f40209 100644
--- a/fs/bcachefs/util.h
+++ b/fs/bcachefs/util.h
@@ -700,4 +700,21 @@ do { \
} \
} while (0)
+static inline void acc_u64s(u64 *acc, const u64 *src, unsigned nr)
+{
+ unsigned i;
+
+ for (i = 0; i < nr; i++)
+ acc[i] += src[i];
+}
+
+static inline void acc_u64s_percpu(u64 *acc, const u64 __percpu *src,
+ unsigned nr)
+{
+ int cpu;
+
+ for_each_possible_cpu(cpu)
+ acc_u64s(acc, per_cpu_ptr(src, cpu), nr);
+}
+
#endif /* _BCACHEFS_UTIL_H */