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
This commit is contained in:
Jean-Sébastien Pédron 2023-02-13 21:49:28 +01:00
parent 53da54b936
commit 8363672729
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
2 changed files with 10 additions and 0 deletions

View File

@ -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_ */

View File

@ -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