On 30/09/2025 12:30, Boris Brezillon wrote:
On Mon, 29 Sep 2025 22:03:10 +0200
Loïc Molinari <[email protected]> wrote:
+unsigned long drm_gem_get_unmapped_area(struct file *filp, unsigned long uaddr,
+ unsigned long len, unsigned long pgoff,
+ unsigned long flags)
+{
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ struct drm_gem_object *obj;
+ unsigned long ret;
+
+ obj = drm_gem_object_lookup_from_offset(filp, pgoff, len >> PAGE_SHIFT);
+ if (IS_ERR(obj))
+ return mm_get_unmapped_area(current->mm, filp, uaddr, len, 0,
+ flags);
+
+ ret = shmem_get_unmapped_area(obj->filp, uaddr, len, 0, flags);
+
+ drm_gem_object_put(obj);
+
+ return ret;
+#else
+ return mm_get_unmapped_area(current->mm, filp, uaddr, len, 0, flags);
Looks like the above code covers the non-THP case too, do we really need
to specialize for !CONFIG_TRANSPARENT_HUGEPAGE here?
It does cover the !CONFIG_TRANSPARENT_HUGEPAGE case
(shmem_get_unmapped_area() would just call and return the
mm_get_unmapped_area() address) but the idea here is to avoid the GEM
object lookup cost by calling mm_get_unmapped_area() directly.
+#endif
+}
+EXPORT_SYMBOL(drm_gem_get_unmapped_area);
Loïc