Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7f8275d0 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

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: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent d0c6f625
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -2926,7 +2926,7 @@ static int kvm_mmu_remove_some_alloc_mmu_pages(struct kvm *kvm)
	return kvm_mmu_zap_page(kvm, page) + 1;
}

static int mmu_shrink(int nr_to_scan, gfp_t gfp_mask)
static int mmu_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
{
	struct kvm *kvm;
	struct kvm *kvm_freed = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -4978,7 +4978,7 @@ i915_gpu_is_active(struct drm_device *dev)
}

static int
i915_gem_shrink(int nr_to_scan, gfp_t gfp_mask)
i915_gem_shrink(struct shrinker *shrink, int nr_to_scan, gfp_t gfp_mask)
{
	drm_i915_private_t *dev_priv, *next_dev;
	struct drm_i915_gem_object *obj_priv, *next_obj;
+1 −1
Original line number Diff line number Diff line
@@ -896,7 +896,7 @@ EXPORT_SYMBOL(shrink_dcache_parent);
 *
 * In this case we return -1 to tell the caller that we baled.
 */
static int shrink_dcache_memory(int nr, gfp_t gfp_mask)
static int shrink_dcache_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
{
	if (nr) {
		if (!(gfp_mask & __GFP_FS))
+1 −1
Original line number Diff line number Diff line
@@ -1358,7 +1358,7 @@ void gfs2_glock_complete(struct gfs2_glock *gl, int ret)
}


static int gfs2_shrink_glock_memory(int nr, gfp_t gfp_mask)
static int gfs2_shrink_glock_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
{
	struct gfs2_glock *gl;
	int may_demote;
+1 −1
Original line number Diff line number Diff line
@@ -77,7 +77,7 @@ static LIST_HEAD(qd_lru_list);
static atomic_t qd_lru_count = ATOMIC_INIT(0);
static DEFINE_SPINLOCK(qd_lru_lock);

int gfs2_shrink_qd_memory(int nr, gfp_t gfp_mask)
int gfs2_shrink_qd_memory(struct shrinker *shrink, int nr, gfp_t gfp_mask)
{
	struct gfs2_quota_data *qd;
	struct gfs2_sbd *sdp;
Loading