From: Debabrata Banerjee Date: Wed, 15 Mar 2017 22:46:46 +0000 (-0400) Subject: Stop double reclaiming or not reclaiming at all X-Git-Tag: zfs-0.7.0-rc4~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b855550c336c04b2bde85d9ffbd893b196fdd7b5;p=zfs Stop double reclaiming or not reclaiming at all Move arcstat_need_free increment from all direct calls to when arc_reclaim_lock is busy and we exit wihout doing anything. Data will be reclaimed in reclaim thread. The previous location meant that we both reclaim the memory in this thread, and also schedule the same amount of memory for reclaim in arc_reclaim, effectively doubling the requested reclaim. AKAMAI: zfs: CR 3695072 Reviewed-by: Tim Chase Reviewed-by: Richard Yao Reviewed-by: Brian Behlendorf Signed-off-by: Debabrata Banerjee Issue #6035 --- diff --git a/module/zfs/arc.c b/module/zfs/arc.c index fa69e1ea4..b18c7a586 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -4414,8 +4414,10 @@ __arc_shrinker_func(struct shrinker *shrink, struct shrink_control *sc) return (SHRINK_STOP); /* Reclaim in progress */ - if (mutex_tryenter(&arc_reclaim_lock) == 0) + if (mutex_tryenter(&arc_reclaim_lock) == 0) { + ARCSTAT_INCR(arcstat_need_free, ptob(sc->nr_to_scan)); return (SHRINK_STOP); + } mutex_exit(&arc_reclaim_lock); @@ -4453,7 +4455,6 @@ __arc_shrinker_func(struct shrinker *shrink, struct shrink_control *sc) ARCSTAT_BUMP(arcstat_memory_indirect_count); } else { arc_no_grow = B_TRUE; - ARCSTAT_INCR(arcstat_need_free, ptob(sc->nr_to_scan)); ARCSTAT_BUMP(arcstat_memory_direct_count); }