[PATCH 4/8] drm/i915: Use huge tmpfs mount point helpers

Loïc Molinari posted 8 patches 2 days, 4 hours ago
[PATCH 4/8] drm/i915: Use huge tmpfs mount point helpers
Posted by Loïc Molinari 2 days, 4 hours ago
Make use of the new drm_gem_shmem_huge_mnt_create() and
drm_gem_shmem_huge_mnt_free() helpers to avoid code duplication.

Signed-off-by: Loïc Molinari <loic.molinari@collabora.com>
---
 drivers/gpu/drm/i915/gem/i915_gemfs.c | 33 +++------------------------
 1 file changed, 3 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gemfs.c b/drivers/gpu/drm/i915/gem/i915_gemfs.c
index a09e2eb47175..70563a6a0b81 100644
--- a/drivers/gpu/drm/i915/gem/i915_gemfs.c
+++ b/drivers/gpu/drm/i915/gem/i915_gemfs.c
@@ -3,25 +3,13 @@
  * Copyright © 2017 Intel Corporation
  */
 
-#include <linux/fs.h>
-#include <linux/mount.h>
-#include <linux/fs_context.h>
-
 #include "i915_drv.h"
 #include "i915_gemfs.h"
 #include "i915_utils.h"
 
-static int add_param(struct fs_context *fc, const char *key, const char *val)
-{
-	return vfs_parse_fs_string(fc, key, val, strlen(val));
-}
-
 void i915_gemfs_init(struct drm_i915_private *i915)
 {
-	struct file_system_type *type;
-	struct fs_context *fc;
 	struct vfsmount *gemfs;
-	int ret;
 
 	/*
 	 * By creating our own shmemfs mountpoint, we can pass in
@@ -38,23 +26,8 @@ void i915_gemfs_init(struct drm_i915_private *i915)
 	if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
 		return;
 
-	if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
-		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 = add_param(fc, "source", "tmpfs");
-	if (!ret)
-		ret = add_param(fc, "huge", "within_size");
-	if (!ret)
-		gemfs = fc_mount_longterm(fc);
-	put_fs_context(fc);
-	if (ret)
+	gemfs = drm_gem_shmem_huge_mnt_create("within_size");
+	if (IS_ERR(gemfs))
 		goto err;
 
 	i915->mm.gemfs = gemfs;
@@ -70,5 +43,5 @@ void i915_gemfs_init(struct drm_i915_private *i915)
 
 void i915_gemfs_fini(struct drm_i915_private *i915)
 {
-	kern_unmount(i915->mm.gemfs);
+	drm_gem_shmem_huge_mnt_free(i915->mm.gemfs);
 }
-- 
2.47.3

Re: [PATCH 4/8] drm/i915: Use huge tmpfs mount point helpers
Posted by kernel test robot 1 day, 13 hours ago
Hi Loïc,

kernel test robot noticed the following build errors:

[auto build test ERROR on drm-misc/drm-misc-next]
[cannot apply to akpm-mm/mm-everything linus/master v6.17 next-20250929]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Lo-c-Molinari/drm-shmem-helper-Add-huge-page-fault-handler/20250930-040600
base:   git://anongit.freedesktop.org/drm/drm-misc drm-misc-next
patch link:    https://lore.kernel.org/r/20250929200316.18417-5-loic.molinari%40collabora.com
patch subject: [PATCH 4/8] drm/i915: Use huge tmpfs mount point helpers
config: i386-randconfig-013-20250930 (https://download.01.org/0day-ci/archive/20250930/202509301837.pQ2TiJkx-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250930/202509301837.pQ2TiJkx-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202509301837.pQ2TiJkx-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/gpu/drm/i915/gem/i915_gemfs.c: In function 'i915_gemfs_init':
>> drivers/gpu/drm/i915/gem/i915_gemfs.c:29:17: error: implicit declaration of function 'drm_gem_shmem_huge_mnt_create' [-Wimplicit-function-declaration]
      29 |         gemfs = drm_gem_shmem_huge_mnt_create("within_size");
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/gpu/drm/i915/gem/i915_gemfs.c:29:15: error: assignment to 'struct vfsmount *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      29 |         gemfs = drm_gem_shmem_huge_mnt_create("within_size");
         |               ^
   drivers/gpu/drm/i915/gem/i915_gemfs.c: In function 'i915_gemfs_fini':
>> drivers/gpu/drm/i915/gem/i915_gemfs.c:46:9: error: implicit declaration of function 'drm_gem_shmem_huge_mnt_free' [-Wimplicit-function-declaration]
      46 |         drm_gem_shmem_huge_mnt_free(i915->mm.gemfs);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/drm_gem_shmem_huge_mnt_create +29 drivers/gpu/drm/i915/gem/i915_gemfs.c

     9	
    10	void i915_gemfs_init(struct drm_i915_private *i915)
    11	{
    12		struct vfsmount *gemfs;
    13	
    14		/*
    15		 * By creating our own shmemfs mountpoint, we can pass in
    16		 * mount flags that better match our usecase.
    17		 *
    18		 * One example, although it is probably better with a per-file
    19		 * control, is selecting huge page allocations ("huge=within_size").
    20		 * However, we only do so on platforms which benefit from it, or to
    21		 * offset the overhead of iommu lookups, where with latter it is a net
    22		 * win even on platforms which would otherwise see some performance
    23		 * regressions such a slow reads issue on Broadwell and Skylake.
    24		 */
    25	
    26		if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
    27			return;
    28	
  > 29		gemfs = drm_gem_shmem_huge_mnt_create("within_size");
    30		if (IS_ERR(gemfs))
    31			goto err;
    32	
    33		i915->mm.gemfs = gemfs;
    34		drm_info(&i915->drm, "Using Transparent Hugepages\n");
    35		return;
    36	
    37	err:
    38		drm_notice(&i915->drm,
    39			   "Transparent Hugepage support is recommended for optimal performance%s\n",
    40			   GRAPHICS_VER(i915) >= 11 ? " on this platform!" :
    41						      " when IOMMU is enabled!");
    42	}
    43	
    44	void i915_gemfs_fini(struct drm_i915_private *i915)
    45	{
  > 46		drm_gem_shmem_huge_mnt_free(i915->mm.gemfs);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki