lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1c48c302-decb-40e2-8ca3-c4e423ccf31b@igalia.com>
Date: Mon, 1 Dec 2025 10:06:18 -0300
From: Maíra Canal <mcanal@...lia.com>
To: Loïc Molinari <loic.molinari@...labora.com>,
 Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
 Maxime Ripard <mripard@...nel.org>, Thomas Zimmermann <tzimmermann@...e.de>,
 David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
 Jani Nikula <jani.nikula@...ux.intel.com>,
 Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
 Rodrigo Vivi <rodrigo.vivi@...el.com>, Tvrtko Ursulin
 <tursulin@...ulin.net>, Boris Brezillon <boris.brezillon@...labora.com>,
 Rob Herring <robh@...nel.org>, Steven Price <steven.price@....com>,
 Liviu Dudau <liviu.dudau@....com>, Melissa Wen <mwen@...lia.com>,
 Hugh Dickins <hughd@...gle.com>, Baolin Wang
 <baolin.wang@...ux.alibaba.com>, Andrew Morton <akpm@...ux-foundation.org>,
 Al Viro <viro@...iv.linux.org.uk>, Mikołaj Wasiak
 <mikolaj.wasiak@...el.com>, Christian Brauner <brauner@...nel.org>,
 Nitin Gote <nitin.r.gote@...el.com>, Andi Shyti
 <andi.shyti@...ux.intel.com>, Jonathan Corbet <corbet@....net>,
 Christopher Healy <healych@...zon.com>, Matthew Wilcox
 <willy@...radead.org>, Bagas Sanjaya <bagasdotme@...il.com>
Cc: linux-kernel@...r.kernel.org, dri-devel@...ts.freedesktop.org,
 intel-gfx@...ts.freedesktop.org, linux-mm@...ck.org,
 linux-doc@...r.kernel.org, kernel@...labora.com
Subject: Re: [PATCH v10 04/10] drm/gem: Add huge tmpfs mountpoint helpers

Hi Loïc,

On 28/11/25 15:52, Loïc Molinari wrote:
> Add the drm_gem_huge_mnt_create() and drm_gem_get_huge_mnt() helpers
> to avoid code duplication in the i915, V3D, Panfrost and Panthor
> drivers. The former creates and mounts a dedicated huge tmpfs
> mountpoint, for the lifetime of a DRM device, used at GEM object
> initialization. The latter retrieves the dedicated huge tmpfs
> mountpoint used by a DRM device.
> 
> The next commits will port drivers to these helpers.
> 
> v3:
> - store huge tmpfs mountpoint in drm_device
> 
> v4:
> - return 0 in builds with CONFIG_TRANSPARENT_HUGEPAGE=n
> - return 0 when huge_mnt already exists
> - use new vfs_parse_fs_string() helper
> 
> v5:
> - remove warning on !dev->huge_mnt and reset to NULL on free
> - inline drm_gem_huge_mnt_create() to remove func from text and avoid
>    calls in builds with CONFIG_TRANSPARENT_HUGEPAGE=n
> - compile out drm_device's huge_mnt field in builds with
>    CONFIG_TRANSPARENT_HUGEPAGE=n
> - add drm_gem_has_huge_mnt() helper
> 
> v6:
> - move huge_mnt doc into ifdef'd section
> - either inline or export drm_gem_huge_mnt_create()
> 
> v7:
> - include <drm/drm_device.h> in drm_gem.h
> 
> v9:
> - replace drm_gem_has_huge_mnt() by drm_gem_get_huge_mnt()
> 
> Signed-off-by: Loïc Molinari <loic.molinari@...labora.com>

Reviewed-by: Maíra Canal <mcanal@...lia.com>

Some suggestions below (feel free to ignore):

