summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-06-04 18:10:23 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-06-04 18:10:29 -0400
commit8642d4ae10f167a2eb850403f6d2b60757242b31 (patch)
tree6cd7f6586f779a806e7f33c8f3e76aebc1cf1064 /include
parent1f78fed4693a5361f56508daac59bebd5b556379 (diff)
Update bcachefs sources to 7c0fe6f104 bcachefs: Fix bch2_fsck_ask_yn()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'include')
-rw-r--r--include/linux/atomic.h7
-rw-r--r--include/linux/math.h5
-rw-r--r--include/linux/mean_and_variance.h17
-rw-r--r--include/linux/sched.h2
4 files changed, 20 insertions, 11 deletions
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 79cf5aa9..f4d047c1 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -271,6 +271,13 @@ static inline i_type a_type##_cmpxchg(a_type##_t *v, i_type old, i_type new)\
static inline i_type a_type##_cmpxchg_acquire(a_type##_t *v, i_type old, i_type new)\
{ \
return cmpxchg_acquire(&v->counter, old, new); \
+} \
+ \
+static inline bool a_type##_try_cmpxchg_acquire(a_type##_t *v, i_type *old, i_type new)\
+{ \
+ i_type prev = *old; \
+ *old = cmpxchg_acquire(&v->counter, *old, new); \
+ return prev == *old; \
}
DEF_ATOMIC_OPS(atomic, int)
diff --git a/include/linux/math.h b/include/linux/math.h
index 3cf6726d..db7cdd23 100644
--- a/include/linux/math.h
+++ b/include/linux/math.h
@@ -2,6 +2,11 @@
#ifndef _LINUX_MATH_H
#define _LINUX_MATH_H
+#include <linux/kernel.h>
+
+/* abs() */
+#include <stdlib.h>
+
/*
* This looks more complex than it should be. But we need to
* get the type for the ~ right in round_down (it needs to be
diff --git a/include/linux/mean_and_variance.h b/include/linux/mean_and_variance.h
index 9ed79f42..64750501 100644
--- a/include/linux/mean_and_variance.h
+++ b/include/linux/mean_and_variance.h
@@ -3,10 +3,9 @@
#define MEAN_AND_VARIANCE_H_
#include <linux/types.h>
-#include <linux/kernel.h>
#include <linux/limits.h>
+#include <linux/math.h>
#include <linux/math64.h>
-#include <stdlib.h>
#define SQRT_U64_MAX 4294967295ULL
@@ -178,14 +177,12 @@ static inline s64 fast_divpow2(s64 n, u8 d)
*
* see linked pdf equation 12.
*/
-static inline struct mean_and_variance
-mean_and_variance_update(struct mean_and_variance s, s64 v)
-{
- return (struct mean_and_variance) {
- .n = s.n + 1,
- .sum = s.sum + v,
- .sum_squares = u128_add(s.sum_squares, u128_square(abs(v))),
- };
+static inline void
+mean_and_variance_update(struct mean_and_variance *s, s64 v)
+{
+ s->n++;
+ s->sum += v;
+ s->sum_squares = u128_add(s->sum_squares, u128_square(abs(v)));
}
s64 mean_and_variance_get_mean(struct mean_and_variance s);
diff --git a/include/linux/sched.h b/include/linux/sched.h
index fef7e323..c5c8e3ac 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -117,7 +117,7 @@ static inline void put_task_struct(struct task_struct *t)
__put_task_struct(t);
}
-#define cond_resched()
+static inline void cond_resched(void) {}
#define need_resched() 0
void schedule(void);