[PATCH 2/3] drm/i915: enable THP for gemfs
Matthew Auld
matthew.auld at intel.com
Thu May 25 14:23:27 UTC 2017
Signed-off-by: Matthew Auld <matthew.auld at intel.com>
---
drivers/gpu/drm/i915/i915_gemfs.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_gemfs.c b/drivers/gpu/drm/i915/i915_gemfs.c
index 2620ffeaebe2..f1d6d5d14f91 100644
--- a/drivers/gpu/drm/i915/i915_gemfs.c
+++ b/drivers/gpu/drm/i915/i915_gemfs.c
@@ -29,6 +29,7 @@
#include <linux/ramfs.h>
#include <linux/pagemap.h>
#include <linux/file.h>
+#include <linux/shmem_fs.h>
#include "i915_drv.h"
@@ -36,10 +37,19 @@ static const struct dentry_operations anon_ops = {
.d_dname = simple_dname
};
+static inline struct shmem_sb_info *SHMEM_SB(struct super_block *sb)
+{
+ return sb->s_fs_info;
+}
+
int i915_gemfs_create(struct drm_i915_private *i915)
{
struct file_system_type *type;
struct vfsmount *gemfs_mnt;
+ struct super_block *sb;
+ int flags = 0;
+ int ret;
+ char options[] = "huge=within_size";
type = get_fs_type("tmpfs");
if (!type) {
@@ -51,6 +61,25 @@ int i915_gemfs_create(struct drm_i915_private *i915)
return PTR_ERR(gemfs_mnt);
}
+ sb = gemfs_mnt->mnt_sb;
+
+#if defined(CONFIG_TRANSPARENT_HUGE_PAGECACHE)
+ /* Idealy we would just pass the mount options when mounting, but for
+ * some reason shmem chooses not to parse the options for MS_KERNMOUNT,
+ * probably because shm_mnt is the only tmpfs kernel mount other than
+ * this, where the mount options aren't used. To workaround this we do
+ * a remount, which is fairly inexpensive, where we know the options are
+ * never igonored.
+ */
+ ret = sb->s_op->remount_fs(sb, &flags, options);
+ if (ret) {
+ kern_unmount(gemfs_mnt);
+ return PTR_ERR(gemfs_mnt);
+ }
+
+ WARN_ON(SHMEM_SB(sb)->huge == 0);
+#endif
+
i915->gemfs_mnt = gemfs_mnt;
return 0;
--
2.9.4
More information about the Intel-gfx-trybot
mailing list