drm/i915: Only attempt to scan the requested number of shrinker slabs

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/c5bd1fc9a6c843c85a5cea5765cdc997f832df3c
Commit:     c5bd1fc9a6c843c85a5cea5765cdc997f832df3c
Parent:     d13a8479f3584613b6aacbb793eae64578b8f69a
Refname:    refs/heads/master
Author:     Chris Wilson <[email protected]>
AuthorDate: Mon Jan 15 21:24:46 2018 +0000
Committer:  Rodrigo Vivi <[email protected]>
CommitDate: Thu Feb 1 07:32:41 2018 -0800

    drm/i915: Only attempt to scan the requested number of shrinker slabs
    
    Since commit 4e773c3a8a69 ("drm/i915: Wire up shrinkctl->nr_scanned"),
    we track the number of objects we scan and do not wish to exceed that as
    it will overly penalise our own slabs under mempressure. Given that we
    now know the target number of objects to scan, use that as our guide for
    deciding to shrink as opposed to the number of objects we manage to
    shrink (which doesn't correspond to the numbers we report to shrinkctl).
    
    Fixes: 4e773c3a8a69 ("drm/i915: Wire up shrinkctl->nr_scanned")
    Signed-off-by: Chris Wilson <[email protected]>
    Cc: Joonas Lahtinen <[email protected]>
    Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
    Reviewed-by: Tvrtko Ursulin <[email protected]>
    (cherry picked from commit 29d384e34c55d696cf37bd4159e05f4b14d45da0)
    Signed-off-by: Rodrigo Vivi <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_shrinker.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_shrinker.c b/drivers/gpu/drm/i915/i915_gem_shrinker.c
index 9029ed04879c..0e158f9287c4 100644
--- a/drivers/gpu/drm/i915/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/i915_gem_shrinker.c
@@ -363,13 +363,13 @@ i915_gem_shrinker_scan(struct shrinker *shrinker, struct shrink_control *sc)
 				I915_SHRINK_BOUND |
 				I915_SHRINK_UNBOUND |
 				I915_SHRINK_PURGEABLE);
-	if (freed < sc->nr_to_scan)
+	if (sc->nr_scanned < sc->nr_to_scan)
 		freed += i915_gem_shrink(i915,
 					 sc->nr_to_scan - sc->nr_scanned,
 					 &sc->nr_scanned,
 					 I915_SHRINK_BOUND |
 					 I915_SHRINK_UNBOUND);
-	if (freed < sc->nr_to_scan && current_is_kswapd()) {
+	if (sc->nr_scanned < sc->nr_to_scan && current_is_kswapd()) {
 		intel_runtime_pm_get(i915);
 		freed += i915_gem_shrink(i915,
 					 sc->nr_to_scan - sc->nr_scanned,
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.