From: Kent Overstreet Date: Fri, 11 Jun 2021 03:34:02 +0000 (-0400) Subject: bcachefs: Don't disable preemption unnecessarily X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=109a4277124ca1a0ff670b519315c4f381c83ad3;p=linux.git bcachefs: Don't disable preemption unnecessarily Small improvements to some percpu utility code. Signed-off-by: Kent Overstreet --- diff --git a/fs/bcachefs/util.c b/fs/bcachefs/util.c index f183c9d80e2c2..f287bca8498dc 100644 --- a/fs/bcachefs/util.c +++ b/fs/bcachefs/util.c @@ -893,13 +893,9 @@ void eytzinger0_find_test(void) */ u64 *bch2_acc_percpu_u64s(u64 __percpu *p, unsigned nr) { - u64 *ret; + u64 *ret = this_cpu_ptr(p); int cpu; - preempt_disable(); - ret = this_cpu_ptr(p); - preempt_enable(); - for_each_possible_cpu(cpu) { u64 *i = per_cpu_ptr(p, cpu); diff --git a/fs/bcachefs/util.h b/fs/bcachefs/util.h index 91aa8c0a0e094..a0cbebf190b48 100644 --- a/fs/bcachefs/util.h +++ b/fs/bcachefs/util.h @@ -715,10 +715,7 @@ static inline void percpu_u64_set(u64 __percpu *dst, u64 src) for_each_possible_cpu(cpu) *per_cpu_ptr(dst, cpu) = 0; - - preempt_disable(); - *this_cpu_ptr(dst) = src; - preempt_enable(); + this_cpu_write(*dst, src); } static inline void acc_u64s(u64 *acc, const u64 *src, unsigned nr)