]> granicus.if.org Git - zfs/commitdiff
Stop double reclaiming or not reclaiming at all
authorDebabrata Banerjee <dbanerje@akamai.com>
Wed, 15 Mar 2017 22:46:46 +0000 (18:46 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 2 May 2017 19:49:36 +0000 (15:49 -0400)
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 <tim@chase2k.com>
Reviewed-by: Richard Yao <ryao@gentoo.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
Issue #6035

module/zfs/arc.c

index fa69e1ea4edb0c1d9a4492cf00c00712d33bc3e9..b18c7a58627580cc76f98c084bb586a27ae98728 100644 (file)
@@ -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);
        }