[1/4] mean and variance: Promote to lib/math
Commit Message
From: Kent Overstreet <kent.overstreet@linux.dev>
Small statistics library, for taking in a series of value and computing
mean, weighted mean, standard deviation and weighted deviation.
The main use case is for statistics on latency measurements.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Cc: Daniel Hill <daniel@gluo.nz>
Cc: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
MAINTAINERS | 9 +++++++++
fs/bcachefs/Kconfig | 10 +---------
fs/bcachefs/Makefile | 3 ---
fs/bcachefs/util.c | 2 +-
fs/bcachefs/util.h | 3 +--
include/linux/mean_and_variance.h | 0
lib/Kconfig.debug | 9 +++++++++
lib/math/Kconfig | 3 +++
lib/math/Makefile | 2 ++
lib/math/mean_and_variance.c | 3 +--
lib/math/mean_and_variance_test.c | 3 +--
11 files changed, 28 insertions(+), 19 deletions(-)
rename fs/bcachefs/mean_and_variance.h => include/linux/mean_and_variance.h (100%)
rename fs/bcachefs/mean_and_variance.c => lib/math/mean_and_variance.c (99%)
rename fs/bcachefs/mean_and_variance_test.c => lib/math/mean_and_variance_test.c (99%)
@@ -13387,6 +13387,15 @@ S: Maintained
F: drivers/net/mdio/mdio-regmap.c
F: include/linux/mdio/mdio-regmap.h
+MEAN AND VARIANCE LIBRARY
+M: Daniel B. Hill <daniel@gluo.nz>
+M: Kent Overstreet <kent.overstreet@linux.dev>
+S: Maintained
+T: git https://github.com/YellowOnion/linux/
+F: include/linux/mean_and_variance.h
+F: lib/math/mean_and_variance.c
+F: lib/math/mean_and_variance_test.c
+
MEASUREMENT COMPUTING CIO-DAC IIO DRIVER
M: William Breathitt Gray <william.gray@linaro.org>
L: linux-iio@vger.kernel.org
@@ -24,6 +24,7 @@ config BCACHEFS_FS
select XXHASH
select SRCU
select SYMBOLIC_ERRNAME
+ select MEAN_AND_VARIANCE
help
The bcachefs filesystem - a modern, copy on write filesystem, with
support for multiple devices, compression, checksumming, etc.
@@ -86,12 +87,3 @@ config BCACHEFS_SIX_OPTIMISTIC_SPIN
Instead of immediately sleeping when attempting to take a six lock that
is held by another thread, spin for a short while, as long as the
thread owning the lock is running.
-
-config MEAN_AND_VARIANCE_UNIT_TEST
- tristate "mean_and_variance unit tests" if !KUNIT_ALL_TESTS
- depends on KUNIT
- depends on BCACHEFS_FS
- default KUNIT_ALL_TESTS
- help
- This option enables the kunit tests for mean_and_variance module.
- If unsure, say N.
@@ -57,7 +57,6 @@ bcachefs-y := \
keylist.o \
logged_ops.o \
lru.o \
- mean_and_variance.o \
migrate.o \
move.o \
movinggc.o \
@@ -88,5 +87,3 @@ bcachefs-y := \
util.o \
varint.o \
xattr.o
-
-obj-$(CONFIG_MEAN_AND_VARIANCE_UNIT_TEST) += mean_and_variance_test.o
@@ -22,9 +22,9 @@
#include <linux/string.h>
#include <linux/types.h>
#include <linux/sched/clock.h>
+#include <linux/mean_and_variance.h>
#include "eytzinger.h"
-#include "mean_and_variance.h"
#include "util.h"
static const char si_units[] = "?kMGTPEZY";
@@ -17,8 +17,7 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/workqueue.h>
-
-#include "mean_and_variance.h"
+#include <linux/mean_and_variance.h>
#include "darray.h"
similarity index 100%
rename from fs/bcachefs/mean_and_variance.h
rename to include/linux/mean_and_variance.h
@@ -2191,6 +2191,15 @@ config CPUMASK_KUNIT_TEST
If unsure, say N.
+config MEAN_AND_VARIANCE_UNIT_TEST
+ tristate "mean_and_variance unit tests" if !KUNIT_ALL_TESTS
+ depends on KUNIT
+ select MEAN_AND_VARIANCE
+ default KUNIT_ALL_TESTS
+ help
+ This option enables the kunit tests for mean_and_variance module.
+ If unsure, say N.
+
config TEST_LIST_SORT
tristate "Linked list sorting test" if !KUNIT_ALL_TESTS
depends on KUNIT
@@ -15,3 +15,6 @@ config PRIME_NUMBERS
config RATIONAL
tristate
+
+config MEAN_AND_VARIANCE
+ tristate
@@ -4,6 +4,8 @@ obj-y += div64.o gcd.o lcm.o int_log.o int_pow.o int_sqrt.o reciprocal_div.o
obj-$(CONFIG_CORDIC) += cordic.o
obj-$(CONFIG_PRIME_NUMBERS) += prime_numbers.o
obj-$(CONFIG_RATIONAL) += rational.o
+obj-$(CONFIG_MEAN_AND_VARIANCE) += mean_and_variance.o
obj-$(CONFIG_TEST_DIV64) += test_div64.o
obj-$(CONFIG_RATIONAL_KUNIT_TEST) += rational-test.o
+obj-$(CONFIG_MEAN_AND_VARIANCE_UNIT_TEST) += mean_and_variance_test.o
similarity index 99%
rename from fs/bcachefs/mean_and_variance.c
rename to lib/math/mean_and_variance.c
@@ -40,10 +40,9 @@
#include <linux/limits.h>
#include <linux/math.h>
#include <linux/math64.h>
+#include <linux/mean_and_variance.h>
#include <linux/module.h>
-#include "mean_and_variance.h"
-
u128_u u128_div(u128_u n, u64 d)
{
u128_u r;
similarity index 99%
rename from fs/bcachefs/mean_and_variance_test.c
rename to lib/math/mean_and_variance_test.c
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-2.0
#include <kunit/test.h>
-
-#include "mean_and_variance.h"
+#include <linux/mean_and_variance.h>
#define MAX_SQR (SQRT_U64_MAX*SQRT_U64_MAX)