]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
Don't read meminfo if there are no shrinkers
authorTim Schlueter <schlueter.tim@linux.com>
Fri, 24 Aug 2018 05:37:31 +0000 (22:37 -0700)
committerTim Schlueter <schlueter.tim@linux.com>
Sun, 4 Nov 2018 21:03:56 +0000 (13:03 -0800)
linux/shrinker.c

index b8fc2464e20f55781349ca769fe73082beea5556..7926be06e29f85983e331725877e351a56915680 100644 (file)
@@ -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;