From: Kent Overstreet Date: Thu, 13 Jun 2024 18:11:48 +0000 (-0400) Subject: bcachefs: per_cpu_sum() X-Git-Tag: v6.11-rc1~120^2~33 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=132e1a2380d06c31a17c773aac6c676658b9686a;p=thirdparty%2Fkernel%2Flinux.git bcachefs: per_cpu_sum() Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index cd09edd12d8a5..2def4f761ca64 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -698,14 +698,19 @@ do { \ } \ } while (0) +#define per_cpu_sum(_p) \ +({ \ + typeof(*_p) _ret = 0; \ + \ + int cpu; \ + for_each_possible_cpu(cpu) \ + _ret += *per_cpu_ptr(_p, cpu); \ + _ret; \ +}) + static inline u64 percpu_u64_get(u64 __percpu *src) { - u64 ret = 0; - int cpu; - - for_each_possible_cpu(cpu) - ret += *per_cpu_ptr(src, cpu); - return ret; + return per_cpu_sum(src); } static inline void percpu_u64_set(u64 __percpu *dst, u64 src)