[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200306011930.99378-1-joel@joelfernandes.org>
Date: Thu, 5 Mar 2020 20:19:30 -0500
From: "Joel Fernandes (Google)" <joel@...lfernandes.org>
To: linux-kernel@...r.kernel.org
Cc: "Joel Fernandes (Google)" <joel@...lfernandes.org>,
surenb@...gle.com,
Arve Hjønnevåg <arve@...roid.com>,
Christian Brauner <christian@...uner.io>,
devel@...verdev.osuosl.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Martijn Coenen <maco@...roid.com>,
Todd Kjos <tkjos@...roid.com>
Subject: [RFC] ashmem: Fix ashmem shrinker nr_to_scan
nr_to_scan is the number of pages to be freed however ashmem doesn't
discount nr_to_scan correctly as it frees ranges. It should be
discounting them by pages than by ranges. Correct the issue.
Cc: surenb@...gle.com
Signed-off-by: Joel Fernandes (Google) <joel@...lfernandes.org>
---
drivers/staging/android/ashmem.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c
index 5891d0744a760..cb525ea6db98a 100644
--- a/drivers/staging/android/ashmem.c
+++ b/drivers/staging/android/ashmem.c
@@ -458,6 +458,8 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
lru_del(range);
freed += range_size(range);
+ sc->nr_to_scan -= range_size(range);
+
mutex_unlock(&ashmem_mutex);
f->f_op->fallocate(f,
FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE,
@@ -467,7 +469,7 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
wake_up_all(&ashmem_shrink_wait);
if (!mutex_trylock(&ashmem_mutex))
goto out;
- if (--sc->nr_to_scan <= 0)
+ if (sc->nr_to_scan <= 0)
break;
}
mutex_unlock(&ashmem_mutex);
--
2.25.0.265.gbab2e86ba0-goog
Powered by blists - more mailing lists