summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkoverstreet <kent.overstreet@gmail.com>2018-11-04 17:42:20 -0500
committerGitHub <noreply@github.com>2018-11-04 17:42:20 -0500
commit6da91e81cc8b84e0efff09b40dffa004b4c0be90 (patch)
tree54553ad0ef77394dbdb70af01a364e7fe89a9b25
parentf420a809b44d1d41f2d6ce461f808224028edc51 (diff)
parentf885dc20eb83c134b559059481d77c724297d236 (diff)
Merge pull request #10 from modelrockettier/shrinkersv0.1
Don't read meminfo if there are no shrinkers
-rw-r--r--linux/shrinker.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/linux/shrinker.c b/linux/shrinker.c
index b8fc246..7926be0 100644
--- a/linux/shrinker.c
+++ b/linux/shrinker.c
@@ -69,8 +69,15 @@ static struct meminfo read_meminfo(void)
void run_shrinkers(void)
{
struct shrinker *shrinker;
- struct meminfo info = read_meminfo();
- s64 want_shrink = (info.total >> 2) - info.available;
+ struct meminfo info;
+ s64 want_shrink;
+
+ /* Fast out if there are no shrinkers to run. */
+ if (list_empty(&shrinker_list))
+ return;
+
+ info = read_meminfo();
+ want_shrink = (info.total >> 2) - info.available;
if (want_shrink <= 0)
return;