From patchwork Thu Feb 28 08:35:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10832675 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 391AB1515 for ; Thu, 28 Feb 2019 08:36:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A8052E067 for ; Thu, 28 Feb 2019 08:36:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 19A8E2DBFB; Thu, 28 Feb 2019 08:36:07 +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 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 8A87A2DBFB for ; Thu, 28 Feb 2019 08:36:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8011B8E0008; Thu, 28 Feb 2019 03:36:05 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7B09D8E0006; Thu, 28 Feb 2019 03:36:05 -0500 (EST) 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 6C78A8E0008; Thu, 28 Feb 2019 03:36:05 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 3E6E48E0006 for ; Thu, 28 Feb 2019 03:36:05 -0500 (EST) Received: by mail-yw1-f72.google.com with SMTP id l11so4374533ywl.18 for ; Thu, 28 Feb 2019 00:36:05 -0800 (PST) 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:mime-version:content-transfer-encoding:message-id; bh=4Cwey845aG5lAHZMAxbXPvYPOgxP0ppIzao/eD7OuCc=; b=LBYMBZCTaCAVZPBpMG62Ska2CtWF70yDQ7xaGTtRB9qYXFxg2BOkqx3fL0z3YoNyiF lsyNo+Gc1t2QZrb+9FcTwQKvG9b9kzseGb1LIXv9vS0zZQF3Bn3N3gDUJuzkDlUvvrG1 s2M95qc5GuR1rYZ+MEsSCGzs/2LixhU0MikGvYN79oVWbtc4m416cZ73VSvGevmmdKQe vJrIXjRnZUKptD3ESdjokssxTJD5uHfhmfOvwNVadzzLyp4rY9+dTf0+oli3TDNTJDIp j8bIwKG8WXWLqF7I7ZV8UiEZb2ePoKXfm2GQDG1jD3lRoDIBw34s9HrN5fktgZWTdM/T cGZQ== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AHQUAubS6ah02zplr1UfUx8PNPXt0ytutEunppAEau3u/bXKkLvGBw9M Gv2v4DmZHrot2aKn5tgOnmu9034imPDTEVodsIlADcPBSbObrt4AYE4n69yTRqtkuWsuS635O6B cXWolYJuE9gdpZjHH7SwXEbcnwdx7ny6gJqwlYd+apge1xBHXP3KCxeJ+r+rUoGD4gQ== X-Received: by 2002:a5b:40a:: with SMTP id m10mr5628608ybp.338.1551342964865; Thu, 28 Feb 2019 00:36:04 -0800 (PST) X-Google-Smtp-Source: AHgI3Iak1fyhxVJhfHpJz3r34vbteux9+bSrLaQU3NcmjzYOjmhsZkVjlcXapdljfg+M6w/MXLKK X-Received: by 2002:a5b:40a:: with SMTP id m10mr5628571ybp.338.1551342964020; Thu, 28 Feb 2019 00:36:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551342964; cv=none; d=google.com; s=arc-20160816; b=F41picqSxEyF7rgUQ8q4IRHthsqx7oSeEHVOfciLtzHYbJieM/rdGUrmvBCE/gTp47 8/GEEdxT1YwJKkp/ia1OW2gZNIGJb8JSiJfmjW//dlGShjExXm+JbOKK4Nkp1OlMXXJ+ IuulR5cBV2n/O99XF1uPT9dRmFt/7S+mVaT/jbuceQCRxozWUJn1do3N2rap4+aSaDLL xga8y0TrREBrPl08HQ6DwA17blMSjbgAnZaXPY/fp6OHiccUIGHBX0EBWeYPUAWpYH2j 8+DoPAp3TuQGdCGL5dRJ7DlXoUqqoWnmggibRe7tEGhTbtytxwFvb91Lp8R8HS8UjWqT IDZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:date:subject:cc :to:from; bh=4Cwey845aG5lAHZMAxbXPvYPOgxP0ppIzao/eD7OuCc=; b=ur4ctYdU7eDN5PHtd3sE6e8yxZVsujLA/CGNJnA+BayluTD662qS5bifRAcpP1FLx5 TPDuLWKN6RRI81Lt/NG1gx0xBywnYcBO2URlVS2BwsfxB1jTS5TzD96ZbymO4PWyCs+c TqncHoF8owQUx5hZZNbipldYm/A1meQ38d0GorbTOoq0u73hJ+CpDUwTrKb+W/U9gzeU H5Wt4RBHe4ICtDHxDyK43JKsw2VUXk7U99O7Z54+tVH+NHm6jQ9enZCY+Bi7vBIxbi/l ag4kVZaRs0Edas4p5FGx7gj+41qc+4MbctcC0Y7eFZegZXB9mKQDHU5oHHfdbukHeE0t BddQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id a9si4880242ybo.32.2019.02.28.00.36.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 00:36:04 -0800 (PST) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1S8ZjrE029729 for ; Thu, 28 Feb 2019 03:36:03 -0500 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0b-001b2d01.pphosted.com with ESMTP id 2qxbq61kxh-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 28 Feb 2019 03:35:57 -0500 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Feb 2019 08:35:36 -0000 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 28 Feb 2019 08:35:33 -0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x1S8ZWVs60686428 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Feb 2019 08:35:32 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 475717805E; Thu, 28 Feb 2019 08:35:32 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D9267805C; Thu, 28 Feb 2019 08:35:29 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.233]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 28 Feb 2019 08:35:29 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, "Kirill A . Shutemov" , Jan Kara , mpe@ellerman.id.au, Ross Zwisler , "Oliver O'Halloran" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH 1/2] fs/dax: deposit pagetable even when installing zero page Date: Thu, 28 Feb 2019 14:05:21 +0530 X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19022808-0016-0000-0000-0000098A1A3A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010678; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01167493; UDB=6.00609930; IPR=6.00948107; MB=3.00025776; MTD=3.00000008; XFM=3.00000015; UTC=2019-02-28 08:35:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19022808-0017-0000-0000-0000424C085D Message-Id: <20190228083522.8189-1-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902280061 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 Architectures like ppc64 use the deposited page table to store hardware page table slot information. Make sure we deposit a page table when using zero page at the pmd level for hash. Without this we hit Unable to handle kernel paging request for data at address 0x00000000 Faulting instruction address: 0xc000000000082a74 Oops: Kernel access of bad area, sig: 11 [#1] .... NIP [c000000000082a74] __hash_page_thp+0x224/0x5b0 LR [c0000000000829a4] __hash_page_thp+0x154/0x5b0 Call Trace: hash_page_mm+0x43c/0x740 do_hash_page+0x2c/0x3c copy_from_iter_flushcache+0xa4/0x4a0 pmem_copy_from_iter+0x2c/0x50 [nd_pmem] dax_copy_from_iter+0x40/0x70 dax_iomap_actor+0x134/0x360 iomap_apply+0xfc/0x1b0 dax_iomap_rw+0xac/0x130 ext4_file_write_iter+0x254/0x460 [ext4] __vfs_write+0x120/0x1e0 vfs_write+0xd8/0x220 SyS_write+0x6c/0x110 system_call+0x3c/0x130 Signed-off-by: Aneesh Kumar K.V Reviewed-by: Jan Kara --- TODO: * Add fixes tag fs/dax.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/fs/dax.c b/fs/dax.c index 6959837cc465..01bfb2ac34f9 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -33,6 +33,7 @@ #include #include #include +#include #include "internal.h" #define CREATE_TRACE_POINTS @@ -1410,7 +1411,9 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, { struct address_space *mapping = vmf->vma->vm_file->f_mapping; unsigned long pmd_addr = vmf->address & PMD_MASK; + struct vm_area_struct *vma = vmf->vma; struct inode *inode = mapping->host; + pgtable_t pgtable = NULL; struct page *zero_page; spinlock_t *ptl; pmd_t pmd_entry; @@ -1425,12 +1428,22 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, *entry = dax_insert_entry(xas, mapping, vmf, *entry, pfn, DAX_PMD | DAX_ZERO_PAGE, false); + if (arch_needs_pgtable_deposit()) { + pgtable = pte_alloc_one(vma->vm_mm); + if (!pgtable) + return VM_FAULT_OOM; + } + ptl = pmd_lock(vmf->vma->vm_mm, vmf->pmd); if (!pmd_none(*(vmf->pmd))) { spin_unlock(ptl); goto fallback; } + if (pgtable) { + pgtable_trans_huge_deposit(vma->vm_mm, vmf->pmd, pgtable); + mm_inc_nr_ptes(vma->vm_mm); + } pmd_entry = mk_pmd(zero_page, vmf->vma->vm_page_prot); pmd_entry = pmd_mkhuge(pmd_entry); set_pmd_at(vmf->vma->vm_mm, pmd_addr, vmf->pmd, pmd_entry); @@ -1439,6 +1452,8 @@ static vm_fault_t dax_pmd_load_hole(struct xa_state *xas, struct vm_fault *vmf, return VM_FAULT_NOPAGE; fallback: + if (pgtable) + pte_free(vma->vm_mm, pgtable); trace_dax_pmd_load_hole_fallback(inode, vmf, zero_page, *entry); return VM_FAULT_FALLBACK; } From patchwork Thu Feb 28 08:35:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Aneesh Kumar K.V" X-Patchwork-Id: 10832665 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 770C01515 for ; Thu, 28 Feb 2019 08:35:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 691FD2DBFB for ; Thu, 28 Feb 2019 08:35:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D8932E074; Thu, 28 Feb 2019 08:35:47 +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 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 D27932DBFB for ; Thu, 28 Feb 2019 08:35:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BACB28E0003; Thu, 28 Feb 2019 03:35:44 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B5B4A8E0001; Thu, 28 Feb 2019 03:35:44 -0500 (EST) 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 A22188E0003; Thu, 28 Feb 2019 03:35:44 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id 78A8D8E0001 for ; Thu, 28 Feb 2019 03:35:44 -0500 (EST) Received: by mail-yw1-f71.google.com with SMTP id c67so16301132ywe.5 for ; Thu, 28 Feb 2019 00:35:44 -0800 (PST) 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:in-reply-to:references:mime-version :content-transfer-encoding:message-id; bh=jJVa2qV8nKvE2yQie1WFcZW7O3Eubx1M5bJjeVzZStM=; b=ONIIKOcfZBC6q0udqgQFYhGBBjghxAGoPTyb7iZDr2mO/orGIVzIMWd5Zees3PARV2 xd0dtn0wLUJDzTjIwzs99HK0RDemarQdmXpe0K0XS/v9xZWzuEL3TnT6UnuT/PsfYvgo tkoLyyIExszuq9ufUypQCBMNjpa0wh2udmLQK0+/sPjOa/7Tx+iETzp2jyShVFWVMvn6 SxtONb02uA5pwR2PVjdi3XWFFq0rIg4z6640sf5HD6AS7/l1QDQizr0Sf65AKc8Tc9zA aL+tpFBiTHGoJyde1JSmykowhXd+4+zpoNobF6UZhGaoBm3Kh/BJK8L9SCbmIBO5ZOhW Gang== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com X-Gm-Message-State: AHQUAuaGjruhEFNtunmORupIgbvWQC1DCi0MoEFfpsbyFfg7zZn9oPXy 9D6hOXCjvPF2rk32c45jbR9pDhX8LU357fEJqnpbFxdFeeeQwjUNWutsW8L5KXEgeZSRvFwqxZi er0UAvcrp1+sa/9/D91g7gj0DL5KCxDBdzOatef4gUKyUOjJ+NQmAGfhfymOWB+wwQA== X-Received: by 2002:a5b:603:: with SMTP id d3mr5287046ybq.119.1551342944168; Thu, 28 Feb 2019 00:35:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IbzZu/NT6fu5Cw2EVgMIQ0APYeCG+894gru9H/GMfxcp/j58O7ye0zhVKsTuRjqsay41//O X-Received: by 2002:a5b:603:: with SMTP id d3mr5287010ybq.119.1551342943293; Thu, 28 Feb 2019 00:35:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551342943; cv=none; d=google.com; s=arc-20160816; b=WFsB4XYYh295Rfx47vzWEq0Ls6Msg1T6zshbCKyWSxA4dEO0KGZoFnovww9L+bSX6Q NOhIIzLCvj6q9w2Kk6Afr8Vgfms9epmhf3UX6/zM2lylP4t60nHYQBuvNrnH2HdpcRwm J2XGYSIkuhkw0/iHM3jGlh7uD68f4qAN3e5OV5yA10/lCS3GiKPwHJ7Eg4wpS9RvAOqR RhjNFUIGsXC8tZB6XOebgX0I1BAFB1bFt12Cv+t+0JhKAy024Sy43sfDAmusdDSH9v3C 00r5Fb2DxEa4xqANIkWH04LwsgXysygMmF4cIf8B6kNzWT8PJJA2IEitM3sMzAcxj2SP zNgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:content-transfer-encoding:mime-version:references :in-reply-to:date:subject:cc:to:from; bh=jJVa2qV8nKvE2yQie1WFcZW7O3Eubx1M5bJjeVzZStM=; b=hPKcrqLuHWzxtraFKfUF4mzj6ycv6HYb7+XU5qk3cIAkCbLHHbGb0DU2NH7WPBRRSs 2V20QHjYMwiA1sLNMgWRD0gwvAfIYVpUnrMDY0iY02EkVfEhcFB1ZmXWjwLHr4eCnAS1 V7HA3yGGu/1JqXfNOVEAtkssUVSO5OLhrdE17eKeKVmKSULensNmyOYcdmOYdMGkumqe bsS1QE+rAIQFV4kDXfVFmfm2Lz009apsslj/qNSSPuvD/Q+RchCdSyg5eUj6EitT5Wjn um9B3RfzcaWcml8NzXdB7M6sgaFhlywGlB4rfJflzjVfzP/x/iYbGGWoVBTGWvozfQsY LwpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com. [148.163.158.5]) by mx.google.com with ESMTPS id o129si10251183ywo.228.2019.02.28.00.35.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Feb 2019 00:35:43 -0800 (PST) Received-SPF: pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) client-ip=148.163.158.5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of aneesh.kumar@linux.ibm.com designates 148.163.158.5 as permitted sender) smtp.mailfrom=aneesh.kumar@linux.ibm.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x1S8Y0vv170833 for ; Thu, 28 Feb 2019 03:35:42 -0500 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2qxaejw585-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 28 Feb 2019 03:35:42 -0500 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 28 Feb 2019 08:35:41 -0000 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 28 Feb 2019 08:35:37 -0000 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x1S8ZaHx23134358 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Feb 2019 08:35:36 GMT Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 890977805C; Thu, 28 Feb 2019 08:35:36 +0000 (GMT) Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CFA3A7805F; Thu, 28 Feb 2019 08:35:33 +0000 (GMT) Received: from skywalker.in.ibm.com (unknown [9.124.31.233]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP; Thu, 28 Feb 2019 08:35:33 +0000 (GMT) From: "Aneesh Kumar K.V" To: akpm@linux-foundation.org, "Kirill A . Shutemov" , Jan Kara , mpe@ellerman.id.au, Ross Zwisler , "Oliver O'Halloran" Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, "Aneesh Kumar K.V" Subject: [PATCH 2/2] mm/dax: Don't enable huge dax mapping by default Date: Thu, 28 Feb 2019 14:05:22 +0530 X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190228083522.8189-1-aneesh.kumar@linux.ibm.com> References: <20190228083522.8189-1-aneesh.kumar@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19022808-0004-0000-0000-000014E81B12 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00010678; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000281; SDB=6.01167493; UDB=6.00609930; IPR=6.00948106; MB=3.00025776; MTD=3.00000008; XFM=3.00000015; UTC=2019-02-28 08:35:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19022808-0005-0000-0000-00008ABEE271 Message-Id: <20190228083522.8189-2-aneesh.kumar@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-02-28_04:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1902280061 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 Add a flag to indicate the ability to do huge page dax mapping. On architecture like ppc64, the hypervisor can disable huge page support in the guest. In such a case, we should not enable huge page dax mapping. This patch adds a flag which the architecture code will update to indicate huge page dax mapping support. Architectures mostly do transparent_hugepage_flag = 0; if they can't do hugepages. That also takes care of disabling dax hugepage mapping with this change. Without this patch we get the below error with kvm on ppc64. [ 118.849975] lpar: Failed hash pte insert with error -4 NOTE: The patch also use echo never > /sys/kernel/mm/transparent_hugepage/enabled to disable dax huge page mapping. Signed-off-by: Aneesh Kumar K.V --- TODO: * Add Fixes: tag include/linux/huge_mm.h | 4 +++- mm/huge_memory.c | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 381e872bfde0..01ad5258545e 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -53,6 +53,7 @@ vm_fault_t vmf_insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, pud_t *pud, pfn_t pfn, bool write); enum transparent_hugepage_flag { TRANSPARENT_HUGEPAGE_FLAG, + TRANSPARENT_HUGEPAGE_DAX_FLAG, TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG, TRANSPARENT_HUGEPAGE_DEFRAG_DIRECT_FLAG, TRANSPARENT_HUGEPAGE_DEFRAG_KSWAPD_FLAG, @@ -111,7 +112,8 @@ 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)) + if (vma_is_dax(vma) && + (transparent_hugepage_flags & (1 << TRANSPARENT_HUGEPAGE_DAX_FLAG))) return true; if (transparent_hugepage_flags & diff --git a/mm/huge_memory.c b/mm/huge_memory.c index faf357eaf0ce..43d742fe0341 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -53,6 +53,7 @@ unsigned long transparent_hugepage_flags __read_mostly = #ifdef CONFIG_TRANSPARENT_HUGEPAGE_MADVISE (1<