> ---
>   drivers/gpu/drm/drm_gem.c | 57 +++++++++++++++++++++++++++++++++++++++
>   include/drm/drm_device.h  | 15 +++++++++++
>   include/drm/drm_gem.h     | 33 +++++++++++++++++++++++
>   3 files changed, 105 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
> index 41d344c270a7..94e5e04865ba 100644
> --- a/drivers/gpu/drm/drm_gem.c
> +++ b/drivers/gpu/drm/drm_gem.c
> @@ -29,6 +29,9 @@
>   #include <linux/export.h>
>   #include <linux/file.h>
>   #include <linux/fs.h>
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +#include <linux/fs_context.h>
> +#endif
>   #include <linux/iosys-map.h>
>   #include <linux/mem_encrypt.h>
>   #include <linux/mm.h>
> @@ -82,6 +85,60 @@
>    * up at a later date, and as our interface with shmfs for memory allocation.
>    */
>   
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +static void drm_gem_huge_mnt_free(struct drm_device *dev, void *data)
> +{
> +	kern_unmount(dev->huge_mnt);
> +}
> +
> +/**
> + * drm_gem_huge_mnt_create - Create, mount and use a huge tmpfs mountpoint
> + * @dev: DRM device a huge tmpfs mountpoint should be used with

Suggestion: "DRM device that will use the huge tmpfs mountpoint"

> + * @value: huge tmpfs mount option value
> + *
> + * This function creates and mounts a dedicated huge tmpfs mountpoint for the
> + * lifetime of the DRM device @dev which is used at GEM object initialization
> + * with drm_gem_object_init().
> + *
> + * The most common option value @value is "within_size" which only allocates

Suggestion: "The most common option for @value is..."

> + * huge pages if the page will be fully within the GEM object size. "always",
> + * "advise" and "never" are supported too but the latter would just create a
> + * mountpoint similar to the default one (`shm_mnt`). See shmemfs and
> + * Transparent Hugepage for more information.
> + *
> + * Returns:
> + * 0 on success or a negative error code on failure.
> + */

[...]

> diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
> index 5af49c5c3778..7dc560ad14fc 100644
> --- a/include/drm/drm_device.h
> +++ b/include/drm/drm_device.h
> @@ -3,6 +3,9 @@
>   
>   #include <linux/list.h>
>   #include <linux/kref.h>
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +#include <linux/mount.h>
> +#endif
>   #include <linux/mutex.h>
>   #include <linux/idr.h>
>   #include <linux/sched.h>
> @@ -168,6 +171,18 @@ struct drm_device {
>   	 */
>   	struct drm_master *master;
>   
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +	/**
> +	 * @huge_mnt:
> +	 *
> +	 * Huge tmpfs mountpoint used at GEM object initialization
> +	 * drm_gem_object_init(). Drivers can call drm_gem_huge_mnt_create() to

Suggestion: "Drivers can call drm_gem_huge_mnt_create() to mount and use
it."

> +	 * create a huge tmfps mountpoint. The default tmpfs mountpoint
> +	 * (`shm_mnt`) is used if NULL.
> +	 */
> +	struct vfsmount *huge_mnt;
> +#endif
> +
>   	/**
>   	 * @driver_features: per-device driver features
>   	 *
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 7c8bd67d087c..4e9ab5d294ac 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -40,6 +40,9 @@
>   #include <linux/list.h>
>   #include <linux/mutex.h>
>   
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +#include <drm/drm_device.h>
> +#endif
>   #include <drm/drm_vma_manager.h>
>   
>   struct iosys_map;
> @@ -492,6 +495,36 @@ struct drm_gem_object {
>   		DRM_GEM_FOPS,\
>   	}
>   
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
> +int drm_gem_huge_mnt_create(struct drm_device *dev, const char *value);
> +#else
> +static inline int drm_gem_huge_mnt_create(struct drm_device *dev,
> +					  const char *value)
> +{
> +	return 0;
> +}
> +#endif
> +
> +/**
> + * drm_gem_get_huge_mnt - Get the huge tmpfs mountpoint used by a DRM device
> + * @dev: DRM device
> +
> + * This function gets the huge tmpfs mountpoint used by DRM device @dev. A huge
> + * tmpfs mountpoint is used after a successful call to drm_gem_huge_mnt_create()

Suggestion: "A huge tmpfs is used instead of `shm_mnt` after a
successful call to drm_gem_huge_mnt_create() when
CONFIG_TRANSPARENT_HUGEPAGE is enabled"

Best Regards,
- Maíra

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