From patchwork Tue Aug 28 14:57:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578657 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 9D9BC175A for ; Tue, 28 Aug 2018 14:57:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8C77A2A4B8 for ; Tue, 28 Aug 2018 14:57:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 800AC2A4C2; Tue, 28 Aug 2018 14:57:44 +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 183522A4B8 for ; Tue, 28 Aug 2018 14:57:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4FD96B46DF; Tue, 28 Aug 2018 10:57:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C88846B46E0; Tue, 28 Aug 2018 10:57:39 -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 B53636B46E1; Tue, 28 Aug 2018 10:57:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 6E4386B46DF for ; Tue, 28 Aug 2018 10:57:39 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id l65-v6so1264423pge.17 for ; Tue, 28 Aug 2018 07:57:39 -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=N7Vh+kzAINa93+ASlwx4IbhXwzGgaGba3pGlvT4L2Pg=; b=MVtTQDp/Chlb0OgsWQkApghevjJo+sqXLkbcpPbEBBHPCK32edZD/5Y7OKEfF7MsF7 ZMtwm4wb56eaSmaldX+jUpjKPinM8LdSKi70aXpkOu4VtUxeIOLzl7yJc7eBFUIlENRW R3zEUKTd+eoYgf3VXTaD/e6BVWRSSpFseaKUHAPE8y9fA29sBu0YlJyuoWT0IayjGe5T TmC+xh8G+4AOig+SLKB9ceJy/9MWKVcWz4+JbQYlvcdl7I+Ssq1Y7ap4G+Z3nBilnC9W aAsJLU5Nvkn26LXg+4bFv70Y56+clgbmbc1IIyfjNRiEhUXWdKIKi5Lb6QNQvz41hkzI M8GA== X-Gm-Message-State: APzg51C0kFamYx9lgbLsJBcYXnfcnGCjZtzZ0iYfr0iqlOj2ql9PlYeJ YXnFY7v4XTRVApMphbAeEBYuTyXpocKtk0Csmcb1G2J4K/oWM3spHvBmmPDE2JDrO5TOuxb23tc 54DQhk5Fxhd595bq6uxWWBNuLwOeCG3L579SMV91g8TnUmwYCIekeiU/Z5znfoy6jGg== X-Received: by 2002:a17:902:694a:: with SMTP id k10-v6mr1923514plt.166.1535468259138; Tue, 28 Aug 2018 07:57:39 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda5xXzEAfs1UDGRMKq1hb8FH69OJNOWsDck/PpJrRbXtdX4nxpKgCUfgLwy8uGDFLWdamNO X-Received: by 2002:a17:902:694a:: with SMTP id k10-v6mr1923482plt.166.1535468258536; Tue, 28 Aug 2018 07:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468258; cv=none; d=google.com; s=arc-20160816; b=Z9cK42UvrkVhBjeQ9q6n0+z4jvVeJVM4VKdl+OqW4OUPWkbf5aMJGC3SeFsIVHZY0o +L8kJ0Z76YaNofrWfxi5qa9y7MQz040a7eSF5nn7aRpcm+nL/GXoXgtyiDxJ8iIO3AMs Jvc1I4tYks2lC9tCdFkMJ8R+OZW1RsWcexN5y5tpfsObbPlBKQmNRzMBZlfo0wgSRAFD Kuzk+piYgXuBGh3RYysPIv0+aT0hSlEIEm6TcZ0bpFFdryP5ysErBvhE8eRSgUjlGoGW tSMD73lMLR26op7Y5uOnjKC8qQqgOMNEwQXiJxG2cQc3Yk6emfm0y6kpmqq34x9wxPQ4 M11g== 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=N7Vh+kzAINa93+ASlwx4IbhXwzGgaGba3pGlvT4L2Pg=; b=ldMB5iM8Y7Lk3a7qfiifvwORW5OWK0KwYsxG3Da5GVUDaSSjt0v1nPqvqJJoF5TXDC Uz8Fb2TDCUz6/6AwgPc/JERdzEvftdZ+A6xSP0R5ASMPmI73Vw5+Yc1y7K/DbBEkkwz6 je8HxvvjoS0F2RnfWGtss6Zdmuwgj1oeyASVACSjznz52NI1ESa0ZabddMFcjiqnUiBs 1NWqbma4t0yuQzvkRg86zmilG8gYOzjCIES9+ZvutyC/kARnSrhoTIQto29L6QlzZh8P 8OCxObzLXP1utbsQDDQnzd0gwuzrU68TkESGtWZis+3aiiwFpB5fGumREXF3X8Eh1oa2 gS3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=c3pnzV8C; 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 y186-v6si1170766pfg.246.2018.08.28.07.57.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:38 -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=c3pnzV8C; 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=N7Vh+kzAINa93+ASlwx4IbhXwzGgaGba3pGlvT4L2Pg=; b=c3pnzV8C4rOFDmfWYfYw/Ky8t l7oqI8HLtpXIfpdL563lpWUIsZ0yQHq0UVuSQP2FyKaYGf6BHhUkXPc0K+OfUAb34zOiPcN5pBZ22 /oJ6w70YyMn86pQ/YtRPJzlIZuKCtmfBkscQv8V6dUZwy4kyD7OkAYzGO4oaPkAwSVDU0NOGVDsIN pZcKyrn+8gzVPwhgXhQ7c95qYDecemHCK2M6AOjR/HBLBVfx1FBfUGmfVwJ+Hv8MvNA+cE3UkCJWw 49gaszjah0NENyPvwxyKuabRsH9ffUn/XLSVAd1HRdhqSooebI8I1oBZhayoj4z421TLixzSyPxGr lDF4JCTVQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR2-0003AD-8E; Tue, 28 Aug 2018 14:57:36 +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 01/10] cramfs: Convert to use vmf_insert_mixed Date: Tue, 28 Aug 2018 07:57:19 -0700 Message-Id: <20180828145728.11873-2-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 cramfs is the only remaining user of vm_insert_mixed; convert it. Signed-off-by: Matthew Wilcox --- fs/cramfs/inode.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/cramfs/inode.c b/fs/cramfs/inode.c index f408994fc632..b72449c19cd1 100644 --- a/fs/cramfs/inode.c +++ b/fs/cramfs/inode.c @@ -417,10 +417,15 @@ static int cramfs_physmem_mmap(struct file *file, struct vm_area_struct *vma) */ int i; vma->vm_flags |= VM_MIXEDMAP; - for (i = 0; i < pages && !ret; i++) { + for (i = 0; i < pages; i++) { + vm_fault_t vmf; unsigned long off = i * PAGE_SIZE; pfn_t pfn = phys_to_pfn_t(address + off, PFN_DEV); - ret = vm_insert_mixed(vma, vma->vm_start + off, pfn); + vmf = vmf_insert_mixed(vma, vma->vm_start + off, pfn); + if (vmf & VM_FAULT_ERROR) { + pages = i; + break; + } } } From patchwork Tue Aug 28 14:57:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578659 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 2867B5A4 for ; Tue, 28 Aug 2018 14:57:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 188032A4B8 for ; Tue, 28 Aug 2018 14:57:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C3642A4C2; Tue, 28 Aug 2018 14:57:47 +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 9A5642A4B8 for ; Tue, 28 Aug 2018 14:57:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 429246B46E0; Tue, 28 Aug 2018 10:57:40 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3D8ED6B46E1; Tue, 28 Aug 2018 10:57:40 -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 252626B46E2; Tue, 28 Aug 2018 10:57:40 -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 CE2816B46E1 for ; Tue, 28 Aug 2018 10:57:39 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id g9-v6so1270313pgc.16 for ; Tue, 28 Aug 2018 07:57:39 -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=Exkv+LQ8zSJPTyJeFocnVOLnkAEWo8whdsioYoMD2fw=; b=PoGyy8YfPRReEikEAkbqyUPWA9wFtr/tUNr9Gxz18yZwk6c+gRHyYeXvdPqxHwqftH 9+iNC92ANDB62uqWDq2zUcu5htX8bf9n4Vdb0Pkme6MkPZO78lFq2B4sHkR1FFd1hWWm 2Ylg+umlXq4/MGDqVNO/SAfFkigvNq39eyhOCCsr8lQ6/gwGMXOkYLeta2JjeCGIGbxw r5LhD3hW1E6+cstaQeWZkzvquulNdqUKrNjaowRZ8EQr718Z4UOqINeqs3mnvmgXj3gj XkZhn2dpAEltupRdszvdlBb0hBOadSLtcm2u/H9X492Podzw51pEwKgJZoKClW3GxHcf 6ukg== X-Gm-Message-State: APzg51CR2uGPBSir2UnBuJqqH2ZHzNgxiJb0eU/GeDyi/AiNn4t4afQm PKGiwD/9wwPanZZPeMFstlh3YzFmlMnUw4EGmLroV1PZyznCiSqT/xgYI7wPRVkaAD3z508g4t2 +eYXC3h7BufiUXA3m1K3nPh5TrM3p3DCeMf0RbrTBvjPhCVvVl3l93jKne0mldUBP9A== X-Received: by 2002:a17:902:b7c5:: with SMTP id v5-v6mr1970965plz.49.1535468259487; Tue, 28 Aug 2018 07:57:39 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZPh9PgIXAyuxS1pC6fSjIExXYUjwTx+m54hbtLgVYLjFJltVWjVbUxWCd1UsWAJyWgQRJo X-Received: by 2002:a17:902:b7c5:: with SMTP id v5-v6mr1970931plz.49.1535468258806; Tue, 28 Aug 2018 07:57:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468258; cv=none; d=google.com; s=arc-20160816; b=TS1AOc+NuNmDAECBK2aruRmN2JfOqAT0lMbHPVICbLq28bjg65+Ow0lmBu3Wv/UhUy 9+vHnx0am1EqnBDTyRu6iNpnUsVa7zYoc6uln5hO48dkTJWBODv4ZpnIZaxiX2hA3Fco qnglDkqxDYlc2hmYoTrvsouZBEm93nidf/PhQuz+kflLj8dye9GRjSh9rI9XiLhKyuu1 wvS+d7vKjvc31a2Yef3FeeR1FTfMFp4eqxsuBGq4phIalLvL0sfh+30/qacqyjgiO/9J 13xoatuaDkp/DVi7/V23y9/H/ShpkxWacmU1nK9qnkz/tZOVnAL75Ub8L7t8AWjvyxuS Kdyw== 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=Exkv+LQ8zSJPTyJeFocnVOLnkAEWo8whdsioYoMD2fw=; b=esWAz279KviQrgU6uldAATEUCRwpSLjrUrn8psjZMuYlMQiUFnUIwq33df/1ZbSATn +FcQlJbQhRSRbbhW8fobbf/mZlBZhRO80aCoqPfQl6UAUMw7hoASoXA+i74ECMHedPfA +wVKCX6Kx8VPqT81+mWNSmcaztGm1c/zULZA8FAPw7SrDdcNVVNnDfZjnSlnj6U7lYQj lS0P4LiMBiPh7odVe1a+QBs+49AqkhCqigZAu1UrNyHO8V56SeoBeqbgw3oz3CI+7WZI RJybN7486hx1YmVnM3dzaQ56ZLvEr55Br2oGJzfjdIe7P6GNf+7IH6DgjB0GIMsqv2P0 cKYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=QwboO2dW; 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 1-v6si1160193plk.379.2018.08.28.07.57.38 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:38 -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=QwboO2dW; 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=Exkv+LQ8zSJPTyJeFocnVOLnkAEWo8whdsioYoMD2fw=; b=QwboO2dWE2pSRU5AMnJauS/KS mMb3BlCJKut71jT7XMq6iIyQvWlifU8RyEEY2yQ0DIXPIY5QUCkvgnOcdjCwRhvthLmzY6eaeZb/L NnjPDhHaexzFI23A+siAhvmeAjJiXIErHXJ+AIgxoDN7hG9Q15wMHw/N26JUiTu4Ehe+S13VNjyNs ndDeAxQ7+UgWiGsK/24/0JtME0fkkAU+zfoF+q5zLfg5rsheNo8Cq4jjpL7gjkEhGP41qwaFauGzv u7rlBgMJDck165FeXdPjkR4CpaBbkVczf6a2x/uLzSaeP0ihS5odedmoreD3p7GKa5OYESZYoOOxh uTxiR9mvQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR2-0003AM-WE; Tue, 28 Aug 2018 14:57:37 +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 02/10] mm: Remove vm_insert_mixed Date: Tue, 28 Aug 2018 07:57:20 -0700 Message-Id: <20180828145728.11873-3-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_mixed() so convert vmf_insert_mixed() from being a compatibility wrapper into the real function. Signed-off-by: Matthew Wilcox --- include/linux/mm.h | 15 +-------------- mm/memory.c | 14 ++++++++++---- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index a61ebe8ad4ca..ce1b24376d72 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2482,7 +2482,7 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); -int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, +vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); @@ -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_mixed(struct vm_area_struct *vma, - unsigned long addr, pfn_t pfn) -{ - int err = vm_insert_mixed(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_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn) { diff --git a/mm/memory.c b/mm/memory.c index c467102a5cbc..f0b123a94426 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1940,13 +1940,19 @@ static int __vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, return insert_pfn(vma, addr, pfn, pgprot, mkwrite); } -int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr, - pfn_t pfn) +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); + int err = __vm_insert_mixed(vma, addr, pfn, false); + if (err == -ENOMEM) + return VM_FAULT_OOM; + if (err < 0 && err != -EBUSY) + return VM_FAULT_SIGBUS; + + return VM_FAULT_NOPAGE; } -EXPORT_SYMBOL(vm_insert_mixed); +EXPORT_SYMBOL(vmf_insert_mixed); /* * If the insertion of PTE failed because someone else already added a From patchwork Tue Aug 28 14:57:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578661 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 CCF0E5A4 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDF502A4B8 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B27F62A4C8; Tue, 28 Aug 2018 14:57:49 +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 34F482A4B8 for ; Tue, 28 Aug 2018 14:57:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2C91C6B46E2; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 276606B46E4; Tue, 28 Aug 2018 10:57:41 -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 18F246B46E5; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id CD7836B46E2 for ; Tue, 28 Aug 2018 10:57:40 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id n17-v6so1052476pff.17 for ; Tue, 28 Aug 2018 07:57:40 -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=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=KLz32YcabADMP1ZpM1JFpuVLFBxkQSOC0B5jDUTtwx8J3Kdvugv/efHETGu+Y1sxhn H5ov0e/DIo6xoVSCikLNm4+xNG9105mwsaMPoVZXDihKyWYDif5DFbKT1WWKAlnXWfnr X4Rcv8EryrEeCbpwXfFjqe/pue7tmKJH2qsaMb//KBHfdxIAlyevjHNU2V5qcd6g1qA2 3iKUk6rQSbU8IA244aucalDHCEzB6CceDSODT1qRThYQ2TiihG35TaGjlgdFKPDfAudm y4nstoyUsUg53uuuJmH0X2YuErN2hWp7qQ+BaFtmQTgoaSgNHFymVJz6OdDHm9jC1xb5 faVA== X-Gm-Message-State: APzg51ARRgHCajyHHw7vljpovnweKlDjg1WZRT9cMyYM5koJluUW6GC2 9S5SAY923zS3lPbWQLCvPAKGla5L8jVxjGEroNLak8GUq/v6vs+KCJbW8BaiUuCkXop7hBOlHKL /kJvRsI9l7XRLAb3DVE2QZ1LYJ3wnxNZzE+3s66cGpC5t8lHYp/eh1mpWKzt+XRbBXg== X-Received: by 2002:a63:1316:: with SMTP id i22-v6mr1904524pgl.86.1535468260516; Tue, 28 Aug 2018 07:57:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda/iHPLD0YOKR+SrRU+MyXbO8YqW3OYsjgSJpI2KCoDwwpJi1gCcw10dStx4XT/Rl0F2IYL X-Received: by 2002:a63:1316:: with SMTP id i22-v6mr1904487pgl.86.1535468259722; Tue, 28 Aug 2018 07:57:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468259; cv=none; d=google.com; s=arc-20160816; b=tHD/UpQbC5uSvHloj+GlmzXLOH3V3MBl7xFA4wGwSG5NJWUa17MF0u9tEUeKhOr3Qh 7NHd+RI0+p5spP7uzhoZ97vugVYMUSXGx8baqNgSZ+FQRkITtFN1hNd/RpvElowRXWAl qxOoNocmQikk1vi4cAU2cD/180180UA4pT+rOCw3a8gfoKV8Xnlflx0oyZNzobGsDJX7 NWGoC/JJ0CT96rTIWXztU4uxTmimLd9+UcKNHlVf1CFjHut++7QLWq8wqlUvlp5bRyrs ZWwwCyrgKmF0HfF1ayGPXibRRXVc7GSPXY8ZNxL+CPSCtys8CHWCtgzYLOFXNimcxoyC 1rhg== 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=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=C4rzBvN/fd6jvIltgRNq+d0SvruJ3FF1RJ2xFfR50AsNKoTnBXW0J8Pdw7prIpxi99 4JA5cZLID6GC9THsNYnjWK9qq2PxEDaluZJiM+zIehU1K9WE1/IXvgc1+0PxHMEVOpB8 t5R6bMsMdlaMy/0hibq+MmibZdQSlbr2ESwJq6Yu2TO07HKWKCXRuJBluDSuxUDKoGel Ppxpa25yI2mLXT1xxuhG6Tw76wUnBAFKs4tEDtEJAspgeO+G8oHA1K2dj3v+pbVcUu55 Efhda1nsJDZwbX8IyDBRGbJD9KCdfv7di0K8bFHv3+nVDmLQrHExf8ISDqp+8DWISy1D tW0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=gwdwUXwV; 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 z5-v6si1216249plo.130.2018.08.28.07.57.39 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:39 -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=gwdwUXwV; 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=MPOh18HfFI3D3qSQeEm7RAc4dBhfYVRBxG/Jp7MGb8U=; b=gwdwUXwVHUb+yjYLSQ7uXxNle iTvkBjjB7hHT5jDlE+qxrDsLGOah2ss92jz8D9z6XrjY4jPWf2sYnDQDkhIE6sku/mnWtWUEipAa9 VfHlXoNmqxiU95qUu3La02KpeJNy+fKAi4/070Syd/XRVbO5yfW7Q5r745sRB7wjipfbb7AszP4x2 VklhihwljeMySBvKD1VMO41Tv3mOjXQVQdeKK9ZU4CAtzXSP76x9ARjgt+zfqg5yFHdMlnWVtJ2nX W66fZC2Uw9oLb76QpHxz2XzzQwEkwlQ7GyJg8XWlBgbWkHNx+nv3TylSI/AencqXcST+LjtB1WFMd 4mU+/iLqA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR3-0003An-N6; Tue, 28 Aug 2018 14:57:37 +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 03/10] mm: Introduce vmf_insert_pfn_prot Date: Tue, 28 Aug 2018 07:57:21 -0700 Message-Id: <20180828145728.11873-4-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 Like vm_insert_pfn_prot(), but returns a vm_fault_t instead of an errno. Also unexport vm_insert_pfn_prot as it has no modular users. Signed-off-by: Matthew Wilcox --- include/linux/mm.h | 2 ++ mm/memory.c | 47 ++++++++++++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index ce1b24376d72..e8bc1a16d44c 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2482,6 +2482,8 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn); int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn); vm_fault_t vmf_insert_mixed_mkwrite(struct vm_area_struct *vma, diff --git a/mm/memory.c b/mm/memory.c index f0b123a94426..8c116c0f64d8 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1843,21 +1843,6 @@ int vm_insert_pfn(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_pfn); -/** - * vm_insert_pfn_prot - insert single pfn into user vma with specified pgprot - * @vma: user vma to map to - * @addr: target user address of this page - * @pfn: source kernel pfn - * @pgprot: pgprot flags for the inserted page - * - * This is exactly like vm_insert_pfn, except that it allows drivers to - * to override pgprot on a per-page basis. - * - * 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 - * impractical. - */ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { @@ -1887,7 +1872,37 @@ int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, return ret; } -EXPORT_SYMBOL(vm_insert_pfn_prot); + +/** + * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot + * @vma: user vma to map to + * @addr: target user address of this page + * @pfn: source kernel pfn + * @pgprot: pgprot flags for the inserted page + * + * This is exactly like vmf_insert_pfn(), except that it allows drivers to + * to override pgprot on a per-page basis. + * + * 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 + * impractical. + * + * Return: vm_fault_t value. + */ +vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, + unsigned long pfn, pgprot_t pgprot) +{ + int err = vm_insert_pfn_prot(vma, addr, pfn, pgprot); + + if (err == -ENOMEM) + return VM_FAULT_OOM; + if (err < 0 && err != -EBUSY) + return VM_FAULT_SIGBUS; + + return VM_FAULT_NOPAGE; +} +EXPORT_SYMBOL(vmf_insert_pfn_prot); static bool vm_mixed_ok(struct vm_area_struct *vma, pfn_t pfn) { From patchwork Tue Aug 28 14:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578663 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 E211C175A for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2BB82A4B8 for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C6E712A4C8; Tue, 28 Aug 2018 14:57:52 +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 4BDE12A4B8 for ; Tue, 28 Aug 2018 14:57:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC60A6B46E3; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B78726B46E4; Tue, 28 Aug 2018 10:57:41 -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 A676C6B46E5; Tue, 28 Aug 2018 10:57:41 -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 61AB46B46E4 for ; Tue, 28 Aug 2018 10:57:41 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id u6-v6so1284880pgn.10 for ; Tue, 28 Aug 2018 07:57:41 -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=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=Hera40S4Ot2Ze3UGmgM2qj/C+CyUELn5sMYKsDYas5YvPiFcaDI2acI+NjGDQu9BmB cIkdYzQ4NPNW7lfYWnHsrMwQw7xzO7HJqrgwBHLhSVRCJCxQ2nKQJPlVqVmbme9FZIbC Ax4FJ+gWWaVrFRMu2q+KoIElMplreMX2gNIiJrlyBjONH3b/8k3LOGDnQH47OkTzEOlZ fO+9QEF7vXC5QTTbJHAsBHxYnpF1f5kU/bcaKzAyCo7xpliZIU+oJHb6teI4KZeviVDa 0XIoXjchoAGNE1HmUTiPg8KgDhul2Kvm9JhyGI8nrJghLDpaatMTBSI2L12l/FLO+ngD 45Ng== X-Gm-Message-State: APzg51BQhoO8BOLqcoIJ4ZPeEdI07r4oFEvS312KzqnOV2SNF2a0eci1 ui4cvn4ixWgTmktadWA2Q/kcxgdk2YulNIC3hyeGinEORkUzPsswPJKWOqslgjNqSS52i4vg4U8 HhW/vKl9wOhWpsvnaGfPTrhr2uhpzrKGqqR7fT6xa5XIuvu4tcb/nS5oVjH7jAj9iaQ== X-Received: by 2002:a17:902:b78a:: with SMTP id e10-v6mr1957422pls.79.1535468261069; Tue, 28 Aug 2018 07:57:41 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaWZowwJWo1el9MaY2aP8KrMzBBPalqozCx+aN6YbYKZMnqI5440EH2+I/Lu2yUjM7N6sSl X-Received: by 2002:a17:902:b78a:: with SMTP id e10-v6mr1957383pls.79.1535468260266; Tue, 28 Aug 2018 07:57:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468260; cv=none; d=google.com; s=arc-20160816; b=sRQ+JWHBMHVVVTgR5LN+IudcgitHEqNXQCAp+QC2LfaFMPDv1ZJNU0xymr95PdWKeo kirqGKhGvgI7+DowivYU+UvwuYhcCAWN3p4ocbrIt9UHtmZfSihYxaFCIaItATzMZsaI IfndGmKgbh17gEINIsRA8As9CrGBjy4Mb4+6MpumzgvISAD1H8p4Hpe+IiMR/RCiwSgc qO0rXpzh76dDiOXSDN1HcGrxYxndnR4KEAZ0YO4POfF9uLUWqsIssXZht27t6tW2GR8m jVsQxn85uq184vo0WlmJwr4e6K2U3F1wzFW5cCuG6DQHKTWRYJRVKlKv7yodE/0u7U/X Y4/A== 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=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=lWprtYW/g616YQLhQ2dheHoMNdVIv2oAkPwhUxXpeKI0p9RqjnH1d6cIfaRdUPvXpf ZtCZkEdcLH6lUWYuB0g8Gs87VU31oSfnu9QNPGbpta3wOoOKvlKbWAtR7L4pZcNw7h5O lpCe5713vinRmKTG3l40Y0IOjcwd3PhekpXm3v5+wtSw6juXJak6d1dNleFmkN0/fLkN OGMKTzvTM07oLhz0vIeP899v1/FlgOAx3mFM8cp2a0Ldq63xWPwM7815MRpIhbnJL6c2 tNyqo/9tTrzO5OSTijVR0nXy2CHhCC6Z/z0KOj8gYSWamDxnyy5BUuUTJ+mgXrpeug6W GNyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=MlhXHXbQ; 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 p14-v6si1103573plo.357.2018.08.28.07.57.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:40 -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=MlhXHXbQ; 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=wjUXKpM3aAzUZ+cGrcsbIYHIevH4mUeUXMQGZp2tvbE=; b=MlhXHXbQ1yVhRHApMUy8I29KV VXzlYu8vxHys6oa7NbpZdSNzLegAaI9Ur6UIXY8+b5kLvbwaLz/8avtBllWksP1Rldm39jWjGpMdr vg+Ih3FhWQMjH5A9ciQy/4luhOyRIuQX/HRdU31sOucg1qQOmhNsBm5hQuIeRSOb9Y0vvIvEd48+2 3/2JjAO7n+4jBsQjc2WzFOndcIyUG5N/pUYZMiHBp3XHHRA2x2dpg7Q9GSIqT374wyCRrY2lrtqtK GnOao8nSZdmF/nwDTEV95bfLP9hNfALfgoiI8LEsTkFjstPZOutvTt7xr8OxbVMVBeZMBe1PQXPbh w+aKeWd+A==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR4-0003BA-GK; Tue, 28 Aug 2018 14:57:38 +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 04/10] x86: Convert vdso to use vm_fault_t Date: Tue, 28 Aug 2018 07:57:22 -0700 Message-Id: <20180828145728.11873-5-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 Return vm_fault_t codes directly from the appropriate mm routines instead of converting from errnos ourselves. Fixes a minor bug where we'd return SIGBUS instead of the correct OOM code if we ran out of memory allocating page tables. Signed-off-by: Matthew Wilcox Reviewed-by: Thomas Gleixner --- arch/x86/entry/vdso/vma.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/arch/x86/entry/vdso/vma.c b/arch/x86/entry/vdso/vma.c index 5b8b556dbb12..d1daa53215a4 100644 --- a/arch/x86/entry/vdso/vma.c +++ b/arch/x86/entry/vdso/vma.c @@ -39,7 +39,7 @@ void __init init_vdso_image(const struct vdso_image *image) struct linux_binprm; -static int vdso_fault(const struct vm_special_mapping *sm, +static vm_fault_t vdso_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { const struct vdso_image *image = vma->vm_mm->context.vdso_image; @@ -84,12 +84,11 @@ static int vdso_mremap(const struct vm_special_mapping *sm, return 0; } -static int vvar_fault(const struct vm_special_mapping *sm, +static vm_fault_t vvar_fault(const struct vm_special_mapping *sm, struct vm_area_struct *vma, struct vm_fault *vmf) { const struct vdso_image *image = vma->vm_mm->context.vdso_image; long sym_offset; - int ret = -EFAULT; if (!image) return VM_FAULT_SIGBUS; @@ -108,29 +107,24 @@ static int vvar_fault(const struct vm_special_mapping *sm, return VM_FAULT_SIGBUS; if (sym_offset == image->sym_vvar_page) { - ret = vm_insert_pfn(vma, vmf->address, - __pa_symbol(&__vvar_page) >> PAGE_SHIFT); + return vmf_insert_pfn(vma, vmf->address, + __pa_symbol(&__vvar_page) >> PAGE_SHIFT); } else if (sym_offset == image->sym_pvclock_page) { struct pvclock_vsyscall_time_info *pvti = pvclock_get_pvti_cpu0_va(); if (pvti && vclock_was_used(VCLOCK_PVCLOCK)) { - ret = vm_insert_pfn_prot( - vma, - vmf->address, - __pa(pvti) >> PAGE_SHIFT, - pgprot_decrypted(vma->vm_page_prot)); + return vmf_insert_pfn_prot(vma, vmf->address, + __pa(pvti) >> PAGE_SHIFT, + pgprot_decrypted(vma->vm_page_prot)); } } else if (sym_offset == image->sym_hvclock_page) { struct ms_hyperv_tsc_page *tsc_pg = hv_get_tsc_page(); if (tsc_pg && vclock_was_used(VCLOCK_HVCLOCK)) - ret = vm_insert_pfn(vma, vmf->address, - vmalloc_to_pfn(tsc_pg)); + return vmf_insert_pfn(vma, vmf->address, + vmalloc_to_pfn(tsc_pg)); } - if (ret == 0 || ret == -EBUSY) - return VM_FAULT_NOPAGE; - return VM_FAULT_SIGBUS; } From patchwork Tue Aug 28 14:57:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578665 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 0725C175A for ; Tue, 28 Aug 2018 14:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAD6D2A477 for ; Tue, 28 Aug 2018 14:57:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC1122A48B; Tue, 28 Aug 2018 14:57:56 +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 315482A477 for ; Tue, 28 Aug 2018 14:57:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E3A7C6B46E4; Tue, 28 Aug 2018 10:57:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D73BD6B46E6; Tue, 28 Aug 2018 10:57:42 -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 C89366B46E7; Tue, 28 Aug 2018 10:57:42 -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 8029D6B46E4 for ; Tue, 28 Aug 2018 10:57:42 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id q67-v6so1286013pgq.9 for ; Tue, 28 Aug 2018 07:57:42 -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=9tBcS1QRQOB96RExgqPwsrGxCmJ5quUecq8Bctt4nyY=; b=j6u5cpvdl1qBW9hGnXKgAdhropzu3F4/SM8nQpTxCTuBnLzHrtRgPS6iHsGZcqAe+D rZvEB2jg+eg/XucWAJN9nBorilot/WTfOKn3LvqfJyUT+G7O3jr5s6gXdLX7WENAN6D0 z4xP0Tgw3kKtj0EUtQHB4JtxANPMHZnFcOJ7Xq7jZXu9G3kYhNZKpQVs/2KfZH9sH14L 0+rKT1WbG/h4gFfrTSWZ1Z/b9CnP49O4hvkWUpuwGtjUzDvMPazBroJ8ToNI7QLq4uR/ d90KyO0Bk7Czlj9rUPrKOGnElOpHOSzXzRE3XyL/WaVhKmQkh4OZwjtSvY4oTX0hKD4V coxg== X-Gm-Message-State: APzg51Bb+yE6ZyRF9943MdoUjQ47Hqq75d9eALRkagr200OTyHakNlA7 TzQIJaDQbS8sBIR50jTBAqlPqAL6XetzEvOekq+wMDLTABR18bVN9NDpq77nxVyVs7Ma6sSRczS FaA99MKEY30EQ6KTTFNAxLiTO/Q4nhQ+wYDlXpfl7/R4fM7FbyXBAoskwhDEOmJ3FHA== X-Received: by 2002:a63:a112:: with SMTP id b18-v6mr1921795pgf.384.1535468262175; Tue, 28 Aug 2018 07:57:42 -0700 (PDT) X-Google-Smtp-Source: ANB0VdakThNdMNRb3+oyXE2VmwgmA+fYX5Hh5jKHb851W0tKn0vn7/h6Jpfe/WA4B86+vo4LywfB X-Received: by 2002:a63:a112:: with SMTP id b18-v6mr1921760pgf.384.1535468261424; Tue, 28 Aug 2018 07:57:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468261; cv=none; d=google.com; s=arc-20160816; b=aoZKZOvuuSMHASDwguvqC5/OleYKan2bOjCnJtpXY0z8W9TsfpPeBnO6EowpcOvjRi XEwWD2A3z/JkYCCY7TxtJI6q3zoaAUw13spwla8IhmjtSrd1NnbU7XeH80YEn1kNPts/ IX+kjTaYECIsjliEyh1T7gWEgnDEz0lDYmFeUaTmPU23+rCMu1nHv8hpODVAoyWYUKFS 1qT03rYy26t3849kMRAOjvFXkQRbD7KXO7WNiYmY+1ZXKqRgKshiF5O5Z+0JeUr5eL48 X2RCkncEqVwyYaTxpNvK7jbCkeyfjpWjnt6rF5GdgWf/oUCqgmEtltZU3btsmxUqc66M dSvA== 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=9tBcS1QRQOB96RExgqPwsrGxCmJ5quUecq8Bctt4nyY=; b=M2RK7XP7f0BDY0Ke4dT+2ruqt7tiaohHhpRQnfbph8UIVENRT2SSktiKCmGV0hb1/k tImE07P6I3Ie02YUEyowmzUdyVtx1KDN4Avc4SB0NjxDaSX22wVXC5RR3wUzcHSQ/sxn jb/5evXn1UbdjvxFrYQ9uE6HKvV2VI68mHMaolabWr2V82klLQl+IHubnWnexzKFUV8H 3scNw4V7NImPsRP+RfNjMOgBvFSygRsI39gZxrNTNDTr7Xh5BITI1FlGWIQ762+TfimR sTnoWZ5/Nrq8bBBAXuGA+CVAuV7161AkTycHchchiiCN60NRtGab5mHuNfzSKtAHp1aP e1Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=pbRVvCuR; 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 n64-v6si1289213pgn.247.2018.08.28.07.57.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:41 -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=pbRVvCuR; 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=9tBcS1QRQOB96RExgqPwsrGxCmJ5quUecq8Bctt4nyY=; b=pbRVvCuRqgWeE8eThkiSJUGOU 0tGJ4MEa0VLyU0TeVTIpGmKyvTeR/wCdJAePZXYUat97fFyeh9/o47ljBZ8fdjCp30jfa50Pc9/Im sHHuvnMOJMpiHrYykf9eN8TqbFFX51oJEyLQ5gBPIWF5oZrdBTEkBkkHJZqWmgrvtmncnf3b20vcS 8wC8Nu117GUJ3lO+CcSTqxxTf5eiyMn/E6TU8FGmXpNkdiSAJtV2tElE6lJBKeSHOH+qyuL5qIThA WmDim6UMO28VblH5IT1p7+l3I9Y2gaHsoHSyTOFGcFxUPfW0yI7X9cjkWNMQYqxuMIvkQNLGRQF7T 9+UaGGUiw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR5-0003Ba-6p; Tue, 28 Aug 2018 14:57:39 +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 05/10] mm: Make vm_insert_pfn_prot static Date: Tue, 28 Aug 2018 07:57:23 -0700 Message-Id: <20180828145728.11873-6-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 Now this is no longer used outside mm/memory.c, make it static. Signed-off-by: Matthew Wilcox --- include/linux/mm.h | 2 -- mm/memory.c | 50 +++++++++++++++++++++++----------------------- 2 files changed, 25 insertions(+), 27 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index e8bc1a16d44c..1552c67c835e 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2480,8 +2480,6 @@ int remap_pfn_range(struct vm_area_struct *, unsigned long addr, 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, unsigned long pfn); -int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot); vm_fault_t vmf_insert_mixed(struct vm_area_struct *vma, unsigned long addr, diff --git a/mm/memory.c b/mm/memory.c index 8c116c0f64d8..8392a104a36d 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1819,31 +1819,7 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, return retval; } -/** - * 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); - -int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, +static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { int ret; @@ -1873,6 +1849,30 @@ 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 From patchwork Tue Aug 28 14:57:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578667 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 2BB065A4 for ; Tue, 28 Aug 2018 14:58:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8689E2A477 for ; Tue, 28 Aug 2018 14:58:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A8062A494; Tue, 28 Aug 2018 14:58:00 +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 09F122A477 for ; Tue, 28 Aug 2018 14:58:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BD666B46E5; Tue, 28 Aug 2018 10:57:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 81B966B46E6; Tue, 28 Aug 2018 10:57:43 -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 732E96B46E7; Tue, 28 Aug 2018 10:57:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 2EF8D6B46E5 for ; Tue, 28 Aug 2018 10:57:43 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id x85-v6so1067675pfe.13 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=yIwb6uEk5/hv3Tvm4Xff2KDOLO6LMMPMM9lI85j8icw=; b=HRKPBiHFHtkFieTI4YeiOjcZreGOcelct81Za8TeBhnKfZaYqSQMxd47NaVM0InVu1 HcTrhDvtQsds6SFaR8pEuC2mXqfpGrxXXtgxpXgm26In9qcYZIg4BCJuJznRi8KUn1+H FDZfk0YpBWyK1OX6dPu9AeQEbg6IpLjAD2FubvBkfSMA+FiZu4CEtNlQ23tlXmX+NTaB uqgGVXo7H95qQa4NEevKbmZDsf1iysQy/x2V+3eO0grh4h4hN0o+6nyratR2Qbrfoq+O qXWeA+4zlBvyspoQNiG3m9Z7USB7nokwusiItl8gb2GVu4RpVbIWZMT0BnZIGSU5i/cl z21Q== X-Gm-Message-State: APzg51Bc0ucPyE/VPQTQXZflJylAkKALQxqkLHPADN5IETT1nBlH+hyf Kz8aa3n1QPsxGn8k396NNfRHTEDzlNyuqIiNV2yEWNQ07XjL8Xe2zPmoenimzjph4mfIk4LGHuf dnb6/9WYaz3+FqAirPHmCc2ajLzHixYje5LVp/GDfmj/RV1zQ++kpYNlVCzH0wPYigA== X-Received: by 2002:a63:6485:: with SMTP id y127-v6mr1874335pgb.393.1535468262864; Tue, 28 Aug 2018 07:57:42 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaef/vKlwKao6LJpE0IXjXieh2ZO6VFMJZRpVc3nCsvfZvjs9b22u7vOMuncQJzc8cG8WHi X-Received: by 2002:a63:6485:: with SMTP id y127-v6mr1874312pgb.393.1535468262114; 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=GdTexr2nsyAM9k6PVtw+n795H9wPI3mF51/XUBSRVm7X6RE5Se0+pdk4AL6HOZfkgF 5fLFRd94uZ1C9nDLUxR4Z6DFB4pYHOUnDsDv8OcFIg6ZquCMBzZ8BqvDMKFvJTOpYuWc E3Zl9o0PPsM89nptFdiEcIlnm+hOHquV+9lQvN1kKilfx4gMlh3UyMSW1Yv3RdG1uM/E pmfmaXaw/BVYfahcxrOrBct5mXwxVNMsXPRbhsw/qFaQfGiaCtBJRzLY1zsZtWvwUWPD /GpNqnXkucipMQZO2aUMhXDlfKm/zbPE9C+ZPuBcQ/MGWVe3wVIkt2K01pIRjkeg/7Nd teFw== 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=yIwb6uEk5/hv3Tvm4Xff2KDOLO6LMMPMM9lI85j8icw=; b=rgyi8kPKy3RaSPYSTC+SYfThYL8BRY9+fT3H75mIi+MQbYtyXMJsl6ICKsJ7UWfgIL gi3dg7ehJDYn7h+dzw7WNUQFZtoe96pk1XSUA7S2WP0Z1gaWYlyqHhLe0z+uB3Pc+wrH 8YuT2QUkUN/+xxuDUCTZb0bEJ+UEsxyaQRELFGHj4q2rufii6+7Ra4u8jqBlE/CHR1uz XNAqcamwUBuQpFMgeoNq4Up/UR5GMl16su5UskLufDrrv5OUa7V/ciJKBbRP6eEiOe3J yMmIQr0ZitaBdQoOtwuo9UHSqArHqJjh56mNAXJu13FCJp/9HwVPtnUn4BG5z8EIuXkM Zs5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=jdK7t+GJ; 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 e14-v6si1078299pfi.184.2018.08.28.07.57.41 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=jdK7t+GJ; 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=yIwb6uEk5/hv3Tvm4Xff2KDOLO6LMMPMM9lI85j8icw=; b=jdK7t+GJO9QxRmlulZaY5yL/W OdR3fcQJKAtlhRmv5uVYKENCdMZbmVFAny4B1K51WA1i0sI/Yn7KEV9G+H93xvEzgwvL/B6KUCPVI /+nXfAIcAKWgJnMOG5i2nRBz/V2Kz6Zc920fR+886fWGd+Qu7+sKLDhfSVFP7Vf4xgkhXvgLF2ND1 XGgy7/e7rciYG6915eCcateQmg42qd/7s6MtJNs0vjeZPLjlNH7eZlDQAmfCLIS5z2tvWfogIx4TX LrVEy2yxzm0+51aPCOBM0EPUXXWwQiD0PxT/Itcs/5+fAtVjDinGzVGXs7L9bMWTF5sIy71VvMO4W qkyTiFWBA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR6-0003Bz-1X; 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 06/10] mm: Remove references to vm_insert_pfn Date: Tue, 28 Aug 2018 07:57:24 -0700 Message-Id: <20180828145728.11873-7-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 Documentation and comments. Signed-off-by: Matthew Wilcox --- Documentation/x86/pat.txt | 4 ++-- include/asm-generic/pgtable.h | 4 ++-- include/linux/hmm.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/x86/pat.txt b/Documentation/x86/pat.txt index 2a4ee6302122..481d8d8536ac 100644 --- a/Documentation/x86/pat.txt +++ b/Documentation/x86/pat.txt @@ -90,12 +90,12 @@ pci proc | -- | -- | WC | Advanced APIs for drivers ------------------------- A. Exporting pages to users with remap_pfn_range, io_remap_pfn_range, -vm_insert_pfn +vmf_insert_pfn Drivers wanting to export some pages to userspace do it by using mmap interface and a combination of 1) pgprot_noncached() -2) io_remap_pfn_range() or remap_pfn_range() or vm_insert_pfn() +2) io_remap_pfn_range() or remap_pfn_range() or vmf_insert_pfn() With PAT support, a new API pgprot_writecombine is being added. So, drivers can continue to use the above sequence, with either pgprot_noncached() or diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index 88ebc6102c7c..5657a20e0c59 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h @@ -757,7 +757,7 @@ static inline pmd_t pmd_swp_clear_soft_dirty(pmd_t pmd) /* * Interfaces that can be used by architecture code to keep track of * memory type of pfn mappings specified by the remap_pfn_range, - * vm_insert_pfn. + * vmf_insert_pfn. */ /* @@ -773,7 +773,7 @@ static inline int track_pfn_remap(struct vm_area_struct *vma, pgprot_t *prot, /* * track_pfn_insert is called when a _new_ single pfn is established - * by vm_insert_pfn(). + * by vmf_insert_pfn(). */ static inline void track_pfn_insert(struct vm_area_struct *vma, pgprot_t *prot, pfn_t pfn) diff --git a/include/linux/hmm.h b/include/linux/hmm.h index 4c92e3ba3e16..dde947083d4e 100644 --- a/include/linux/hmm.h +++ b/include/linux/hmm.h @@ -107,7 +107,7 @@ enum hmm_pfn_flag_e { * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned memory * HMM_PFN_NONE: corresponding CPU page table entry is pte_none() * HMM_PFN_SPECIAL: corresponding CPU page table entry is special; i.e., the - * result of vm_insert_pfn() or vm_insert_page(). Therefore, it should not + * result of vmf_insert_pfn() or vm_insert_page(). Therefore, it should not * be mirrored by a device, because the entry will never have HMM_PFN_VALID * set and the pfn value is undefined. * 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 */ From patchwork Tue Aug 28 14:57:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578671 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 28C955A4 for ; Tue, 28 Aug 2018 14:58:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 197232A4DC for ; Tue, 28 Aug 2018 14:58:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D1BD2A4E0; Tue, 28 Aug 2018 14:58:11 +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 6D3882A4DE for ; Tue, 28 Aug 2018 14:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3F546B46E8; 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 BED156B46E9; 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 ADFFA6B46EA; 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-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 68C496B46E8 for ; Tue, 28 Aug 2018 10:57:44 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id e15-v6so1084453pfi.5 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=zU0QkCVvQYJGUULQkXZrz90Twq+68Z+fITs7I2vkboA=; b=h1EPuVqiZVRN9gcpH1+HUB1H1x2QhQleYV4YHMd0NTal/8rNwDmFUfPydIDWb6fJN3 51/xRGchlPuerOiwTOC+a86RZy//Kqf13Eng4ic6+ZKc7dzZ69N/zjMzPlgP4IwVYyBi YcX9ljsVSiROVvDZwXO6hf5B9ICwiDQY65Z0q6JUIlMBZtVI/IlZYcoSEZXmqms4Oiln XDWLA80VWkvdAHlSRJCgLE5tfKu4GaBrelaZdO18BSXjxiq8cdJQwj8hRl6Z7TWUnpug tIlEy/crOCC/wJ49gXo0OJbqQGEx08AmvdhVhEbHL/Ort3mfl7hC01rHbawxHxkSsic5 fGaQ== X-Gm-Message-State: APzg51BTvhuNklCjh6R9CUppHPqX4Q80m9j4FCNKSqcEFHCubkfO3rYP R+Th3h5UE7t7blsOrP/w1BOfSsWd1we/ZBq7SXCQrXws3tPOyQO0ZE0uNq/jXnsKtwWgYd/vHlP qDG6at4+nwiL3bToE0VQbY3xTKesiqJhSh+A6aWt6zPLB52xynFQsX5mH9n80+tW8+w== X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr1906828plo.124.1535468264108; Tue, 28 Aug 2018 07:57:44 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdaon6l5FZ+6tVhZcloEhm1ZB1OBKJM0M/9AwfclHRBrMSLA4gbQFanVbYAQcZ8peiLrxC8Y X-Received: by 2002:a17:902:8bc4:: with SMTP id r4-v6mr1906788plo.124.1535468263393; Tue, 28 Aug 2018 07:57:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535468263; cv=none; d=google.com; s=arc-20160816; b=d1w+4IVuWXMic9wTsSCgO/GQK6xolFQaSyN6by56rzChGsLigjQn/l0EsIflvKAhT0 txK0zeQ7ne7Bb6MKgT97IlJZOU1pvSaq5MCefFX73Gdx25leiB+9AaPXAJp1a6049VJF ggCyCJ40qqAIkXX+sMegEkx6Ir+CPCWvcij6pvfKONts3tHxP7pExIPxkHQTWZu5xmPD VN19vvW+nmp12j7AvCmdj6Qq8NzghsyvjmrN4t/4udR4lTsVr3LISPPHVJ9GozaXLGEM kYl/ytkPqfGLSG9SIv40v6iHYqr5d019ER+K62Sqv34OBtnulFxYGsjoJMMvZ/xryBcM bp0Q== 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=zU0QkCVvQYJGUULQkXZrz90Twq+68Z+fITs7I2vkboA=; b=CWtFVg5A2lTvZpVFHRHuKlfeCoUX3qrhHfYRVIIllkMH80ZXnUS3JAkv4RP8BkgP3S LdeGkgzwpwHhvCpTQLZw5Pk5tbzbh+bkR4IBWiBIJu81iCyTTp3UtArUt7IhLUUnr3hH /Y7UptWdxrCgje1Enf8LPAnbZXQqaU1nEV9UHRnhjxDyR/YQ338bwebDzh6Ak6A/77q8 GHnGtCWpl9ZAP/u8kcJDi5ueTHMAc6WO/T5FDx8GDQFOEN/sVD2qJOcBOjwu8npkv2fi 4s37/uU1DX60ujeYanaLUybJEoPKsOoENMfPmKqYvhciwqJDtiF7xDEcwFlWDIj9inGr 5VHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b="rl9IcXn/"; 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 l14-v6si1198591pfd.250.2018.08.28.07.57.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 07:57:43 -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="rl9IcXn/"; 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=zU0QkCVvQYJGUULQkXZrz90Twq+68Z+fITs7I2vkboA=; b=rl9IcXn/KXyLGct7CVIKh2iPr gqmioch5zYkp7rkujjTNwIXLFSBWZ4S6GmT/HwAkGeOSh1fQCMtzfFUXAvVRbGP9xZutrxNonipiq acYSRD5CEblGbux3PZjVtzj8k+PlL/MHqbnk6PJvlOqyjsaa3w3WzkFlpdh50NuC5cGC6bh8fK4PN +w/8qKmAG3VocQ/T7ZEbd22JMjwZj0xpGIiMJ0Pf3m8UkfOpozxBr0hH6ASp3IEl8e/9RkMpu3kjb HS1K3fxHQngkkBmgFz8YWa9RokyXB12l6lsiP3gqA/8mVP2QCu0ZeCZK7SKYT6P4D2T2dOzE3IS6S B3OhRaMNA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR7-0003Cu-Ie; Tue, 28 Aug 2018 14:57:41 +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 08/10] mm: Inline vm_insert_pfn_prot into caller Date: Tue, 28 Aug 2018 07:57:26 -0700 Message-Id: <20180828145728.11873-9-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 vm_insert_pfn_prot() is only called from vmf_insert_pfn_prot(), so inline it and convert some of the errnos into vm_fault codes earlier. Signed-off-by: Matthew Wilcox --- mm/memory.c | 55 +++++++++++++++++++++++------------------------------ 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index d5ccbadd81c1..9e97926fee19 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1819,36 +1819,6 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, return retval; } -static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, - unsigned long pfn, pgprot_t pgprot) -{ - int ret; - /* - * Technically, architectures with pte_special can avoid all these - * restrictions (same for remap_pfn_range). However we would like - * consistency in testing and feature parity among all, so we should - * try to keep these invariants in place for everybody. - */ - BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); - BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == - (VM_PFNMAP|VM_MIXEDMAP)); - BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); - BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn)); - - if (addr < vma->vm_start || addr >= vma->vm_end) - return -EFAULT; - - if (!pfn_modify_allowed(pfn, pgprot)) - return -EACCES; - - track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); - - ret = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, - false); - - return ret; -} - /** * vmf_insert_pfn_prot - insert single pfn into user vma with specified pgprot * @vma: user vma to map to @@ -1870,7 +1840,30 @@ static int vm_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { - int err = vm_insert_pfn_prot(vma, addr, pfn, pgprot); + int err; + + /* + * Technically, architectures with pte_special can avoid all these + * restrictions (same for remap_pfn_range). However we would like + * consistency in testing and feature parity among all, so we should + * try to keep these invariants in place for everybody. + */ + BUG_ON(!(vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP))); + BUG_ON((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) == + (VM_PFNMAP|VM_MIXEDMAP)); + BUG_ON((vma->vm_flags & VM_PFNMAP) && is_cow_mapping(vma->vm_flags)); + BUG_ON((vma->vm_flags & VM_MIXEDMAP) && pfn_valid(pfn)); + + if (addr < vma->vm_start || addr >= vma->vm_end) + return VM_FAULT_SIGBUS; + + if (!pfn_modify_allowed(pfn, pgprot)) + return VM_FAULT_SIGBUS; + + track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); + + err = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, + false); if (err == -ENOMEM) return VM_FAULT_OOM; 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); From patchwork Tue Aug 28 14:57:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10578675 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 6B61A5A4 for ; Tue, 28 Aug 2018 14:58:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C84A2A4DC for ; Tue, 28 Aug 2018 14:58:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 510E32A4E0; Tue, 28 Aug 2018 14:58:21 +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 DCF9C2A4DC for ; Tue, 28 Aug 2018 14:58:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D9E476B46EA; 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 D755C6B46ED; 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 C3A486B46EB; 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-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 7D2276B46EC for ; Tue, 28 Aug 2018 10:57:45 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id o16-v6so1266578pgv.21 for ; Tue, 28 Aug 2018 07:57:45 -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=ttwMQNsa+nr6K2+Si0fY85CCjll5fRpBEwDl7EOBPac=; b=SvhJeFbkWWzTLMPQnFgytBgRZ+VNLGk5UC7aNh8X0yf5UZBpnBoL5nlC/qFZgZTFtY 1soF20OZMCOOW3Uh3DQ5Ytg03jvEPGQ7FlBcuzHrUzx9k4k1wFnpt5BMAfJdO3iRE9A8 QIWeQ7o4ex6wqL0OhxRU54d0Smb1p6HhYKSG7EKIrj6CvaEXeuxIoLs+7jU8jnvGPCi4 pdUeITnIlNVTa+q/ceI1TOz/Y2jWVKjnHbNwZESuY0xYukV2YjVbmwx/OrlHubC/wf1f VRp8c4ZX4oi2rD3ilDrViNLR8IFw19ffhpu2+JfLa4T8icPPjiC6HQ1Z0tIIuVrZl9vZ 6sSw== X-Gm-Message-State: APzg51A8iJP1C6o78fFQCXqESGUpmhmRyoWgDUllsXZLG2PG023jXeK0 FFII7QzmErjcdAuI2supW9afgP6lp5nWI2lEREhZk5ZZaqmqipuVta090GYCpTeGu3S6Y4wvxxx 6c5Z3WnZkSAnMiK/ExG2bobqwsLjRArB+Of5WLMsgWLFckvz0iimBlBRlDS+NkaA3hQ== X-Received: by 2002:a17:902:7586:: with SMTP id j6-v6mr1894515pll.295.1535468265185; Tue, 28 Aug 2018 07:57:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZTQujDRMjN5JkiioSesioUB97O58MInoEfR4Rc7wgVykVY9wqeRKLgC9pSugSaSPAEiI8c X-Received: by 2002:a17:902:7586:: with SMTP id j6-v6mr1894465pll.295.1535468264346; 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=0Nws4f6mQxiD3enI6lfiOkRAgpDiOpQpSzLKBFC99YaaTFlPNdzvk2R5nDZySoUa6w mMnUWrNPSyvC5zqTDffp9ZQh9tWwwLB482DiORWj7vJaXxmG+bJ/6hOd+HRhy0rQ++Co t6EZmidYAMhncXVYcFPRFEia4QN6GtDlnRlzAT4xyggDRhWnSymMuz/wzr0UV0amOT5Y rtaRVi/BOzjMpFdkC5AQOb/eSyrnV7k6TWyFQCl2SH2LuUHPeMiLgiLw5mugHY3uI1nt ZFTExH18ETp4cf0+O3/WQpYFlejF8m2DA833uWxLhVwmNUzy2AqeF+xzkYPSmgkb8Ivl yx7w== 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=ttwMQNsa+nr6K2+Si0fY85CCjll5fRpBEwDl7EOBPac=; b=xVzL4wk145hJSmdKDIGXP9ixEYXOA8vVO7dznRgrfOFJFkPit/bG0ZswuocHMPJr45 0bA7vnPgvYTwtD4rqKarFMPuQ58NY5Yq6rsOp+nS0KCGcwJdOtFA1H7aTmJQNYoTSx5o 1aqIMM3gz6uz3t6V3IcUiyGtfN8cO5HKJVnXF7vFsT4s8hEMKke8mCWnzgYlYeh+5634 s8WtmMne6cSEwJhGDj7wPy4FXoRM7vUwlaYbbayrVOUD2eb+CfOqZJlBOJO5LHS+iIq4 oL+X4SXC/u2txwF9nOL14Y6e/deGwiquggAc8uBq7KmL9u87sCwNs+CfMvDB4jXObFO5 IMlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=Dh+f9bbX; 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 w135-v6si1276302pff.8.2018.08.28.07.57.44 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=Dh+f9bbX; 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=ttwMQNsa+nr6K2+Si0fY85CCjll5fRpBEwDl7EOBPac=; b=Dh+f9bbXLCApjDEKWa2hER8L3 Wh33eqmk3Ffnt6bAoUzFEs4oUmgW1inUoCZrlcvHSD0A+MnJUSknAuG7Cklv9dGzwb+mgst/bgD3e 80EOMSyChfozNqJpneV9z78JoHRco1iK0qAb6ATO+t4oyEXyTJ8NcVtOhCZTA4WcV1JR7Y8sjMM69 V6nqZ7ydokBhjzPO1QvETxpQeWalEjwUbZvOR0Ug0GLY5ckVhByxE/1m2IyML5bKAYIzU/IFDPIQO QwLhEEpjJ+M7GucHvM5vysuEtwJIeVTdlucLBln4dlufVC4Fz6hPokhetdKy/X8NBI/VjkFCCms9p keoVqD1gA==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fufR8-0003Dk-W6; Tue, 28 Aug 2018 14:57:43 +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 10/10] mm: Convert insert_pfn to vm_fault_t Date: Tue, 28 Aug 2018 07:57:28 -0700 Message-Id: <20180828145728.11873-11-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 convert its errno into a vm_fault_t, so convert it to return a vm_fault_t directly. Signed-off-by: Matthew Wilcox --- mm/memory.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 9fef202b4ea7..368b65390762 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1767,19 +1767,16 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, } EXPORT_SYMBOL(vm_insert_page); -static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, +static vm_fault_t insert_pfn(struct vm_area_struct *vma, unsigned long addr, pfn_t pfn, pgprot_t prot, bool mkwrite) { struct mm_struct *mm = vma->vm_mm; - int retval; pte_t *pte, entry; spinlock_t *ptl; - retval = -ENOMEM; pte = get_locked_pte(mm, addr, &ptl); if (!pte) - goto out; - retval = -EBUSY; + return VM_FAULT_OOM; if (!pte_none(*pte)) { if (mkwrite) { /* @@ -1812,11 +1809,9 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, set_pte_at(mm, addr, pte, entry); update_mmu_cache(vma, addr, pte); /* XXX: why not for insert_page? */ - retval = 0; out_unlock: pte_unmap_unlock(pte, ptl); -out: - return retval; + return VM_FAULT_NOPAGE; } /** @@ -1840,8 +1835,6 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, unsigned long pfn, pgprot_t pgprot) { - int err; - /* * Technically, architectures with pte_special can avoid all these * restrictions (same for remap_pfn_range). However we would like @@ -1862,15 +1855,8 @@ vm_fault_t vmf_insert_pfn_prot(struct vm_area_struct *vma, unsigned long addr, track_pfn_insert(vma, &pgprot, __pfn_to_pfn_t(pfn, PFN_DEV)); - err = insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, + return insert_pfn(vma, addr, __pfn_to_pfn_t(pfn, PFN_DEV), pgprot, false); - - if (err == -ENOMEM) - return VM_FAULT_OOM; - if (err < 0 && err != -EBUSY) - return VM_FAULT_SIGBUS; - - return VM_FAULT_NOPAGE; } EXPORT_SYMBOL(vmf_insert_pfn_prot); @@ -1950,7 +1936,7 @@ static vm_fault_t __vm_insert_mixed(struct vm_area_struct *vma, page = pfn_to_page(pfn_t_to_pfn(pfn)); err = insert_page(vma, addr, page, pgprot); } else { - err = insert_pfn(vma, addr, pfn, pgprot, mkwrite); + return insert_pfn(vma, addr, pfn, pgprot, mkwrite); } if (err == -ENOMEM)