Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965417AbcJYAWw (ORCPT ); Mon, 24 Oct 2016 20:22:52 -0400 Received: from mga14.intel.com ([192.55.52.115]:43565 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758189AbcJYAOW (ORCPT ); Mon, 24 Oct 2016 20:14:22 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,543,1473145200"; d="scan'208";a="1058554061" From: "Kirill A. Shutemov" To: "Theodore Ts'o" , Andreas Dilger , Jan Kara , Andrew Morton Cc: Alexander Viro , Hugh Dickins , Andrea Arcangeli , Dave Hansen , Vlastimil Babka , Matthew Wilcox , Ross Zwisler , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCHv4 23/43] thp: make thp_get_unmapped_area() respect S_HUGE_MODE Date: Tue, 25 Oct 2016 03:13:22 +0300 Message-Id: <20161025001342.76126-24-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161025001342.76126-1-kirill.shutemov@linux.intel.com> References: <20161025001342.76126-1-kirill.shutemov@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 939 Lines: 28 We want mmap(NULL) to return PMD-aligned address if the inode can have huge pages in page cache. Signed-off-by: Kirill A. Shutemov --- mm/huge_memory.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 40fe91ac383c..2c1524a8d5d4 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -518,10 +518,12 @@ unsigned long thp_get_unmapped_area(struct file *filp, unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags) { loff_t off = (loff_t)pgoff << PAGE_SHIFT; + struct inode *inode = filp->f_mapping->host; if (addr) goto out; - if (!IS_DAX(filp->f_mapping->host) || !IS_ENABLED(CONFIG_FS_DAX_PMD)) + if ((inode->i_flags & S_HUGE_MODE) == S_HUGE_NEVER && + (!IS_DAX(inode) || !IS_ENABLED(CONFIG_FS_DAX_PMD))) goto out; addr = __thp_get_unmapped_area(filp, len, off, flags, PMD_SIZE); -- 2.9.3