From patchwork Tue Aug 28 14:57:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578669 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 3A7F8175A for ; Tue, 28 Aug 2018 14:58:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 07F772A4A7 for ; Tue, 28 Aug 2018 14:58:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F09A82A4AD; Tue, 28 Aug 2018 14:58:05 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID 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 61DAD2A4A7 for ; Tue, 28 Aug 2018 14:58:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3679C6B46E6; Tue, 28 Aug 2018 10:57:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2CDAB6B46E8; Tue, 28 Aug 2018 10:57:44 -0400 (EDT) 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 1673F6B46E9; Tue, 28 Aug 2018 10:57:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id B9D4D6B46E6 for ; Tue, 28 Aug 2018 10:57:43 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id w18-v6so766476plp.3 for ; Tue, 28 Aug 2018 07:57:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=Q+UtRyNvNkwYnshT9IkFBgwFupwwt2dJy++I8w/l5mU=; b=kKgyVabhHRbNg41lSZ1UZZPj1o+kx4rj50uodHHcJe01uGxf79cdesVAWV4JzmMQSN PfuAzn3QcEiGBkLx+4a9Er5kSn9ug8oJGchZig5rvCZzklLkt1+zzhfsvL/Z3lRo2Qsh MKxMY60DO0MPL487rX5PTi/ctqkd2Y0KZgSHi0c1n7Zxc7aG2hYLtJyqKLlaxZauPjEy +73Oi2gm5hD9o2IDtNr2Y7z+B75GfmyYQFPk+kq4B2iWKAUlMV35oKqjVCajkL9KSaUn dUepQr3uA+Sj2KP6diiuF2f4x+KMJ0sHZWLlZ8cgl9FUVwKeLsA3uk4BAnHg2TlUNexj 3dnA== X-Gm-Message-State: APzg51D701EpqVBwrkrFLnNny6sTTVEHiGlf/BOzjhLO6wJCVYemia4O ckuWHRF/voyEwB4vk5pYTZhhiT2eewfJfSlc2nqveLCW+itmCLuVmCuSQ3/nl9i1gYhJiU0wqTq hS/aS/cFKQsNgzvAawu1ZxjAPxw5g8XHdauqXeqfpwhBx9FOX+4E3Az1p9FyR+VJRiQ== X-Received: by 2002:a62:cd3:: with SMTP id 80-v6mr2020747pfm.184.1535468263430; Tue, 28 Aug 2018 07:57:43 -0700 (PDT) X-Google-Smtp-Source: ANB0VdanITl5UTa3Sud0kL0+vluOG/qUPqJ9HN4zk6nUTCHsVfiXqPvwpU0EaVTymVoiyjTr6CX5 X-Received: by 2002:a62:cd3:: with SMTP id 80-v6mr2020696pfm.184.1535468262564; Tue, 28 Aug 2018 07:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468262; cv=none; d=google.com; s=arc-20160816; b=nLOdd7hs4N/lT9VgFYJBGwjjrmBXkCabODJ1MUkTqU6oymi/LjEvhA+neovqcFPB9R H3azUcmlPa4wZ9l9k6yuNUHOi/4W3HpyIGlAonU79MHKFBGdP7YBIAd4+yb1dBGY5f6d 0bNnD7CLN5bipb1GZJrygpLjTQ+F656hNlGU89PDKkKJHspjLMfrwIcV02jWT2cZ/LmB aocPR4gXBPAwDhox1zN+64CpYA7AcTjAF7MZkgqSuVGQozFl2xwz/yiVkBHNAh7C+5e9 frJXDPyjYUiVDsFJQgiqGXcHXpyhOTKrxgASK8JfEZLMb8F50ue2OmkLcNsrUXAJ8y5J S72w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=Q+UtRyNvNkwYnshT9IkFBgwFupwwt2dJy++I8w/l5mU=; b=c84I4QgHSM0ECg3PFlAO31W92eCj8OADtu4kTLZO6DngHGGujggLbQz2uEdDOxEABs w0xvey/fMHjAjMvKhi92LZEsKFNZvy0c4QyPvxIlXJf0knnyymY2FY8dwcc/YFZHcFNe J/0tEE74YSpXq96McEYLBGv8c1CKIiCrIRf3+NE0XnKywJzqcGTgsYXiaAAyqYpnwOES ELYiLYqs609kJe0iekCcUmkaC1RABb9LeHYZ3lu9cQtROkL+H7X5kKLzF312rcYU6/qw PtMOcCPGo7Irmb7LuBbEFs33+0PfZ2Ins5/cDHIU3z7K7+OY+C6ghPOgNTlF9i46GfFp k4/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=oYzGoW05; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id m5-v6si1241270pgt.361.2018.08.28.07.57.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=oYzGoW05; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=Q+UtRyNvNkwYnshT9IkFBgwFupwwt2dJy++I8w/l5mU=; b=oYzGoW05CqFQL9d7Wkcj3bKW9 znlj55QGfDaTL/naoO577ByyBAkfDOxFGhfmN2B8Vtb8TmcgE3GrUvnk7fq0A+UXkfA2xXGrcPm2R Uko7H+DU4M3ZMUXfzAjiUpyiFsp84GCPUEw7XoB2Wp4WrSCZUCIu8r+3ctF9jOpOlfi07Xrye1MY6 cqrLzuONDrr6gMClBHGuuhO5okGid+7MmOCu7O4xLEDh4+TK62ER0AXRxtYebBDe+PxFK3On46XE9 qx/s4wZCi4lBmQQfBP7Dc8n3nBk+zCbnSjY/StK6NH+AyUfk9EaeeIzxFcRbNW3VUzlBUaRWCrSVW Cb8JBN3jg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR6-0003CJ-Ql; Tue, 28 Aug 2018 14:57:40 +0000 From: Matthew Wilcox To: Andrew Morton Cc: Matthew Wilcox , Nicolas Pitre , Souptick Joarder , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/10] mm: Remove vm_insert_pfn Date: Tue, 28 Aug 2018 07:57:25 -0700 Message-Id: <20180828145728.11873-8-willy@infradead.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180828145728.11873-1-willy@infradead.org> References: <20180828145728.11873-1-willy@infradead.org> 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 All callers are now converted to vmf_insert_pfn so convert vmf_insert_pfn() from being a compatibility wrapper around vm_insert_pfn() to being a compatibility wrapper around vmf_insert_pfn_prot(). Signed-off-by: Matthew Wilcox --- include/linux/mm.h | 15 +------------ mm/memory.c | 54 +++++++++++++++++++++++++--------------------- 2 files changed, 30 insertions(+), 39 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 1552c67c835e..bd5e2469b637 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2478,7 +2478,7 @@ struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); int remap_pfn_range(struct vm_area_struct *, unsigned long addr, unsigned long pfn, unsigned long size, pgprot_t); int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); -int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); @@ -2501,19 +2501,6 @@ static inline vm_fault_t vmf_insert_page(struct vm_area_struct *vma, return VM_FAULT_NOPAGE; } -static inline vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, - unsigned long addr, unsigned long pfn) -{ - int err = vm_insert_pfn(vma, addr, pfn); - - if (err == -ENOMEM) - return VM_FAULT_OOM; - if (err < 0 && err != -EBUSY) - return VM_FAULT_SIGBUS; - - return VM_FAULT_NOPAGE; -} - static inline vm_fault_t vmf_error(int err) { if (err == -ENOMEM) diff --git a/mm/memory.c b/mm/memory.c index 8392a104a36d..d5ccbadd81c1 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1849,30 +1849,6 @@ static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, return ret; } -/** - * vm_insert_pfn - insert single pfn into user vma - * @vma: user vma to map to - * @addr: target user address of this page - * @pfn: source kernel pfn - * - * Similar to vm_insert_page, this allows drivers to insert individual pages - * they've allocated into a user vma. Same comments apply. - * - * This function should only be called from a vm_ops->fault handler, and - * in that case the handler should return NULL. - * - * vma cannot be a COW mapping. - * - * As this is called only for pages that do not currently exist, we - * do not need to flush old virtual caches or the TLB. - */ -int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn) -{ - return vm_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot); -} -EXPORT_SYMBOL(vm_insert_pfn); - /** * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot * @vma: user vma to map to @@ -1885,9 +1861,10 @@ EXPORT_SYMBOL(vm_insert_pfn); * * This only makes sense for IO mappings, and it makes no sense for * COW mappings. In general, using multiple vmas is preferable; - * vm_insert_pfn_prot should only be used if using multiple VMAs is + * vmf_insert_pfn_prot should only be used if using multiple VMAs is * impractical. * + * Context: Process context. May allocate using %GFP_KERNEL. * Return: vm_fault_t value. */ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, @@ -1904,6 +1881,33 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vmf_insert_pfn_prot); +/** + * vmf_insert_pfn - insert single pfn into user vma + * @vma: user vma to map to + * @addr: target user address of this page + * @pfn: source kernel pfn + * + * Similar to vm_insert_page, this allows drivers to insert individual pages + * they've allocated into a user vma. Same comments apply. + * + * This function should only be called from a vm_ops->fault handler, and + * in that case the handler should return the result of this function. + * + * vma cannot be a COW mapping. + * + * As this is called only for pages that do not currently exist, we + * do not need to flush old virtual caches or the TLB. + * + * Context: Process context. May allocate using %GFP_KERNEL. + * Return: vm_fault_t value. + */ +vm_fault_t vmf_insert_pfn(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn) +{ + return vmf_insert_pfn_prot(vma, addr, pfn, vma->vm_page_prot); +} +EXPORT_SYMBOL(vmf_insert_pfn); + static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) { /* these checks mirror the abort conditions in vm_normal_page */