aboutsummaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2010-07-19 00:56:17 -0400
committerDave Chinner <david@fromorbit.com>2010-07-19 00:56:17 -0400
commit7f8275d0d660c146de6ee3017e1e2e594c49e820 (patch)
tree884db927118b44102750b5168ee36ef4b8b5cb4e /mm/vmscan.c
parentd0c6f6258478e1dba532bf7c28e2cd6e1047d3a4 (diff)
mm: add context argument to shrinker callback
The current shrinker implementation requires the registered callback to have global state to work from. This makes it difficult to shrink caches that are not global (e.g. per-filesystem caches). Pass the shrinker structure to the callback so that users can embed the shrinker structure in the context the shrinker needs to operate on and get back to it in the callback via container_of(). Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 9c7e57cc63a3..199fa436c0dd 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -213,8 +213,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
213 list_for_each_entry(shrinker, &shrinker_list, list) { 213 list_for_each_entry(shrinker, &shrinker_list, list) {
214 unsigned long long delta; 214 unsigned long long delta;
215 unsigned long total_scan; 215 unsigned long total_scan;
216 unsigned long max_pass = (*shrinker->shrink)(0, gfp_mask); 216 unsigned long max_pass;
217 217
218 max_pass = (*shrinker->shrink)(shrinker, 0, gfp_mask);
218 delta = (4 * scanned) / shrinker->seeks; 219 delta = (4 * scanned) / shrinker->seeks;
219 delta *= max_pass; 220 delta *= max_pass;
220 do_div(delta, lru_pages + 1); 221 do_div(delta, lru_pages + 1);
@@ -242,8 +243,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
242 int shrink_ret; 243 int shrink_ret;
243 int nr_before; 244 int nr_before;
244 245
245 nr_before = (*shrinker->shrink)(0, gfp_mask); 246 nr_before = (*shrinker->shrink)(shrinker, 0, gfp_mask);
246 shrink_ret = (*shrinker->shrink)(this_scan, gfp_mask); 247 shrink_ret = (*shrinker->shrink)(shrinker, this_scan,
248 gfp_mask);
247 if (shrink_ret == -1) 249 if (shrink_ret == -1)
248 break; 250 break;
249 if (shrink_ret < nr_before) 251 if (shrink_ret < nr_before)