Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * SPDX-License-Identifier: MIT
0003  *
0004  * Copyright © 2017 Intel Corporation
0005  */
0006 
0007 #include <linux/fs.h>
0008 #include <linux/mount.h>
0009 
0010 #include "i915_drv.h"
0011 #include "i915_gemfs.h"
0012 #include "i915_utils.h"
0013 
0014 void i915_gemfs_init(struct drm_i915_private *i915)
0015 {
0016     char huge_opt[] = "huge=within_size"; /* r/w */
0017     struct file_system_type *type;
0018     struct vfsmount *gemfs;
0019 
0020     /*
0021      * By creating our own shmemfs mountpoint, we can pass in
0022      * mount flags that better match our usecase.
0023      *
0024      * One example, although it is probably better with a per-file
0025      * control, is selecting huge page allocations ("huge=within_size").
0026      * However, we only do so on platforms which benefit from it, or to
0027      * offset the overhead of iommu lookups, where with latter it is a net
0028      * win even on platforms which would otherwise see some performance
0029      * regressions such a slow reads issue on Broadwell and Skylake.
0030      */
0031 
0032     if (GRAPHICS_VER(i915) < 11 && !i915_vtd_active(i915))
0033         return;
0034 
0035     if (!IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE))
0036         goto err;
0037 
0038     type = get_fs_type("tmpfs");
0039     if (!type)
0040         goto err;
0041 
0042     gemfs = vfs_kern_mount(type, SB_KERNMOUNT, type->name, huge_opt);
0043     if (IS_ERR(gemfs))
0044         goto err;
0045 
0046     i915->mm.gemfs = gemfs;
0047     drm_info(&i915->drm, "Using Transparent Hugepages\n");
0048     return;
0049 
0050 err:
0051     drm_notice(&i915->drm,
0052            "Transparent Hugepage support is recommended for optimal performance%s\n",
0053            GRAPHICS_VER(i915) >= 11 ? " on this platform!" :
0054                           " when IOMMU is enabled!");
0055 }
0056 
0057 void i915_gemfs_fini(struct drm_i915_private *i915)
0058 {
0059     kern_unmount(i915->mm.gemfs);
0060 }