]> granicus.if.org Git - spl/commitdiff
Ensure direct reclaim forward progress
authorBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 1 May 2012 22:49:07 +0000 (15:49 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Mon, 7 May 2012 18:54:19 +0000 (11:54 -0700)
The Linux direct reclaim path uses this out of band value to
determine if forward progress is being made.  Normally this is
incremented by kmem_freepages() which is part of the various
Linux slab implementations.  However, since we are using none
of that infrastructure we're responsible for incrementing this
count.

If no forward progress is detected and a subsequent allocation
fails the OOM killer will be invoked.  If there was forward
progress additional reclaim will be attempted via the page
cache and registerd shrinker until the allocation succeeds.

Signed-off-by: Prakash Surya <surya1@llnl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #107

module/spl/spl-kmem.c

index 361030b18131971fa064e1e9dffc203bae930b49..f7d5f7e86b31129eba02d589ebbe2e610703cadc 100644 (file)
@@ -880,6 +880,16 @@ kv_free(spl_kmem_cache_t *skc, void *ptr, int size)
        ASSERT(IS_P2ALIGNED(ptr, PAGE_SIZE));
        ASSERT(ISP2(size));
 
+       /*
+        * The Linux direct reclaim path uses this out of band value to
+        * determine if forward progress is being made.  Normally this is
+        * incremented by kmem_freepages() which is part of the various
+        * Linux slab implementations.  However, since we are using none
+        * of that infrastructure we are responsible for incrementing it.
+        */
+       if (current->reclaim_state)
+               current->reclaim_state->reclaimed_slab += size >> PAGE_SHIFT;
+
        if (skc->skc_flags & KMC_KMEM)
                free_pages((unsigned long)ptr, get_order(size));
        else