diff options
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 */ |