From patchwork Tue Aug 28 14:57:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578673 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 771DB175A for ; Tue, 28 Aug 2018 14:58:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 660F12A4DC for ; Tue, 28 Aug 2018 14:58:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 592E02A4E0; Tue, 28 Aug 2018 14:58:16 +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 E79D22A4DC for ; Tue, 28 Aug 2018 14:58:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84B416B46E9; Tue, 28 Aug 2018 10:57:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 78A6C6B46EA; Tue, 28 Aug 2018 10:57:45 -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 5B4EF6B46EB; Tue, 28 Aug 2018 10:57:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 03A336B46E9 for ; Tue, 28 Aug 2018 10:57:45 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id h3-v6so1276711pgc.8 for ; Tue, 28 Aug 2018 07:57:44 -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=f5lhvXrwlCEZ0ayy37d4xw82v+UZxOYyyayLQyFd26E=; b=swfb0t1aCbJn4+nQRZDYXyyWK8Rij3C7bUoiMLT9PCy/68Dmlb7aDX2Jaj6RybTsBa Px0l9FWkx8oMg03uP3hczwQwYQb8wwVpm2SUpex1t3WltzjN2s65ZSiv1zvoHS14n5KK aWZDYM2P2T+GednUbnuNM5gLrnaqYhQzroxibdYF1n/DSegfOKDa1Bo+S9QXjWjNJvJI +swtejXsH8b7xxQxDSDJ8JPOj+/pDdFyKmEHce4bnxQRqH9/9wMrDJuWhNlGArPB78um 5al0KQYmBFzUFpKLHNAYkxF/424IB6mU2q5p1rf7C+4xnveBastXgOtP3SkJMKRkZEJz qSnQ== X-Gm-Message-State: APzg51AkPUqpjBVrUAhFNSUG28VlWUd6YuwfAvHZbmFI7g7azFWIR7ib 7479SwjmGPq6TYnIJn2ToJbLMPE/Ba848QjOS9OD9SggTE6dqQOdLULejGYx8lJpQGfMWYY8ULn QHanqGZz/Q22mF7VprfV4p9ycbgkUfoXUAZicXvBcD1KkwaYb+swfLWIFPTTQapbvvA== X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr1968896pfj.244.1535468264702; Tue, 28 Aug 2018 07:57:44 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZcIHmiUQ/vcddb/EOTxltb/v0lr3oO8OrK4ffnYjLiQHHwyONWvvuyaNZoO+BNkTtk/qqo X-Received: by 2002:a62:50c3:: with SMTP id g64-v6mr1968858pfj.244.1535468264030; Tue, 28 Aug 2018 07:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468264; cv=none; d=google.com; s=arc-20160816; b=00Pgrq2RFxjVQCfIbgYsXlAbErF2EWSufgi3IV9PlTpI3tdF6uDoerIW/2rduiveaP nIPG6S7IA0F+RIoRNKTqDxbVrNOtvUk9YaPjCMEIbzSJD4SviZjttxceuosAWrfBhkB5 YTz1VS674d3j2R2lid9KPHQtPeaCx7Db1Yaa2MZaAEqYooIbPE0ygKY+Kc2wHvprYZsM 1MEtjP1So4TfcGXdJ7p81jbhgmT3lM6xHql0FJcBK3KCbo4088cCk+UTSiWdBwfXzRpS +c4BRepJeE5GlLD10XTbrX8JAPiQRaPTaRl+bjrKlYHQ6JgI1lKHJsoTvXLuEmteaCyZ X/9g== 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=f5lhvXrwlCEZ0ayy37d4xw82v+UZxOYyyayLQyFd26E=; b=fclrSpVHg4l8I9rJNsfZX4ZHFfZbqn/7XYX52QWngafipRBIg3zbNh91OqUFfDcnaV 5NXpz/AGC+GEA6JMnqj2V1wCngn1UAvpJORfFJ6Bna0CpmGBmQ9mHlZHuEJ4AdY/VLmG dLcE9qk7wWWRAm46on3/KJMG8eE95rGrMIZPDhVlxi+hJlXe0Ji0v+9vbSC8R8JCAJqx gF1TfF4U9wh1yu7J1cr0DDtPykN//hv3wGp1crSr7PPI9RXJt/CcnJHTVFHCj3IEQ7ex HQtDUnzYqnrHVW3dFqbNQ3PybAPy/xhgwo6UTwXeGt55+JBNcisDjL1DBu37/cFKxkOD jUJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=D81kjOyW; 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 l63-v6si1182249plb.106.2018.08.28.07.57.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:44 -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=D81kjOyW; 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=f5lhvXrwlCEZ0ayy37d4xw82v+UZxOYyyayLQyFd26E=; b=D81kjOyWnlp6sEQdo7Z74hP0b CkgtyOe+BCufAkcsTVDFfvyRmjuJorzKSd0ZH3uSs54b24AWMgaLaIb2A6MTw+KQx+MrpTMi02Qqz wrbYJ/eRFobeiQBCh56Ifts/5MPn36Xt68x8cMrPtnIqf9WS5rkTaBSFmQiCvDv38Bii1UQ10FukG eBAqS45ksNj9RdULs4L2Fw90XQwQKyzXUMaF8F3Wc8atLNxeskh0NeFPpMf5BjrR/r4TW+plgSjsT 4/Lb5gcQ6J0nw0YbQLSE1PEmGgG6d67//tDtjuuwYwm4bd2/EU81Z92SlGJWAXVdjba+/mWZ2pWbl sGdyZovMg==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR8-0003DJ-Au; Tue, 28 Aug 2018 14:57:42 +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 09/10] mm: Convert __vm_insert_mixed to vm_fault_t Date: Tue, 28 Aug 2018 07:57:27 -0700 Message-Id: <20180828145728.11873-10-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 Both of its callers currently convert its errno return into a vm_fault_t, so move the conversion into __vm_insert_mixed. Signed-off-by: Matthew Wilcox --- mm/memory.c | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 9e97926fee19..9fef202b4ea7 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1915,20 +1915,21 @@ static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) return false; } -static int __vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, - pfn_t pfn, bool mkwrite) +static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma, + unsigned long addr, pfn_t pfn, bool mkwrite) { pgprot_t pgprot = vma->vm_page_prot; + int err; BUG_ON(!vm_mixed_ok(vma, pfn)); if (addr < vma->vm_start || addr >= vma->vm_end) - return -EFAULT; + return VM_FAULT_SIGBUS; track_pfn_insert(vma, &pgprot, pfn); if (!pfn_modify_allowed(pfn_t_to_pfn(pfn), pgprot)) - return -EACCES; + return VM_FAULT_SIGBUS; /* * If we don't have pte special, then we have to use the pfn_valid() @@ -1947,15 +1948,10 @@ static int __vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, * result in pfn_t_has_page() == false. */ page = pfn_to_page(pfn_t_to_pfn(pfn)); - return insert_page(vma, addr, page, pgprot); + err = insert_page(vma, addr, page, pgprot); + } else { + err = insert_pfn(vma, addr, pfn, pgprot, mkwrite); } - return insert_pfn(vma, addr, pfn, pgprot, mkwrite); -} - -vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, - pfn_t pfn) -{ - int err = __vm_insert_mixed(vma, addr, pfn, false); if (err == -ENOMEM) return VM_FAULT_OOM; @@ -1964,6 +1960,12 @@ vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, return VM_FAULT_NOPAGE; } + +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, + pfn_t pfn) +{ + return __vm_insert_mixed(vma, addr, pfn, false); +} EXPORT_SYMBOL(vmf_insert_mixed); /* @@ -1971,18 +1973,10 @@ EXPORT_SYMBOL(vmf_insert_mixed); * different entry in the mean time, we treat that as success as we assume * the same entry was actually inserted. */ - vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn) { - int err; - - err = __vm_insert_mixed(vma, addr, pfn, true); - if (err == -ENOMEM) - return VM_FAULT_OOM; - if (err < 0 && err != -EBUSY) - return VM_FAULT_SIGBUS; - return VM_FAULT_NOPAGE; + return __vm_insert_mixed(vma, addr, pfn, true); } EXPORT_SYMBOL(vmf_insert_mixed_mkwrite);