From patchwork Sun Mar 12 23:40:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Stoakes X-Patchwork-Id: 13171903 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC72AC6FD19 for ; Sun, 12 Mar 2023 23:42:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E0ED6B0074; Sun, 12 Mar 2023 19:42:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 76AC96B0075; Sun, 12 Mar 2023 19:42:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4AB9F8E0001; Sun, 12 Mar 2023 19:42:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3786E6B0074 for ; Sun, 12 Mar 2023 19:42:37 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 0EF521A07DF for ; Sun, 12 Mar 2023 23:42:37 +0000 (UTC) X-FDA: 80561873154.24.63D0179 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) by imf19.hostedemail.com (Postfix) with ESMTP id 37EE71A0003 for ; Sun, 12 Mar 2023 23:42:33 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=maz9e2QT; spf=pass (imf19.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678664554; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=WSSuuGbSViNSiJOOpvJAXNlPkjhkPMmdrutdIOUQWHlptMi0Jcam0dVXVEA9t8IS0WCFtL I5JHZKsD5e7zqiZ4iSHpTpaIY+VW/nV8iBLgGya6EuQr+0QvAm6D0g69eTDlp/bNv4lJIE FHN5GEMlzh+S+UpLxTR1VG69uTbPrD4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=maz9e2QT; spf=pass (imf19.hostedemail.com: domain of lstoakes@gmail.com designates 209.85.128.42 as permitted sender) smtp.mailfrom=lstoakes@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678664554; a=rsa-sha256; cv=none; b=UnvR8IGtCkV7o8qwku2xxOHD0b1Ma5UdW1ayf0L5CeOY+B8r1w/j3L3hlFf6N5Bz43dLmC gIUG0bo+bPmbPv6yNIcLpxGURDBCZvAj5mheF/ihnnFC11kSActqOSJuYzxJZMd4HoskpP wuL8wAawFslPte//cA2C4lTEr6HV4+M= Received: by mail-wm1-f42.google.com with SMTP id k25-20020a7bc419000000b003ed23114fa7so1054600wmi.4 for ; Sun, 12 Mar 2023 16:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678664552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=maz9e2QTegb5aGWaMrUn0W1T4Yb7pAPV4qShHMkAP0jmTAZnGYuceUYaHypxk3ZK3n ZDBqAaSh4+ktG95WP3CVzvvsS2QYlwldP0jD7mTJmW1UGRN168RC1lxMVOZZ1PQh6TOP +y2rQ91YejaLYBVYdHPFlUg3gA+SBPTgCXZkunTCQq/KKrnRLP5bUKBFIC/AQiIgFbRE 9s1UuvtwQdsPaN9SJ22GP58vW9sS051TMmx+qiNlQayml8SjCelQJT8pch0Nw/dG8/SL tYw6OY+zWYtLnjRJ7LUlFPQgbzFk8ileybTIoNKp4/+CPVyIglWvzyNCWtisu9Kn/kcB nHrw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678664552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l5BwzPdb3pP6HQP4bpfNX6Ih3sOxfK6TuzT4vYnYmzI=; b=CDiqCcRTktgILTesbopaeQcMudwjZULjkbYFhmkfkhiKBRKAQk+AK1fNub8rj12qYd l5mOY5aRfXHw28+GSyIawDxNo8NvwNm+cGoxA3XcqiXJlZoAPorYzG6deKX0RK+FL94x hutnHQIQ3xYGhGsugwalr/QGLOZCX8B8sSZjTpEI8rSiyhXcXbzpn3HAbbSlkXzYdyBM 3cabntZLRauKa9KhdQ4vzQmAne59COZNVS+8Wfz4FF/83t14TJkjnlisTvU+sjJAwmnX bNqsbotaoil0oXVuhr7oHN4DcOsAadX2lZt/0r8+h7Q6UnPESMkTF+g3Ze+ePnZGS2H/ z0iQ== X-Gm-Message-State: AO0yUKVaj9jPA2pYSJ749mCTdbnja27LHuuaVhvXU1DqJBKdhzWuddxn quHrmqDv8w/EJImFTXjrT1qprOgFGSk= X-Google-Smtp-Source: AK7set88QQ6jrd1M0hrmNofJDYtEfX1glIjDn7W2t6EdL0uThkNjlqD3H5zcW/MHqEOtS/rhvVi/CQ== X-Received: by 2002:a05:600c:1d29:b0:3eb:3945:d3f4 with SMTP id l41-20020a05600c1d2900b003eb3945d3f4mr10055016wms.2.1678664552343; Sun, 12 Mar 2023 16:42:32 -0700 (PDT) Received: from lucifer.home (host86-146-209-214.range86-146.btcentralplus.com. [86.146.209.214]) by smtp.googlemail.com with ESMTPSA id iz20-20020a05600c555400b003ed201ddef2sm3698376wmb.2.2023.03.12.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Mar 2023 16:42:31 -0700 (PDT) From: Lorenzo Stoakes To: linux-mm@kvack.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Andrew Morton Cc: Thomas Hellstrom , Christian Konig , Matthew Wilcox , Michal Hocko , "Kirill A . Shutemov" , Dan Williams , Jason Gunthorpe , Lorenzo Stoakes Subject: [PATCH 2/3] mm: Remove vmf_insert_pfn_xxx_prot() for huge page-table entries Date: Sun, 12 Mar 2023 23:40:14 +0000 Message-Id: <604c2ad79659d4b8a6e3e1611c6219d5d3233988.1678661628.git.lstoakes@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: ziatbwycmg784zy6iynry5ms14w6c8b4 X-Rspamd-Queue-Id: 37EE71A0003 X-HE-Tag: 1678664553-292380 X-HE-Meta: U2FsdGVkX19maPTUIsSqTWCDSxvqgbFw+6RPfjensyCckUQmKys36ZzW9RwfIwo/7r/kkOaHFP/4I1sVtNG63obI9f5ocaj8FXt36DF8uD+Ih9gdaiXiQSmP80gRP6wc7ZUZT/HS621HGGiw+hADjB0nBJ7atAU27JtuwX7Unvog/CuvA35NqHEI3zEiNcfnMZCFcu6XESTiPPH3a7t65USgU7adqnRemU+mm+XC72DruaEWNSsCfOiVxEGhNx65rbwXW2SN6EqnzX0ksaV4izP88R7d1VLp6WbD7SW7wRhT20u1P4A9P7ZpK2QbQBUHiAtWwomZNFUqzEPtGUQMwYMG8EVaJsgHtk21gQ3IXfvUqdvSsNcywxyVJHz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eOli/WzCuCzy3/uVBTJWDW2/WCfgoiuD1FAyrv2IG703CHf 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: This functionality's sole user, the drm ttm module, removed support for it in commit 0d979509539e ("drm/ttm: remove ttm_bo_vm_insert_huge()") as the whole approach is currently unworkable without a PMD/PUD special bit and updates to GUP. Signed-off-by: Lorenzo Stoakes --- include/linux/huge_mm.h | 39 ++------------------------------------- mm/huge_memory.c | 31 +++++++++++++------------------ 2 files changed, 15 insertions(+), 55 deletions(-) diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index 70bd867eba94..3c52fc9d85dc 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h @@ -39,44 +39,9 @@ bool move_huge_pmd(struct vm_area_struct *vma, unsigned long old_addr, int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, pmd_t *pmd, unsigned long addr, pgprot_t newprot, unsigned long cp_flags); -vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write); -/** - * vmf_insert_pfn_pmd - insert a pmd size pfn - * @vmf: Structure describing the fault - * @pfn: pfn to insert - * @pgprot: page protection to use - * @write: whether it's a write fault - * - * Insert a pmd size pfn. See vmf_insert_pfn() for additional info. - * - * Return: vm_fault_t value. - */ -static inline vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, - bool write) -{ - return vmf_insert_pfn_pmd_prot(vmf, pfn, vmf->vma->vm_page_prot, write); -} -vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write); - -/** - * vmf_insert_pfn_pud - insert a pud size pfn - * @vmf: Structure describing the fault - * @pfn: pfn to insert - * @pgprot: page protection to use - * @write: whether it's a write fault - * - * Insert a pud size pfn. See vmf_insert_pfn() for additional info. - * - * Return: vm_fault_t value. - */ -static inline vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, - bool write) -{ - return vmf_insert_pfn_pud_prot(vmf, pfn, vmf->vma->vm_page_prot, write); -} +vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write); +vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write); enum transparent_hugepage_flag { TRANSPARENT_HUGEPAGE_NEVER_DAX, diff --git a/mm/huge_memory.c b/mm/huge_memory.c index b0ab247939e0..5a0e5e84ab13 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -889,23 +889,20 @@ static void insert_pfn_pmd(struct vm_area_struct *vma, unsigned long addr, } /** - * vmf_insert_pfn_pmd_prot - insert a pmd size pfn + * vmf_insert_pfn_pmd - insert a pmd size pfn * @vmf: Structure describing the fault * @pfn: pfn to insert - * @pgprot: page protection to use * @write: whether it's a write fault * - * Insert a pmd size pfn. See vmf_insert_pfn() for additional info and - * also consult the vmf_insert_mixed_prot() documentation when - * @pgprot != @vmf->vma->vm_page_prot. + * Insert a pmd size pfn. See vmf_insert_pfn() for additional info. * * Return: vm_fault_t value. */ -vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write) +vm_fault_t vmf_insert_pfn_pmd(struct vm_fault *vmf, pfn_t pfn, bool write) { unsigned long addr = vmf->address & PMD_MASK; struct vm_area_struct *vma = vmf->vma; + pgprot_t pgprot = vma->vm_page_prot; pgtable_t pgtable = NULL; /* @@ -933,7 +930,7 @@ vm_fault_t vmf_insert_pfn_pmd_prot(struct vm_fault *vmf, pfn_t pfn, insert_pfn_pmd(vma, addr, vmf->pmd, pfn, pgprot, write, pgtable); return VM_FAULT_NOPAGE; } -EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd_prot); +EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd); #ifdef CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD static pud_t maybe_pud_mkwrite(pud_t pud, struct vm_area_struct *vma) @@ -944,9 +941,10 @@ static pud_t maybe_pud_mkwrite(pud_t pud, struct vm_area_struct *vma) } static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, - pud_t *pud, pfn_t pfn, pgprot_t prot, bool write) + pud_t *pud, pfn_t pfn, bool write) { struct mm_struct *mm = vma->vm_mm; + pgprot_t prot = vma->vm_page_prot; pud_t entry; spinlock_t *ptl; @@ -980,23 +978,20 @@ static void insert_pfn_pud(struct vm_area_struct *vma, unsigned long addr, } /** - * vmf_insert_pfn_pud_prot - insert a pud size pfn + * vmf_insert_pfn_pud - insert a pud size pfn * @vmf: Structure describing the fault * @pfn: pfn to insert - * @pgprot: page protection to use * @write: whether it's a write fault * - * Insert a pud size pfn. See vmf_insert_pfn() for additional info and - * also consult the vmf_insert_mixed_prot() documentation when - * @pgprot != @vmf->vma->vm_page_prot. + * Insert a pud size pfn. See vmf_insert_pfn() for additional info. * * Return: vm_fault_t value. */ -vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, - pgprot_t pgprot, bool write) +vm_fault_t vmf_insert_pfn_pud(struct vm_fault *vmf, pfn_t pfn, bool write) { unsigned long addr = vmf->address & PUD_MASK; struct vm_area_struct *vma = vmf->vma; + pgprot_t pgprot = vma->vm_page_prot; /* * If we had pud_special, we could avoid all these restrictions, @@ -1014,10 +1009,10 @@ vm_fault_t vmf_insert_pfn_pud_prot(struct vm_fault *vmf, pfn_t pfn, track_pfn_insert(vma, &pgprot, pfn); - insert_pfn_pud(vma, addr, vmf->pud, pfn, pgprot, write); + insert_pfn_pud(vma, addr, vmf->pud, pfn, write); return VM_FAULT_NOPAGE; } -EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud_prot); +EXPORT_SYMBOL_GPL(vmf_insert_pfn_pud); #endif /* CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD */ static void touch_pmd(struct vm_area_struct *vma, unsigned long addr,