From patchwork Sun Mar 24 23:45:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13600984 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 ED676C54E58 for ; Sun, 24 Mar 2024 23:46:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7E93D6B0087; Sun, 24 Mar 2024 19:46:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 771F26B0088; Sun, 24 Mar 2024 19:46:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6129F6B0089; Sun, 24 Mar 2024 19:46:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 4D6676B0087 for ; Sun, 24 Mar 2024 19:46:09 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 23D4280183 for ; Sun, 24 Mar 2024 23:46:09 +0000 (UTC) X-FDA: 81933568458.06.9951242 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf22.hostedemail.com (Postfix) with ESMTP id A2B4BC000A for ; Sun, 24 Mar 2024 23:46:07 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Zs83sjYR; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+9b69c840030af2843ecd+7518+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+9b69c840030af2843ecd+7518+infradead.org+hch@bombadil.srs.infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711323967; 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=QR9PmT9kuEPLqJlaQ7HoUyIFQl+oTbi7KFvMo1nZb5I=; b=EuV7dXstikoNWmVYr3YWLmpxLxv6f/2DkGypHRarvWNsFHblPxSqYCDYI/q8ersOFm7nLM 1xBxZoMGzAuG751HyY6twm1UQ/cgQSnQPeyRyA7bSWEjO06PXcYa3G4hOrJ7wO1wjeVIvq 279Y/TbbG0fDd5Df4B99mUlbOAXbi1c= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=Zs83sjYR; dmarc=none; spf=none (imf22.hostedemail.com: domain of BATV+9b69c840030af2843ecd+7518+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+9b69c840030af2843ecd+7518+infradead.org+hch@bombadil.srs.infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711323967; a=rsa-sha256; cv=none; b=64mobmSsFVoXqAQxaVDGOF0NOKcn/NPk0NQPMw8wdKZ4lXuMjtfUag8pHCfVFWjvdsSMQi Z3HIr1NgO5Zl6f/I/UHElBL9iyVl/Ki2R7/9OfGncyGYV6qZoqZhWM/EJSiskEa0zTiBWo tVvJaIAizVgVUB2mK7RWyTANP7wdjJM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=QR9PmT9kuEPLqJlaQ7HoUyIFQl+oTbi7KFvMo1nZb5I=; b=Zs83sjYRCSzsRs0rqWWvIZyqvC 3cfZJiBgQclExbKdvY0+fg95kokQpyTjkch7QxseKHpCjFxkDFSTUhR1cvUva5t4vz3B3ROGCFChI 9hXCd0YFpu4KSDAP5X5kEj8xdwxnxrkhfxg6SoMOEP50b4+/sGgi2/pUIdoXvwXtBUl7LRbJquTcM etu8XL/Pa9y4QHIa0Qh6BAyTrf83lnrRYRJ9BsZ3cDjI9TOu9YDdIXAMOgLXFgKiz3XLD3NvtGiFP JTf1ZN3MJ8SdCK9AC/1WmKGAzHLZcOPdvosqqE2zolMI8nG1rJBlTyU9fd0yx0jLBgtAgg6/1fs20 JW2YFUMg==; Received: from [210.13.83.2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1roXXG-0000000DwnQ-22qb; Sun, 24 Mar 2024 23:45:55 +0000 From: Christoph Hellwig To: Andrew Morton , Dave Hansen , Andy Lutomirski , Peter Zijlstra , Fei Li Cc: x86@kernel.org, linux-mm@kvack.org Subject: [PATCH 2/3] mm: remove follow_pfn Date: Mon, 25 Mar 2024 07:45:41 +0800 Message-Id: <20240324234542.2038726-3-hch@lst.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240324234542.2038726-1-hch@lst.de> References: <20240324234542.2038726-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspamd-Queue-Id: A2B4BC000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: eukg7rziijyptyb7cqttykp9piu7mmq4 X-HE-Tag: 1711323967-406613 X-HE-Meta: U2FsdGVkX19cKDn9Q3JeRg1lcNdpe5yKSm18655vTfdZCbE0GbIQ4SPIhk7UhcmPpZ9gLbAhsUJ3P+UUilLV4gkBoyNB/5i+Fqltsg6hutf7U4TO7RjhfkKOjB7rsS+5D0z8ssjCsQ5RsYjWH170hasmYa6lserKdD6CzZ73D4Ursg7oKsjFu7W1h6R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.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Remove follow_pfn now that the last user is gone. Signed-off-by: Christoph Hellwig Reviewed-by: David Hildenbrand --- include/linux/mm.h | 2 -- mm/memory.c | 36 ++---------------------------------- mm/nommu.c | 21 --------------------- 3 files changed, 2 insertions(+), 57 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7fc..9cd2c69f913601 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2393,8 +2393,6 @@ int copy_page_range(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma); int follow_pte(struct mm_struct *mm, unsigned long address, pte_t **ptepp, spinlock_t **ptlp); -int follow_pfn(struct vm_area_struct *vma, unsigned long address, - unsigned long *pfn); int follow_phys(struct vm_area_struct *vma, unsigned long address, unsigned int flags, unsigned long *prot, resource_size_t *phys); int generic_access_phys(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index f2bc6dd15eb830..d7f09d5aae6e53 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -5880,8 +5880,8 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) * Only IO mappings and raw PFN mappings are allowed. The mmap semaphore * should be taken for read. * - * KVM uses this function. While it is arguably less bad than ``follow_pfn``, - * it is not a good general-purpose API. + * KVM uses this function. While it is arguably less bad than the historic + * ``follow_pfn``, it is not a good general-purpose API. * * Return: zero on success, -ve otherwise. */ @@ -5923,38 +5923,6 @@ int follow_pte(struct mm_struct *mm, unsigned long address, } EXPORT_SYMBOL_GPL(follow_pte); -/** - * follow_pfn - look up PFN at a user virtual address - * @vma: memory mapping - * @address: user virtual address - * @pfn: location to store found PFN - * - * Only IO mappings and raw PFN mappings are allowed. - * - * This function does not allow the caller to read the permissions - * of the PTE. Do not use it. - * - * Return: zero and the pfn at @pfn on success, -ve otherwise. - */ -int follow_pfn(struct vm_area_struct *vma, unsigned long address, - unsigned long *pfn) -{ - int ret = -EINVAL; - spinlock_t *ptl; - pte_t *ptep; - - if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) - return ret; - - ret = follow_pte(vma->vm_mm, address, &ptep, &ptl); - if (ret) - return ret; - *pfn = pte_pfn(ptep_get(ptep)); - pte_unmap_unlock(ptep, ptl); - return 0; -} -EXPORT_SYMBOL(follow_pfn); - #ifdef CONFIG_HAVE_IOREMAP_PROT int follow_phys(struct vm_area_struct *vma, unsigned long address, unsigned int flags, diff --git a/mm/nommu.c b/mm/nommu.c index 5ec8f44e7ce976..38d3ecc30c3ba9 100644 --- a/mm/nommu.c +++ b/mm/nommu.c @@ -110,27 +110,6 @@ unsigned int kobjsize(const void *objp) return page_size(page); } -/** - * follow_pfn - look up PFN at a user virtual address - * @vma: memory mapping - * @address: user virtual address - * @pfn: location to store found PFN - * - * Only IO mappings and raw PFN mappings are allowed. - * - * Returns zero and the pfn at @pfn on success, -ve otherwise. - */ -int follow_pfn(struct vm_area_struct *vma, unsigned long address, - unsigned long *pfn) -{ - if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) - return -EINVAL; - - *pfn = address >> PAGE_SHIFT; - return 0; -} -EXPORT_SYMBOL(follow_pfn); - void vfree(const void *addr) { kfree(addr);