diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-12-17 08:44:56 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:14 -0400 |
commit | 23f80d2b3bf7898579c841786c49842789f32ff5 (patch) | |
tree | 685a39d5dca93c04939b2a8b56de2cd949c5d25a /fs/bcachefs/util.h | |
parent | e47c017144fe302dfba09ba9f6629ed5dca6d77f (diff) | |
download | lwn-23f80d2b3bf7898579c841786c49842789f32ff5.tar.gz lwn-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.h | 17 |
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 */ |