From patchwork Mon Dec 7 11:31:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yulei zhang X-Patchwork-Id: 11955469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A59CC4361B for ; Mon, 7 Dec 2020 11:35:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id CDF3823340 for ; Mon, 7 Dec 2020 11:35:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CDF3823340 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 64F528D001B; Mon, 7 Dec 2020 06:35:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6246F8D0001; Mon, 7 Dec 2020 06:35:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4EDF68D001B; Mon, 7 Dec 2020 06:35:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0033.hostedemail.com [216.40.44.33]) by kanga.kvack.org (Postfix) with ESMTP id 397308D0001 for ; Mon, 7 Dec 2020 06:35:17 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E542C1EE6 for ; Mon, 7 Dec 2020 11:35:16 +0000 (UTC) X-FDA: 77566280232.25.plant52_1f0a26d273de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id B47051804E3A0 for ; Mon, 7 Dec 2020 11:35:16 +0000 (UTC) X-HE-Tag: plant52_1f0a26d273de X-Filterd-Recvd-Size: 5409 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) by imf33.hostedemail.com (Postfix) with ESMTP for ; Mon, 7 Dec 2020 11:35:16 +0000 (UTC) Received: by mail-pg1-f175.google.com with SMTP id e2so316825pgi.5 for ; Mon, 07 Dec 2020 03:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WOqN3wAFWNmwPLLbitVjeNVP3/1EeNDqwEgp1U7by0Y=; b=t2mhCRx4ddW/Vy1XTuXt7xLNO/CzgHXZeydB8wf2nGDpcuoOfUMGpcemrPer6RwsAu uNrNzd2nFAftQMHWukm68XBY2ZReEiQDmMuknuogHStEJ92RpzjB90S9K9a1cbyDhi2W 9Vm6qF/G07WKj7L5wgUVDnQOr5/Zh79lLesUmR9Lh/aRQyBdGzd14FIUZji0fOJd8pl+ /jy3wxMeIMmrTvfNtbWdW+RdAKQyWUr9HmQ31ldStU+rb3XP8uT16WXN0+pGuRlr4ZTK AOGRKulren3uPBcL5hwFYJaFeUE2vqsl9ziKH6yRfEJ//oEfAk2A5bJm4l2xsQwEEOOy Hptg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WOqN3wAFWNmwPLLbitVjeNVP3/1EeNDqwEgp1U7by0Y=; b=WPGp/QZipQv5FFXZxt2uUfrC06JJcLtCZq+4nlf7joLmtNobZ/7RbVCnDphfZ/3TmF RVNsCDDvk+QJ1SHHCHQRIPT1NO/FLW0qUZaqggPWB4Q9QR4N6YeZe03Uoo9pQCmF6+41 jhp/7QB1888THlCevFY7piwkiMOZLn5qgnPSZCiIMnLSX+vIuh21ub22CV46aNZNyj5R vA96rbMlJPSqSUUYG2crkJzBiS04gEk8kDqDqNB+DEQ6fqi4VpdrCKmlYVsdwHf1/d1F moLtvjY37KoTdIzjHNAqwyxBSUMuCu9XHEU+19g1fgC2syrC2ZPpaBTdgai0gjSjP4Zi MCxg== X-Gm-Message-State: AOAM531AmSDe4iQFpBnnRtwBA7I/TTXclS5t9KAvYignibt5KHGGQKga DVGK/bsqdbalgguKCphnIgdNRlC4Vx4= X-Google-Smtp-Source: ABdhPJwbvfVevLMEXxhQw8TM4SqqQZ/7ZuW0O/nKHs8QddAXnvoNRyEBcv9DCTj5vDpAlxEcd07BrA== X-Received: by 2002:a17:902:860a:b029:da:e83a:7f1f with SMTP id f10-20020a170902860ab02900dae83a7f1fmr7784842plo.60.1607340915254; Mon, 07 Dec 2020 03:35:15 -0800 (PST) Received: from localhost.localdomain ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id d4sm14219822pfo.127.2020.12.07.03.35.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Dec 2020 03:35:14 -0800 (PST) From: yulei.kernel@gmail.com X-Google-Original-From: yuleixzhang@tencent.com To: linux-mm@kvack.org, akpm@linux-foundation.org, linux-fsdevel@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, naoya.horiguchi@nec.com, viro@zeniv.linux.org.uk, pbonzini@redhat.com Cc: joao.m.martins@oracle.com, rdunlap@infradead.org, sean.j.christopherson@intel.com, xiaoguangrong.eric@gmail.com, kernellwp@gmail.com, lihaiwei.kernel@gmail.com, Yulei Zhang , Chen Zhuo Subject: [RFC V2 28/37] mm, dmemfs: support huge_fault() for dmemfs Date: Mon, 7 Dec 2020 19:31:21 +0800 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: MIME-Version: 1.0 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: From: Yulei Zhang Introduce __dmemfs_huge_fault() to handle 1G huge pud for dmemfs. Signed-off-by: Chen Zhuo Signed-off-by: Yulei Zhang --- fs/dmemfs/inode.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/fs/dmemfs/inode.c b/fs/dmemfs/inode.c index 17a518c..f698b9d 100644 --- a/fs/dmemfs/inode.c +++ b/fs/dmemfs/inode.c @@ -519,6 +519,43 @@ static vm_fault_t __dmemfs_pmd_fault(struct vm_fault *vmf) return ret; } +#ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD +static vm_fault_t __dmemfs_huge_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; + unsigned long pud_addr = vmf->address & PUD_MASK; + struct inode *inode = file_inode(vma->vm_file); + void *entry; + phys_addr_t phys; + pfn_t pfn; + int ret; + + if (dmem_page_size(inode) < PUD_SIZE) + return VM_FAULT_FALLBACK; + + WARN_ON(pud_addr < vma->vm_start || + vma->vm_end < pud_addr + PUD_SIZE); + + entry = radix_get_create_entry(vma, pud_addr, inode, + linear_page_index(vma, pud_addr)); + if (IS_ERR(entry)) + return (PTR_ERR(entry) == -ENOMEM) ? + VM_FAULT_OOM : VM_FAULT_SIGBUS; + + phys = dmem_entry_to_addr(inode, entry); + pfn = phys_to_pfn_t(phys, PFN_DMEM); + ret = vmf_insert_pfn_pud(vmf, pfn, !!(vma->vm_flags & VM_WRITE)); + + radix_put_entry(); + return ret; +} +#else +static vm_fault_t __dmemfs_huge_fault(struct vm_fault *vmf) +{ + return VM_FAULT_FALLBACK; +} +#endif /* !CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ + static vm_fault_t dmemfs_huge_fault(struct vm_fault *vmf, enum page_entry_size pe_size) { int ret; @@ -530,6 +567,9 @@ static vm_fault_t dmemfs_huge_fault(struct vm_fault *vmf, enum page_entry_size p case PE_SIZE_PMD: ret = __dmemfs_pmd_fault(vmf); break; + case PE_SIZE_PUD: + ret = __dmemfs_huge_fault(vmf); + break; default: ret = VM_FAULT_SIGBUS; }