summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/util.h
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2024-06-13 20:11:48 +0200
committerKent Overstreet <kent.overstreet@linux.dev>2024-07-15 01:00:15 +0200
commit132e1a2380d06c31a17c773aac6c676658b9686a (patch)
tree72682b244d2b2aaf849bf526c4b0ce16e694fdaa /fs/bcachefs/util.h
parentMAINTAINERS: remove Brian Foster as a reviewer for bcachefs (diff)
downloadlinux-132e1a2380d06c31a17c773aac6c676658b9686a.tar.xz
linux-132e1a2380d06c31a17c773aac6c676658b9686a.zip
bcachefs: per_cpu_sum()
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, 11 insertions, 6 deletions
diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h
index cd09edd12d8a..2def4f761ca6 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)