mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]>
This commit is contained in:
parent
d0c6f62584
commit
7f8275d0d6
18 changed files with 31 additions and 22 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue