From patchwork Wed May 31 18:51:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Auld X-Patchwork-Id: 9757957 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 57608602BF for ; Wed, 31 May 2017 18:52:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BF732834A for ; Wed, 31 May 2017 18:52:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40D4B2849E; Wed, 31 May 2017 18:52:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 063162834A for ; Wed, 31 May 2017 18:52:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11C966E2D9; Wed, 31 May 2017 18:52:18 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by gabe.freedesktop.org (Postfix) with ESMTPS id 09F046E2D3 for ; Wed, 31 May 2017 18:52:15 +0000 (UTC) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 31 May 2017 11:52:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.39,275,1493708400"; d="scan'208"; a="1155033144" Received: from sgallagh-mobl1.ger.corp.intel.com (HELO mwahaha.ger.corp.intel.com) ([10.252.0.34]) by fmsmga001.fm.intel.com with ESMTP; 31 May 2017 11:52:13 -0700 From: Matthew Auld To: intel-gfx@lists.freedesktop.org Date: Wed, 31 May 2017 19:51:57 +0100 Message-Id: <20170531185210.29189-3-matthew.auld@intel.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170531185210.29189-1-matthew.auld@intel.com> References: <20170531185210.29189-1-matthew.auld@intel.com> Subject: [Intel-gfx] [PATCH 02/15] drm/i915: enable THP for gemfs X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Enable transparent-huge-pages through gemfs by mounting with huge=within_size. Signed-off-by: Matthew Auld Cc: Joonas Lahtinen Cc: Chris Wilson --- drivers/gpu/drm/i915/i915_gemfs.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gemfs.c b/drivers/gpu/drm/i915/i915_gemfs.c index e1b2af1d9946..7b50ff97623e 100644 --- a/drivers/gpu/drm/i915/i915_gemfs.c +++ b/drivers/gpu/drm/i915/i915_gemfs.c @@ -25,6 +25,7 @@ #include #include #include +#include static const struct dentry_operations anon_ops = { .d_dname = simple_dname @@ -41,6 +42,28 @@ struct vfsmount *i915_gemfs_create(void) gemfs_mnt = kern_mount(type); +#if defined(CONFIG_TRANSPARENT_HUGE_PAGECACHE) + if (!IS_ERR(gemfs_mnt) && has_transparent_hugepage()) { + struct super_block *sb = gemfs_mnt->mnt_sb; + char options[] = "huge=within_size"; + int flags = 0; + int ret; + + /* 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 ERR_PTR(ret); + } + } +#endif + return gemfs_mnt; }