From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Cc: Chris Wilson <chris@chris-wilson.co.uk>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, Matthew Auld <matthew.auld@intel.com>, Dave Hansen <dave.hansen@intel.com>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>, Andrew Morton <akpm@linux-foundation.org>, Michal Hocko <mhocko@suse.com> Subject: [RFC] mm,drm/i915: Mark pinned shmemfs pages as unevictable Date: Tue, 6 Jun 2017 13:04:36 +0100 [thread overview] Message-ID: <20170606120436.8683-1-chris@chris-wilson.co.uk> (raw) Similar in principle to the treatment of get_user_pages, pages that i915.ko acquires from shmemfs are not immediately reclaimable and so should be excluded from the mm accounting and vmscan until they have been returned to the system via shrink_slab/i915_gem_shrink. By moving the unreclaimable pages off the inactive anon lru, not only should vmscan be improved by avoiding walking unreclaimable pages, but the system should also have a better idea of how much memory it can reclaim at that moment in time. Note, however, the interaction with shrink_slab which will move some mlocked pages back to the inactive anon lru. Suggested-by: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Michal Hocko <mhocko@suse.com> --- drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++++- mm/mlock.c | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8cb811519db1..37a98fbc6a12 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2193,6 +2193,9 @@ void __i915_gem_object_truncate(struct drm_i915_gem_object *obj) obj->mm.pages = ERR_PTR(-EFAULT); } +extern void mlock_vma_page(struct page *page); +extern unsigned int munlock_vma_page(struct page *page); + static void i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, struct sg_table *pages) @@ -2214,6 +2217,10 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, if (obj->mm.madv == I915_MADV_WILLNEED) mark_page_accessed(page); + lock_page(page); + munlock_vma_page(page); + unlock_page(page); + put_page(page); } obj->mm.dirty = false; @@ -2412,6 +2419,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) } last_pfn = page_to_pfn(page); + lock_page(page); + mlock_vma_page(page); + unlock_page(page); + /* Check that the i965g/gm workaround works. */ WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL)); } @@ -2450,8 +2461,12 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) err_sg: sg_mark_end(sg); err_pages: - for_each_sgt_page(page, sgt_iter, st) + for_each_sgt_page(page, sgt_iter, st) { + lock_page(page); + munlock_vma_page(page); + unlock_page(page); put_page(page); + } sg_free_table(st); kfree(st); diff --git a/mm/mlock.c b/mm/mlock.c index b562b5523a65..531d9f8fd033 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -94,6 +94,7 @@ void mlock_vma_page(struct page *page) putback_lru_page(page); } } +EXPORT_SYMBOL_GPL(mlock_vma_page); /* * Isolate a page from LRU with optional get_page() pin. @@ -211,6 +212,7 @@ unsigned int munlock_vma_page(struct page *page) out: return nr_pages - 1; } +EXPORT_SYMBOL_GPL(munlock_vma_page); /* * convert get_user_pages() return value to posix mlock() error -- 2.11.0 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk> To: intel-gfx@lists.freedesktop.org, linux-mm@kvack.org Cc: Michal Hocko <mhocko@suse.com>, Dave Hansen <dave.hansen@intel.com>, Matthew Auld <matthew.auld@intel.com>, Andrew Morton <akpm@linux-foundation.org>, "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com> Subject: [RFC] mm, drm/i915: Mark pinned shmemfs pages as unevictable Date: Tue, 6 Jun 2017 13:04:36 +0100 [thread overview] Message-ID: <20170606120436.8683-1-chris@chris-wilson.co.uk> (raw) Similar in principle to the treatment of get_user_pages, pages that i915.ko acquires from shmemfs are not immediately reclaimable and so should be excluded from the mm accounting and vmscan until they have been returned to the system via shrink_slab/i915_gem_shrink. By moving the unreclaimable pages off the inactive anon lru, not only should vmscan be improved by avoiding walking unreclaimable pages, but the system should also have a better idea of how much memory it can reclaim at that moment in time. Note, however, the interaction with shrink_slab which will move some mlocked pages back to the inactive anon lru. Suggested-by: Dave Hansen <dave.hansen@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: "Kirill A . Shutemov" <kirill.shutemov@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Michal Hocko <mhocko@suse.com> --- drivers/gpu/drm/i915/i915_gem.c | 17 ++++++++++++++++- mm/mlock.c | 2 ++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index 8cb811519db1..37a98fbc6a12 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -2193,6 +2193,9 @@ void __i915_gem_object_truncate(struct drm_i915_gem_object *obj) obj->mm.pages = ERR_PTR(-EFAULT); } +extern void mlock_vma_page(struct page *page); +extern unsigned int munlock_vma_page(struct page *page); + static void i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, struct sg_table *pages) @@ -2214,6 +2217,10 @@ i915_gem_object_put_pages_gtt(struct drm_i915_gem_object *obj, if (obj->mm.madv == I915_MADV_WILLNEED) mark_page_accessed(page); + lock_page(page); + munlock_vma_page(page); + unlock_page(page); + put_page(page); } obj->mm.dirty = false; @@ -2412,6 +2419,10 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) } last_pfn = page_to_pfn(page); + lock_page(page); + mlock_vma_page(page); + unlock_page(page); + /* Check that the i965g/gm workaround works. */ WARN_ON((gfp & __GFP_DMA32) && (last_pfn >= 0x00100000UL)); } @@ -2450,8 +2461,12 @@ i915_gem_object_get_pages_gtt(struct drm_i915_gem_object *obj) err_sg: sg_mark_end(sg); err_pages: - for_each_sgt_page(page, sgt_iter, st) + for_each_sgt_page(page, sgt_iter, st) { + lock_page(page); + munlock_vma_page(page); + unlock_page(page); put_page(page); + } sg_free_table(st); kfree(st); diff --git a/mm/mlock.c b/mm/mlock.c index b562b5523a65..531d9f8fd033 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -94,6 +94,7 @@ void mlock_vma_page(struct page *page) putback_lru_page(page); } } +EXPORT_SYMBOL_GPL(mlock_vma_page); /* * Isolate a page from LRU with optional get_page() pin. @@ -211,6 +212,7 @@ unsigned int munlock_vma_page(struct page *page) out: return nr_pages - 1; } +EXPORT_SYMBOL_GPL(munlock_vma_page); /* * convert get_user_pages() return value to posix mlock() error -- 2.11.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next reply other threads:[~2017-06-06 12:05 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2017-06-06 12:04 Chris Wilson [this message] 2017-06-06 12:04 ` [RFC] mm, drm/i915: Mark pinned shmemfs pages as unevictable Chris Wilson 2017-06-06 12:14 ` [RFC] mm,drm/i915: " Michal Hocko 2017-06-06 12:14 ` [RFC] mm, drm/i915: " Michal Hocko 2017-06-06 12:30 ` [RFC] mm,drm/i915: " Vlastimil Babka 2017-06-06 14:05 ` Chris Wilson 2017-06-06 17:47 ` Jerome Glisse 2017-06-06 17:47 ` Jerome Glisse 2017-06-06 12:34 ` Chris Wilson 2017-06-06 16:17 ` Dave Hansen 2017-06-06 16:17 ` Dave Hansen 2017-06-06 16:23 ` Peter Zijlstra 2017-08-19 13:15 ` Chris Wilson 2017-08-21 14:06 ` Michal Hocko 2017-08-21 15:03 ` Chris Wilson 2017-08-21 15:57 ` Peter Zijlstra 2017-08-21 15:57 ` [RFC] mm, drm/i915: " Peter Zijlstra 2017-08-21 16:29 ` [RFC] mm,drm/i915: " Christopher Lameter
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20170606120436.8683-1-chris@chris-wilson.co.uk \ --to=chris@chris-wilson.co.uk \ --cc=akpm@linux-foundation.org \ --cc=dave.hansen@intel.com \ --cc=intel-gfx@lists.freedesktop.org \ --cc=joonas.lahtinen@linux.intel.com \ --cc=kirill.shutemov@linux.intel.com \ --cc=linux-mm@kvack.org \ --cc=matthew.auld@intel.com \ --cc=mhocko@suse.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.