@@ -4308,6 +4308,16 @@ i915_gem_object_create(struct drm_i915_private *dev_priv, u64 size)
mapping = obj->base.filp->f_mapping;
mapping_set_gfp_mask(mapping, mask);
+ /* If configured attempt to use THP through shmemfs. This will
+ * effectively default to huge-pages for this mapping if it makes sense
+ * given the object size and HPAGE_PMD_SIZE. This is best effort only.
+ */
+#ifdef CONFIG_TRANSPARENT_HUGE_PAGECACHE
+ if (has_transparent_hugepage() &&
+ HAS_PAGE_SIZE(dev_priv, HPAGE_PMD_SIZE))
+ SHMEM_I(mapping->host)->huge = SHMEM_HUGE_WITHIN_SIZE;
+#endif
+
i915_gem_object_init(obj, &i915_gem_object_ops);
obj->base.write_domain = I915_GEM_DOMAIN_CPU;
Default to transparent-huge-pages for shmem backed objects through the SHMEM_HUGE_WITHIN_SIZE huge option. Best effort only. Signed-off-by: Matthew Auld <matthew.auld@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Dave Hansen <dave.hansen@intel.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Hugh Dickins <hughd@google.com> Cc: linux-mm@kvack.org --- drivers/gpu/drm/i915/i915_gem.c | 10 ++++++++++ 1 file changed, 10 insertions(+)