diff mbox

[04/22] drm/i915/gemfs: enable THP

Message ID 20170925184737.8807-5-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Matthew Auld Sept. 25, 2017, 6:47 p.m. UTC
Enable transparent-huge-pages through gemfs by mounting with
huge=within_size.

v2: prefer kern_mount_data

Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Kirill A. Shutemov <kirill@shutemov.name>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>
Cc: linux-mm@kvack.org
---
 drivers/gpu/drm/i915/i915_gemfs.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Chris Wilson Sept. 25, 2017, 7:11 p.m. UTC | #1
Quoting Matthew Auld (2017-09-25 19:47:19)
> Enable transparent-huge-pages through gemfs by mounting with
> huge=within_size.
> 
> v2: prefer kern_mount_data
> 
> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Dave Hansen <dave.hansen@intel.com>
> Cc: Kirill A. Shutemov <kirill@shutemov.name>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Hugh Dickins <hughd@google.com>
> Cc: linux-mm@kvack.org
> ---
>  drivers/gpu/drm/i915/i915_gemfs.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gemfs.c b/drivers/gpu/drm/i915/i915_gemfs.c
> index 168d0bd98f60..dc35719814f0 100644
> --- a/drivers/gpu/drm/i915/i915_gemfs.c
> +++ b/drivers/gpu/drm/i915/i915_gemfs.c
> @@ -24,6 +24,7 @@
>  
>  #include <linux/fs.h>
>  #include <linux/mount.h>
> +#include <linux/pagemap.h>
>  
>  #include "i915_drv.h"
>  #include "i915_gemfs.h"
> @@ -32,12 +33,17 @@ int i915_gemfs_init(struct drm_i915_private *i915)
>  {
>         struct file_system_type *type;
>         struct vfsmount *gemfs;
> +       char within_size[] = "huge=within_size";
> +       char *options = NULL;
>  
>         type = get_fs_type("tmpfs");
>         if (!type)
>                 return -ENODEV;
>  

/*
 * Enable hugepages that fit into the object's size so that
 * we do not overallocate, as the excess will not be reused and
 * our objects may be extremely long lived.
 */

> -       gemfs = kern_mount(type);
> +       if (has_transparent_hugepage())
> +               options = within_size;
> +
> +       gemfs = kern_mount_data(type, options);

The alternative to the previous two patches would be to export a
function to set the hugepage policy on the shmem_sb_info.

>         if (IS_ERR(gemfs))
>                 return PTR_ERR(gemfs);

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gemfs.c b/drivers/gpu/drm/i915/i915_gemfs.c
index 168d0bd98f60..dc35719814f0 100644
--- a/drivers/gpu/drm/i915/i915_gemfs.c
+++ b/drivers/gpu/drm/i915/i915_gemfs.c
@@ -24,6 +24,7 @@ 
 
 #include <linux/fs.h>
 #include <linux/mount.h>
+#include <linux/pagemap.h>
 
 #include "i915_drv.h"
 #include "i915_gemfs.h"
@@ -32,12 +33,17 @@  int i915_gemfs_init(struct drm_i915_private *i915)
 {
 	struct file_system_type *type;
 	struct vfsmount *gemfs;
+	char within_size[] = "huge=within_size";
+	char *options = NULL;
 
 	type = get_fs_type("tmpfs");
 	if (!type)
 		return -ENODEV;
 
-	gemfs = kern_mount(type);
+	if (has_transparent_hugepage())
+		options = within_size;
+
+	gemfs = kern_mount_data(type, options);
 	if (IS_ERR(gemfs))
 		return PTR_ERR(gemfs);