From patchwork Tue Nov 13 05:51:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10679607 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 90A4513BB for ; Tue, 13 Nov 2018 05:52:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80E9B2A3B1 for ; Tue, 13 Nov 2018 05:52:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E7A52A3B9; Tue, 13 Nov 2018 05:52:08 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 0037F2A3B1 for ; Tue, 13 Nov 2018 05:52:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 700276B0285; Tue, 13 Nov 2018 00:51:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6D7DD6B0286; Tue, 13 Nov 2018 00:51:57 -0500 (EST) 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 59E616B0287; Tue, 13 Nov 2018 00:51:57 -0500 (EST) 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 139766B0285 for ; Tue, 13 Nov 2018 00:51:57 -0500 (EST) Received: by mail-pf1-f197.google.com with SMTP id i19-v6so9561377pfi.21 for ; Mon, 12 Nov 2018 21:51:57 -0800 (PST) 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=/uJLzkGdLWM/XWSM2u3mmnrZlh5dEIkBVnU3pTKL7fM=; b=gEWpn4QnjlCgFlFIHeFkPfcN2LrNfQ9iXDZ/pqVgGYTkdh8UYGZLU1v31z8/H4t38/ 7jP/qxmwaO5S/y0BRAV5sHbS7Ncphf7yOpXCz44cmG6qLPL17O3WBdtX2Tx24icL8MuZ U15VaW0vdbpXIgZmz8JqC3GNRc3+NO2dAhJHhnznuSKfSv2WLZLajNqg60uvuBkrsEko Lx3TyFQ+ucEWGlL8vkFheoDLXLuyuY2vzKF76tJjhpNeaChQQR277LEppIvgSmQxkyBG Bk1B+P67x0GHrStQ/N7VvV0X9WfbJrLH4jjkwzTCIxw93XdNwLspCA3j8WbKPQ2wexNB 13fw== X-Gm-Message-State: AGRZ1gIOkNZwrN6CRM+43Hqh752ZD8i6VMaz8QdK6jHgttbSBZR/58mO vB/Sv5nnV2fOmW7qWlM1EO5/ddyFZzgiv7GvTrezWAfiDjrniVpiW3XH5Un2qEekQOAeIEWcP6c 23oWMGfWBb6nCiNhvhRjsuEXf9e3NnHSHfiPkrW8wx7b+BkLXluFWeIYszTAS1ca/Xw== X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr3828751pfi.43.1542088316767; Mon, 12 Nov 2018 21:51:56 -0800 (PST) X-Google-Smtp-Source: AJdET5fsIjasKCF4Vj67yGDgdEQl6zH8AJ+Vkj3y6l6KQ9PjJ/+FhAGc4vWbH+7drGaBhLCm+4kl X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr3828719pfi.43.1542088315915; Mon, 12 Nov 2018 21:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088315; cv=none; d=google.com; s=arc-20160816; b=OMEVIx69UJ0c0vklO6ilq+cuCcPH69s4p6DJTwDkVk8s8ccmAb6I6CfS2wRPKKBzKQ JgnA6GsnH18OUibVTq4sVd6v0aSWAGQluPfXLf8+XjokxFu/WBt8atw/eyXMS469oNfj ln4sAl5mWslkkGwWJGvLvNyvIWEjHSvdF+mAT4cZDJCpxxsBBG9ixItnaRXQAQMe1XAO xqka7STKIvMh4j0jDJJhRQNbjA3trgRT0VUQM0TwOitpeJGJ7hrTD5b3Kir5hlyukfh/ 30xdccYeL25JX6Uh2tJU9au5tBGC6Pm9poo5q+QIXGcfZmgmMDekKBIv3BQGiF/ljG4J 2vWA== 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; bh=/uJLzkGdLWM/XWSM2u3mmnrZlh5dEIkBVnU3pTKL7fM=; b=rCeKtP34O9Z+DQ6fuX9t0GtSr1eLgti5Z/uam6I9BMwOvu3LvLYrRaeJEUc7d/Hqqv gDDJ3IgDNB32Uf+L424a9T0thV855UQ5lwOeT6uwel2J7c7egDZmymO+0+9/h3+d2smk F0CPEpQivqeXp5JaJt1/cMQNc/VkCB0uPVyfALhVMJ7SrRCI370EYQXaTqYf+riP6pbc jgq1XFyxwEtXKriwIUMW0HRV+Zhp86BWfoJhOjV0MvTX+2q3w9XUEPkuK7yoT8Bxumir 4hLjJQO47O0X+/iqwKSJz6yzreOMLyN/fS3KpKA3n/dkEkl0FRmxVBOWPWNcJDHvy9H/ TWNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="BEz873R/"; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from mail.kernel.org (mail.kernel.org. [198.145.29.99]) by mx.google.com with ESMTPS id p1-v6si18209903pfa.120.2018.11.12.21.51.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 21:51:55 -0800 (PST) Received-SPF: pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) client-ip=198.145.29.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="BEz873R/"; spf=pass (google.com: domain of sashal@kernel.org designates 198.145.29.99 as permitted sender) smtp.mailfrom=sashal@kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sasha-vm.mshome.net (unknown [64.114.255.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 66F282250E; Tue, 13 Nov 2018 05:51:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088315; bh=qvhnOLe0Amh57SirA8Nn66irwBqaiSvMQYW06ao7ULA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEz873R/l1uWUV6t4y/pVwd/icU39bD9HAyo7KIRzsoLNrgYJNUFjUYaO+TjOAiG9 45CkFS0ryv/gEbbbd9E7y+my1m6ifBjCw/4jjVMWmDZ0bMv4r2V5B7bXS7MBpxPsRm cR33vnPlVDn59tC5QAjOyi1hlqSSfRh68UgCAqw8= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jan Kara , Ross Zwisler , Dan Williams , Dave Jiang , Andrew Morton , Linus Torvalds , Sasha Levin , linux-mm@kvack.org Subject: [PATCH AUTOSEL 4.14 07/26] mm: Fix warning in insert_pfn() Date: Tue, 13 Nov 2018 00:51:31 -0500 Message-Id: <20181113055150.78773-7-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113055150.78773-1-sashal@kernel.org> References: <20181113055150.78773-1-sashal@kernel.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 From: Jan Kara [ Upstream commit f2c57d91b0d96aa13ccff4e3b178038f17b00658 ] In DAX mode a write pagefault can race with write(2) in the following way: CPU0 CPU1 write fault for mapped zero page (hole) dax_iomap_rw() iomap_apply() xfs_file_iomap_begin() - allocates blocks dax_iomap_actor() invalidate_inode_pages2_range() - invalidates radix tree entries in given range dax_iomap_pte_fault() grab_mapping_entry() - no entry found, creates empty ... xfs_file_iomap_begin() - finds already allocated block ... vmf_insert_mixed_mkwrite() - WARNs and does nothing because there is still zero page mapped in PTE unmap_mapping_pages() This race results in WARN_ON from insert_pfn() and is occasionally triggered by fstest generic/344. Note that the race is otherwise harmless as before write(2) on CPU0 is finished, we will invalidate page tables properly and thus user of mmap will see modified data from write(2) from that point on. So just restrict the warning only to the case when the PFN in PTE is not zero page. Link: http://lkml.kernel.org/r/20180824154542.26872-1-jack@suse.cz Signed-off-by: Jan Kara Reviewed-by: Andrew Morton Cc: Ross Zwisler Cc: Dan Williams Cc: Dave Jiang Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/memory.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 93d5d324904b..9c0172a4d9bf 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1804,10 +1804,15 @@ static int insert_pfn(struct vm_area_struct *vma, unsigned long addr, * in may not match the PFN we have mapped if the * mapped PFN is a writeable COW page. In the mkwrite * case we are creating a writable PTE for a shared - * mapping and we expect the PFNs to match. + * mapping and we expect the PFNs to match. If they + * don't match, we are likely racing with block + * allocation and mapping invalidation so just skip the + * update. */ - if (WARN_ON_ONCE(pte_pfn(*pte) != pfn_t_to_pfn(pfn))) + if (pte_pfn(*pte) != pfn_t_to_pfn(pfn)) { + WARN_ON_ONCE(!is_zero_pfn(pte_pfn(*pte))); goto out_unlock; + } entry = *pte; goto out_mkwrite; } else