From patchwork Fri Sep 28 22:31:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 10620401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C7C19180E for ; Fri, 28 Sep 2018 22:32:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ABE4B2BBFF for ; Fri, 28 Sep 2018 22:32:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DFC02BD9E; Fri, 28 Sep 2018 22:32:34 +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=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F1FD2BBFF for ; Fri, 28 Sep 2018 22:32:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DA8418E0002; Fri, 28 Sep 2018 18:32:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D584C8E0001; Fri, 28 Sep 2018 18:32:32 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6E258E0002; Fri, 28 Sep 2018 18:32:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 8694E8E0001 for ; Fri, 28 Sep 2018 18:32:32 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id c8-v6so8658024pfn.2 for ; Fri, 28 Sep 2018 15:32:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=fKl4H/BsRqhxBE5dEONuYCKCQm2tQxbPv3kw+Wd0+jM=; b=PBN4oVViCFmfM5/250RKA6Y39Uy+SS9Zp1/zvWWpzPbQouZMuRzF9gXGXKffZGyfeo 5rGKPtfRLjJ7m0AOhQN8WL9zbNvJvSSCRGA3ixZoYUFXLAtam1xxAlUxc6W5Knf/j65G rIt+U1ty5f+hOFeN5jWk79v7gR0afilqMDI/id1MEp2p+IkofvMQiPm9ai4I7VgbVGC5 KYAS8AfGVY//4vYlzBzk+5JgTkaCIJsquuI4HD0/hIpfonMS+hoKAPcEOJb80Ek3qN1W L73cFeRXzFRR2QWW/ROlvCmGli5A3qiXyZLzI3+UU9cZ6JWRTj26Jn/FOU0ahZkDM5bO R34Q== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Gm-Message-State: ABuFfogXY4JjN5ax6h8MepWwKvYUXLzHBR34q1tOfxYp6ikB0On5Acxi qEF/tDAlcOou0d70OYRlaOB0MUIkqkGXCmUPNwLw89/AaznKj/MUpYU4iwmDkKeI5KXBAW+m5Ep BpbSZtNg22xOJ1+6yVuyshw1ma49IbsXeOgDKFnRwHGYb6Qn4G83Y3c4Bemt/Lr6L6w== X-Received: by 2002:a63:5f03:: with SMTP id t3-v6mr595343pgb.68.1538173952231; Fri, 28 Sep 2018 15:32:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV60oQ/M2uAPQYRqqSuuzi2q+4yGFvoON/+0yQKOsc1T5fZo/Y/Nw/GslhiVQHeNi01oiZ2Cj X-Received: by 2002:a63:5f03:: with SMTP id t3-v6mr595296pgb.68.1538173951076; Fri, 28 Sep 2018 15:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538173951; cv=none; d=google.com; s=arc-20160816; b=S6Y3yWbCHJqo8aB15sE4oGA1mWk8bE21d7jkWXmLLsZx+BA8dqdG5L+MnAIWv4lWW2 IOmMVw2vnhJDL8xsIWFgHA2h9N0lt3XJcxzAie2b+s0hQYvhfdecSTdSSETcDC8/arOm hP3sDQZ9K2WH3myq9LP9lW8E/I39izSTLZCRlLFY46+8N8ruffuUnEtbaCEQqJhsNiSJ wwJ4SqimKFswfIgy1ZAYhnYKVMioOPa64wacU9499SKWeEmy0Dipzv3ZpYuC7dyvI8Fp Un2raQcr6aNQvll8hFCHC5KeLoRt3xCv/6waXKXPZvfsXxTsYftLJ4IdwE9uUF5kt67+ q6Sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from; bh=fKl4H/BsRqhxBE5dEONuYCKCQm2tQxbPv3kw+Wd0+jM=; b=UQyrYc8G/yto5avTmuigCobFZ0N5A9VyCi5CBrp0pS9e9/uNo9fWmXWd6h8vkkqw4w oy0RJYcD+tJz3O0pc2nFUP9mmid1PJQvEIGPTE0WBgo+yvSQAKfN+PT5ZG8KvJCde0qi UpuiPfCvXqhm5BhSKoGsHPgw6ewkq2AE0LvLbUBFIGKfII3BLoqVQvzyS6cIvgBCo4/h c8zFIoprY21M6A//nW1aEqiYv8d3uIw9EX7GaTRSBVqnBFFm7yUGEfwNlJbSE9niZgXb 2tFexFbh9tmKUbwxc231XE8Elxmzxo/a/zq5+xUdKqW7IY4H29N88P3D6ftAWljwdziF Qt0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out4437.biz.mail.alibaba.com (out4437.biz.mail.alibaba.com. [47.88.44.37]) by mx.google.com with ESMTPS id v13-v6si6053008plo.182.2018.09.28.15.32.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Sep 2018 15:32:29 -0700 (PDT) Received-SPF: pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) client-ip=47.88.44.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of yang.shi@linux.alibaba.com designates 47.88.44.37 as permitted sender) smtp.mailfrom=yang.shi@linux.alibaba.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alibaba.com X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R321e4;CH=green;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=yang.shi@linux.alibaba.com;NM=1;PH=DS;RN=8;SR=0;TI=SMTPD_---0T9evJAE_1538173916; Received: from e19h19392.et15sqa.tbsite.net(mailfrom:yang.shi@linux.alibaba.com fp:SMTPD_---0T9evJAE_1538173916) by smtp.aliyun-inc.com(127.0.0.1); Sat, 29 Sep 2018 06:32:02 +0800 From: Yang Shi To: dan.j.williams@intel.com, jack@suse.cz, ross.zwisler@linux.intel.com, kirill.shutemov@linux.intel.com, akpm@linux-foundation.org Cc: yang.shi@linux.alibaba.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] mm: enforce THP for VM_NOHUGEPAGE dax mappings Date: Sat, 29 Sep 2018 06:31:56 +0800 Message-Id: <1538173916-95849-1-git-send-email-yang.shi@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP commit baabda261424517110ea98c6651f632ebf2561e3 ("mm: always enable thp for dax mappings") says madvise hguepage policy makes less sense for dax, and force enabling thp for dax mappings in all cases, even though THP is set to "never". However, transparent_hugepage_enabled() may return false if VM_NOHUGEPAGE is set even though the mapping is dax. So, move is_vma_dax() check to the very beginning to enforce THP for dax mappings in all cases. Cc: Dan Williams Cc: Jan Kara Cc: Ross Zwisler Cc: "Kirill A. Shutemov" Signed-off-by: Yang Shi --- I didn't find anyone mention the check should be before VM_NOHUGEPAGE in the review for Dan's original patch. And, that patch commit log states clearly that THP for dax mapping for all cases even though THP is never. So, I'm supposed it should behave in this way. include/linux/huge_mm.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 99c19b0..b2ad305 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -95,6 +95,9 @@ extern ssize_t single_hugepage_flag_show(struct kobject *kobj, static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) { + if (vma_is_dax(vma)) + return true; + if (vma->vm_flags & VM_NOHUGEPAGE) return false; @@ -107,9 +110,6 @@ static inline bool transparent_hugepage_enabled(struct vm_area_struct *vma) if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_FLAG)) return true; - if (vma_is_dax(vma)) - return true; - if (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG)) return !!(vma->vm_flags & VM_HUGEPAGE);