diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2018-12-17 08:44:56 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2018-12-27 11:38:39 -0500 |
commit | 8ac80dff71027c044c7244c1f08928123725c510 (patch) | |
tree | 27f42be2d71be58b6722c504af63830d11db8fb6 /fs/bcachefs/util.h | |
parent | d6542a654ce2d4d014721a8ac74885fbb42ae442 (diff) |
bcachefs: factor out acc_u64s()bcachefs-v4.19
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 905b24f29d1d..5ea096ec5738 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -704,4 +704,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 */ |