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>
This commit is contained in:
committed by
Dave Chinner
parent
d0c6f62584
commit
7f8275d0d6
@ -213,8 +213,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
|
||||
list_for_each_entry(shrinker, &shrinker_list, list) {
|
||||
unsigned long long delta;
|
||||
unsigned long total_scan;
|
||||
unsigned long max_pass = (*shrinker->shrink)(0, gfp_mask);
|
||||
unsigned long max_pass;
|
||||
|
||||
max_pass = (*shrinker->shrink)(shrinker, 0, gfp_mask);
|
||||
delta = (4 * scanned) / shrinker->seeks;
|
||||
delta *= max_pass;
|
||||
do_div(delta, lru_pages + 1);
|
||||
@ -242,8 +243,9 @@ unsigned long shrink_slab(unsigned long scanned, gfp_t gfp_mask,
|
||||
int shrink_ret;
|
||||
int nr_before;
|
||||
|
||||
nr_before = (*shrinker->shrink)(0, gfp_mask);
|
||||
shrink_ret = (*shrinker->shrink)(this_scan, gfp_mask);
|
||||
nr_before = (*shrinker->shrink)(shrinker, 0, gfp_mask);
|
||||
shrink_ret = (*shrinker->shrink)(shrinker, this_scan,
|
||||
gfp_mask);
|
||||
if (shrink_ret == -1)
|
||||
break;
|
||||
if (shrink_ret < nr_before)
|
||||
|
Reference in New Issue
Block a user