aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-02-13 20:49:28 +0000
committerJean-Sébastien Pédron <dumbbell@FreeBSD.org>2023-02-16 11:55:20 +0000
commit01b3fc89ddd8e48c6dfe584d44b6018edc4f3a5f (patch)
tree60964e81066a2bbf8a3b7895e4d4bc6fce6620e8
parent895d286a36cf70fa527538ca3c9a1a545f81a9cd (diff)
downloadsrc-01b3fc89ddd8e48c6dfe584d44b6018edc4f3a5f.tar.gz
src-01b3fc89ddd8e48c6dfe584d44b6018edc4f3a5f.zip
linuxkpi: Add `synchronize_shrinkers()`
It takes the lock and release it immediately to make sure no shrinkers are running in parallel. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38565 (cherry picked from commit 83636727291714c235726da987a02c5b1d51bb54)
-rw-r--r--sys/compat/linuxkpi/common/include/linux/shrinker.h2
-rw-r--r--sys/compat/linuxkpi/common/src/linux_shrinker.c8
2 files changed, 10 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/shrinker.h b/sys/compat/linuxkpi/common/include/linux/shrinker.h
index 39ea35f0a862..04e96a12c4bd 100644
--- a/sys/compat/linuxkpi/common/include/linux/shrinker.h
+++ b/sys/compat/linuxkpi/common/include/linux/shrinker.h
@@ -51,8 +51,10 @@ struct shrinker {
int linuxkpi_register_shrinker(struct shrinker *s);
void linuxkpi_unregister_shrinker(struct shrinker *s);
+void linuxkpi_synchronize_shrinkers(void);
#define register_shrinker(s) linuxkpi_register_shrinker(s)
#define unregister_shrinker(s) linuxkpi_unregister_shrinker(s)
+#define synchronize_shrinkers() linuxkpi_synchronize_shrinkers()
#endif /* _LINUXKPI_LINUX_SHRINKER_H_ */
diff --git a/sys/compat/linuxkpi/common/src/linux_shrinker.c b/sys/compat/linuxkpi/common/src/linux_shrinker.c
index b48e491a4e2f..227ef3261cb3 100644
--- a/sys/compat/linuxkpi/common/src/linux_shrinker.c
+++ b/sys/compat/linuxkpi/common/src/linux_shrinker.c
@@ -64,6 +64,14 @@ linuxkpi_unregister_shrinker(struct shrinker *s)
sx_xunlock(&sx_shrinker);
}
+void
+linuxkpi_synchronize_shrinkers(void)
+{
+
+ sx_xlock(&sx_shrinker);
+ sx_xunlock(&sx_shrinker);
+}
+
#define SHRINKER_BATCH 512
static void