Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2321619pxu; Mon, 7 Dec 2020 03:41:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJLcsJ8p8PmZ69xPGnCGfIewSwC9rONGunKGUusEZ1G41Z7eZA05c+g4WqgfnQ2vFSDQRn X-Received: by 2002:a17:906:5609:: with SMTP id f9mr17753346ejq.535.1607341300617; Mon, 07 Dec 2020 03:41:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607341300; cv=none; d=google.com; s=arc-20160816; b=jepk+yV3Ue2mW0qhoKD6AytHt+d25JzlI4rdYYs2LF+0Zn+I5kyZsxbL/dsX0tt+Lc xaZrI00wUuOnuz4Zyz1aaxHNAKH0P8qma5OWRoP1xGzK46jaeyVfrdvRr+C8HyC2lchm A7sgl47J2V0azfJbALlQsB8pKtwF5EJjafTJIdhcMSh4w/wUufc2IRVE1YsdIJblPCTh RNUjEBs3kTQTW3wetd3lNibM+JN3xlS+K2SsYAxN8nA9nA/Ko29hmIBZbus3xdp0217q xiQZsD7W81H/TJCDvpzgEQFiqte8M4lY2syGXuoCX/ggKvLjqPiuslBYd+W2/zf77eON VoSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=WOqN3wAFWNmwPLLbitVjeNVP3/1EeNDqwEgp1U7by0Y=; b=CH6idv3mRPIwNYcMWv7mocYz5pLNqPk0Y/wC0FUbCdip41+9qpTBDIgFW/Vjc9DM7l 7EnDm7rrqm4pR8zF5mPgvdxAyc3HJ40K/fas2B6ti5YZYseQfJB80uQ8XHWQ6TUmWSil /d7muMthWcHfj2C9I5snWv5zu6RdYW9z2KtDpD9+jPfWAXoH6L0H0WX0yABVcqS0ixz1 rJgqSc7m47OQW5q30aj/uD+0oFR4R7EK6no55sx85vLIrILSxGcxzFufNdUEjWvM4VEW SMx1mSy0cvoB11AkCsa01n3C9qxJgwNsxq14iWBbmRDJ0ktzmglh8tROPq3avHcUL7jh 2fvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t2mhCRx4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k20si6314948ejz.543.2020.12.07.03.41.17; Mon, 07 Dec 2020 03:41:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=t2mhCRx4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727417AbgLGLhJ (ORCPT + 99 others); Mon, 7 Dec 2020 06:37:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727425AbgLGLfc (ORCPT ); Mon, 7 Dec 2020 06:35:32 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C89CC0613D2; Mon, 7 Dec 2020 03:35:15 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id c79so9618736pfc.2; Mon, 07 Dec 2020 03:35:15 -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=EJLd6ULjOYjaQkY3OaixEUj1mOdd9JsPSLmGlkfqLqNyMLwUPr9nUw7XWbEqOWjApV gsId4qNCfbb8plitRD0isCdXEpR9H/+jz6Msx7uFeHrKYO5CAqDYiHPnhjSlve5JY8tg 7+nMVVch5sVpdUWN3a98v/YV6xUQL57UIxakp2ZpU3c+fqFDd2lfrkXSS63ryHeuksq8 cW5NBcH3giMPasNzBaa25wSANyHbIQH5+9ImSKl3QQx+ryy91Km6PvbIR+Z86zilCI5B 7S+sIpw29Bw3Ypvw9zv5JyS4ejJn1xkhoLlsbHw+WvCAGQ8Rl5Yec+tfat1IxMy75iFL jlHQ== X-Gm-Message-State: AOAM533agR3739qsaOo0XZaZZTUqLletb8ko/XHYi95HNioLEAKRIRVE MLNhQsiWbol5FM/7gdC2xtU= 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; } -- 1.8.3.1