From: "Loïc Molinari" <loic.molinari@collabora.com>
To: "Tvrtko Ursulin" <tursulin@ursulin.net>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Boris Brezillon" <boris.brezillon@collabora.com>,
"Rob Herring" <robh@kernel.org>,
"Steven Price" <steven.price@arm.com>,
"Liviu Dudau" <liviu.dudau@arm.com>,
"Melissa Wen" <mwen@igalia.com>,
"Maíra Canal" <mcanal@igalia.com>,
"Hugh Dickins" <hughd@google.com>,
"Baolin Wang" <baolin.wang@linux.alibaba.com>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Al Viro" <viro@zeniv.linux.org.uk>,
"Mikołaj Wasiak" <mikolaj.wasiak@intel.com>,
"Christian Brauner" <brauner@kernel.org>,
"Nitin Gote" <nitin.r.gote@intel.com>,
"Andi Shyti" <andi.shyti@linux.intel.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Christopher Healy" <healych@amazon.com>,
"Matthew Wilcox" <willy@infradead.org>,
"Bagas Sanjaya" <bagasdotme@gmail.com>
Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-mm@kvack.org,
linux-doc@vger.kernel.org, kernel@collabora.com
Subject: Re: [PATCH v9 06/11] drm/v3d: Use huge tmpfs mountpoint helpers
Date: Fri, 28 Nov 2025 19:19:03 +0100 [thread overview]
Message-ID: <411f7b0f-858c-4486-8819-c01b29cc123a@collabora.com> (raw)
In-Reply-To: <75cf65a0-8967-4e39-8bfe-aa284f8242b3@ursulin.net>
On 20/11/2025 10:39, Tvrtko Ursulin wrote:
>
> On 14/11/2025 17:02, Loïc Molinari wrote:
>> Make use of the new drm_gem_huge_mnt_create() and
>> drm_gem_get_huge_mnt() helpers to avoid code duplication. Now that
>> it's just a few lines long, the single function in v3d_gemfs.c is
>> moved into v3d_gem.c.
>>
>> v3:
>> - use huge tmpfs mountpoint in drm_device
>> - move v3d_gemfs.c into v3d_gem.c
>>
>> v4:
>> - clean up mountpoint creation error handling
>>
>> v5:
>> - fix CONFIG_TRANSPARENT_HUGEPAGE check
>> - use drm_gem_has_huge_mnt() helper
>>
>> v8:
>> - don't access huge_mnt field with CONFIG_TRANSPARENT_HUGEPAGE=n
>>
>> v9:
>> - replace drm_gem_has_huge_mnt() by drm_gem_get_huge_mnt()
>>
>> Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
>> ---
>> drivers/gpu/drm/v3d/Makefile | 3 +-
>> drivers/gpu/drm/v3d/v3d_bo.c | 9 +++--
>> drivers/gpu/drm/v3d/v3d_drv.c | 2 +-
>> drivers/gpu/drm/v3d/v3d_drv.h | 11 +-----
>> drivers/gpu/drm/v3d/v3d_gem.c | 27 ++++++++++++--
>> drivers/gpu/drm/v3d/v3d_gemfs.c | 62 ---------------------------------
>> 6 files changed, 34 insertions(+), 80 deletions(-)
>> delete mode 100644 drivers/gpu/drm/v3d/v3d_gemfs.c
>>
>> diff --git a/drivers/gpu/drm/v3d/Makefile b/drivers/gpu/drm/v3d/Makefile
>> index fcf710926057..b7d673f1153b 100644
>> --- a/drivers/gpu/drm/v3d/Makefile
>> +++ b/drivers/gpu/drm/v3d/Makefile
>> @@ -13,8 +13,7 @@ v3d-y := \
>> v3d_trace_points.o \
>> v3d_sched.o \
>> v3d_sysfs.o \
>> - v3d_submit.o \
>> - v3d_gemfs.o
>> + v3d_submit.o
>> v3d-$(CONFIG_DEBUG_FS) += v3d_debugfs.o
>> diff --git a/drivers/gpu/drm/v3d/v3d_bo.c b/drivers/gpu/drm/v3d/v3d_bo.c
>> index d9547f5117b9..211578abf9b6 100644
>> --- a/drivers/gpu/drm/v3d/v3d_bo.c
>> +++ b/drivers/gpu/drm/v3d/v3d_bo.c
>> @@ -114,7 +114,7 @@ v3d_bo_create_finish(struct drm_gem_object *obj)
>> if (IS_ERR(sgt))
>> return PTR_ERR(sgt);
>> - if (!v3d->gemfs)
>> + if (!drm_gem_get_huge_mnt(obj->dev))
>> align = SZ_4K;
>> else if (obj->size >= SZ_1M)
>> align = SZ_1M;
>> @@ -150,12 +150,15 @@ struct v3d_bo *v3d_bo_create(struct drm_device
>> *dev, struct drm_file *file_priv,
>> size_t unaligned_size)
>> {
>> struct drm_gem_shmem_object *shmem_obj;
>> - struct v3d_dev *v3d = to_v3d_dev(dev);
>> struct v3d_bo *bo;
>> int ret;
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>> shmem_obj = drm_gem_shmem_create_with_mnt(dev, unaligned_size,
>> - v3d->gemfs);
>> + dev->huge_mnt);
>> +#else
>> + shmem_obj = drm_gem_shmem_create(dev, unaligned_size);
>> +#endif
>
> Don't you want to use the same pattern not requiring #ifdef as you did
> in i915?
Yes, I'm going to propose a v10 doing so.
> The rest looks good to me on a glance. Only functional change appears to
> be that you are adding a new error message, scrolling down..
>
>> if (IS_ERR(shmem_obj))
>> return ERR_CAST(shmem_obj);
>> bo = to_v3d_bo(&shmem_obj->base);
>> diff --git a/drivers/gpu/drm/v3d/v3d_drv.c b/drivers/gpu/drm/v3d/
>> v3d_drv.c
>> index e8a46c8bad8a..8faa9382846f 100644
>> --- a/drivers/gpu/drm/v3d/v3d_drv.c
>> +++ b/drivers/gpu/drm/v3d/v3d_drv.c
>> @@ -107,7 +107,7 @@ static int v3d_get_param_ioctl(struct drm_device
>> *dev, void *data,
>> args->value = v3d->perfmon_info.max_counters;
>> return 0;
>> case DRM_V3D_PARAM_SUPPORTS_SUPER_PAGES:
>> - args->value = !!v3d->gemfs;
>> + args->value = !!drm_gem_get_huge_mnt(dev);
>> return 0;
>> case DRM_V3D_PARAM_GLOBAL_RESET_COUNTER:
>> mutex_lock(&v3d->reset_lock);
>> diff --git a/drivers/gpu/drm/v3d/v3d_drv.h b/drivers/gpu/drm/v3d/
>> v3d_drv.h
>> index 1884686985b8..99a39329bb85 100644
>> --- a/drivers/gpu/drm/v3d/v3d_drv.h
>> +++ b/drivers/gpu/drm/v3d/v3d_drv.h
>> @@ -158,11 +158,6 @@ struct v3d_dev {
>> struct drm_mm mm;
>> spinlock_t mm_lock;
>> - /*
>> - * tmpfs instance used for shmem backed objects
>> - */
>> - struct vfsmount *gemfs;
>> -
>> struct work_struct overflow_mem_work;
>> struct v3d_queue_state queue[V3D_MAX_QUEUES];
>> @@ -569,6 +564,7 @@ extern const struct dma_fence_ops v3d_fence_ops;
>> struct dma_fence *v3d_fence_create(struct v3d_dev *v3d, enum
>> v3d_queue q);
>> /* v3d_gem.c */
>> +extern bool super_pages;
>> int v3d_gem_init(struct drm_device *dev);
>> void v3d_gem_destroy(struct drm_device *dev);
>> void v3d_reset_sms(struct v3d_dev *v3d);
>> @@ -576,11 +572,6 @@ void v3d_reset(struct v3d_dev *v3d);
>> void v3d_invalidate_caches(struct v3d_dev *v3d);
>> void v3d_clean_caches(struct v3d_dev *v3d);
>> -/* v3d_gemfs.c */
>> -extern bool super_pages;
>> -void v3d_gemfs_init(struct v3d_dev *v3d);
>> -void v3d_gemfs_fini(struct v3d_dev *v3d);
>> -
>> /* v3d_submit.c */
>> void v3d_job_cleanup(struct v3d_job *job);
>> void v3d_job_put(struct v3d_job *job);
>> diff --git a/drivers/gpu/drm/v3d/v3d_gem.c b/drivers/gpu/drm/v3d/
>> v3d_gem.c
>> index 5a180dc6c452..62532a89dd14 100644
>> --- a/drivers/gpu/drm/v3d/v3d_gem.c
>> +++ b/drivers/gpu/drm/v3d/v3d_gem.c
>> @@ -259,6 +259,30 @@ v3d_invalidate_caches(struct v3d_dev *v3d)
>> v3d_invalidate_slices(v3d, 0);
>> }
>> +static void
>> +v3d_huge_mnt_init(struct v3d_dev *v3d)
>> +{
>> + int err = 0;
>> +
>> + /*
>> + * By using a huge shmemfs mountpoint when the user wants to
>> + * enable Super Pages, we can pass in mount flags that better
>> + * match our usecase.
>> + */
>> +
>> + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && super_pages)
>> + err = drm_gem_huge_mnt_create(&v3d->drm, "within_size");
>> +
>> + if (drm_gem_get_huge_mnt(&v3d->drm))
>> + drm_info(&v3d->drm, "Using Transparent Hugepages\n");
>> + else if (err)
>> + drm_warn(&v3d->drm, "Can't use Transparent Hugepages (%d)\n",
>> + err);
>
> .. here, but that looks acceptable to me.
It logs a warning instead of the notice below in case of error at huge
mounpoint creation. Looks acceptable to me too. I'd be happy to get the
point of view of a V3D maintainer as well here.
Regards,
Loïc
> Regards,
>
> Tvrtko
>
>> + else
>> + drm_notice(&v3d->drm,
>> + "Transparent Hugepage support is recommended for
>> optimal performance on this platform!\n");
>> +}
>> +
>> int
>> v3d_gem_init(struct drm_device *dev)
>> {
>> @@ -310,7 +334,7 @@ v3d_gem_init(struct drm_device *dev)
>> v3d_init_hw_state(v3d);
>> v3d_mmu_set_page_table(v3d);
>> - v3d_gemfs_init(v3d);
>> + v3d_huge_mnt_init(v3d);
>> ret = v3d_sched_init(v3d);
>> if (ret) {
>> @@ -330,7 +354,6 @@ v3d_gem_destroy(struct drm_device *dev)
>> enum v3d_queue q;
>> v3d_sched_fini(v3d);
>> - v3d_gemfs_fini(v3d);
>> /* Waiting for jobs to finish would need to be done before
>> * unregistering V3D.
>> diff --git a/drivers/gpu/drm/v3d/v3d_gemfs.c b/drivers/gpu/drm/v3d/
>> v3d_gemfs.c
>> deleted file mode 100644
>> index bf351fc0d488..000000000000
>> --- a/drivers/gpu/drm/v3d/v3d_gemfs.c
>> +++ /dev/null
>> @@ -1,62 +0,0 @@
>> -// SPDX-License-Identifier: GPL-2.0+
>> -/* Copyright (C) 2024 Raspberry Pi */
>> -
>> -#include <linux/fs.h>
>> -#include <linux/mount.h>
>> -#include <linux/fs_context.h>
>> -
>> -#include <drm/drm_print.h>
>> -
>> -#include "v3d_drv.h"
>> -
>> -void v3d_gemfs_init(struct v3d_dev *v3d)
>> -{
>> - struct file_system_type *type;
>> - struct fs_context *fc;
>> - struct vfsmount *gemfs;
>> - int ret;
>> -
>> - /*
>> - * By creating our own shmemfs mountpoint, we can pass in
>> - * mount flags that better match our usecase. However, we
>> - * only do so on platforms which benefit from it.
>> - */
>> - if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
>> - goto err;
>> -
>> - /* The user doesn't want to enable Super Pages */
>> - if (!super_pages)
>> - goto err;
>> -
>> - type = get_fs_type("tmpfs");
>> - if (!type)
>> - goto err;
>> -
>> - fc = fs_context_for_mount(type, SB_KERNMOUNT);
>> - if (IS_ERR(fc))
>> - goto err;
>> - ret = vfs_parse_fs_string(fc, "source", "tmpfs");
>> - if (!ret)
>> - ret = vfs_parse_fs_string(fc, "huge", "within_size");
>> - if (!ret)
>> - gemfs = fc_mount_longterm(fc);
>> - put_fs_context(fc);
>> - if (ret)
>> - goto err;
>> -
>> - v3d->gemfs = gemfs;
>> - drm_info(&v3d->drm, "Using Transparent Hugepages\n");
>> -
>> - return;
>> -
>> -err:
>> - v3d->gemfs = NULL;
>> - drm_notice(&v3d->drm,
>> - "Transparent Hugepage support is recommended for optimal
>> performance on this platform!\n");
>> -}
>> -
>> -void v3d_gemfs_fini(struct v3d_dev *v3d)
>> -{
>> - if (v3d->gemfs)
>> - kern_unmount(v3d->gemfs);
>> -}
>
next prev parent reply other threads:[~2025-11-28 18:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 17:02 [PATCH v9 00/11] drm: Reduce page tables overhead with THP Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 01/11] drm/shmem-helper: Simplify page offset calculation in fault handler Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 02/11] drm/shmem-helper: Map huge pages " Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 03/11] drm/gem: Introduce drm_gem_get_unmapped_area() fop Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 04/11] drm/gem: Add huge tmpfs mountpoint helpers Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 05/11] drm/i915: Use " Loïc Molinari
2025-11-20 9:31 ` Tvrtko Ursulin
2025-11-28 18:41 ` Loïc Molinari
2025-12-02 11:01 ` Tvrtko Ursulin
2025-12-05 8:37 ` Loïc Molinari
2025-11-14 17:02 ` [PATCH v9 06/11] drm/v3d: " Loïc Molinari
2025-11-14 17:11 ` Boris Brezillon
2025-11-14 17:21 ` Loïc Molinari
2025-11-20 9:39 ` Tvrtko Ursulin
2025-11-28 18:19 ` Loïc Molinari [this message]
2025-11-14 17:02 ` [PATCH v9 07/11] drm/gem: Get rid of *_with_mnt helpers Loïc Molinari
2025-11-14 17:15 ` Boris Brezillon
2025-11-14 17:02 ` [PATCH v9 08/11] drm/panthor: Introduce huge tmpfs mountpoint option Loïc Molinari
2025-11-14 17:03 ` [PATCH v9 09/11] drm/panthor: Improve IOMMU map/unmap debugging logs Loïc Molinari
2025-11-26 10:10 ` Boris Brezillon
2025-11-14 17:03 ` [PATCH v9 10/11] drm/panfrost: Introduce huge tmpfs mountpoint option Loïc Molinari
2025-11-14 17:03 ` [PATCH v9 11/11] Documentation/gpu/drm-mm: Add THP paragraph to GEM mapping section Loïc Molinari
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=411f7b0f-858c-4486-8819-c01b29cc123a@collabora.com \
--to=loic.molinari@collabora.com \
--cc=airlied@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=andi.shyti@linux.intel.com \
--cc=bagasdotme@gmail.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=boris.brezillon@collabora.com \
--cc=brauner@kernel.org \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=healych@amazon.com \
--cc=hughd@google.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel@collabora.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mcanal@igalia.com \
--cc=mikolaj.wasiak@intel.com \
--cc=mripard@kernel.org \
--cc=mwen@igalia.com \
--cc=nitin.r.gote@intel.com \
--cc=robh@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=viro@zeniv.linux.org.uk \
--cc=willy@infradead.org \
/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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox