From patchwork Tue Nov 13 05:49:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 10679553 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 AC4A713BB for ; Tue, 13 Nov 2018 05:50:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A7BD2A19B for ; Tue, 13 Nov 2018 05:50:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8BAAB2A1A5; Tue, 13 Nov 2018 05:50:14 +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 17C282A19B for ; Tue, 13 Nov 2018 05:50:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1839C6B0007; Tue, 13 Nov 2018 00:50:13 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 133846B0008; Tue, 13 Nov 2018 00:50:13 -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 F3C676B000A; Tue, 13 Nov 2018 00:50:12 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id ADD006B0007 for ; Tue, 13 Nov 2018 00:50:12 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id s22so7359668pgv.8 for ; Mon, 12 Nov 2018 21:50:12 -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=wTosEECzgpOVxDYCqgqKI7W7oqGjn2m6YWtkl7ajxHI=; b=DQpL4seaNFHAdklblXXRW436Xunw944EfQ+hdPk+JL0rm+SzivFGlD9ruXNdBK38bn QqUIE2SjIYQ/qgftOVXzZC4NsoHyuMoq5dFGleVdr3FXZ6USg20ifuoB8treGyoe7aFM dfi85KVZJwR3DS4RRy+cKQ5eBI6DlMXgEgrUlNtT1SsGW2irTRZ+wlYhXrkQM1P3M0hE wXpu7Ehcd6hBR+Jw8/75wEwwyaP7mp6sEsYfB0ptlZl+KvABO/aNLugQ6RbhMA9rGlx+ KcjbcQD+nGD9Y8zJvBgpAjSHg7EKwlxG1cKSt7uErE1X1yNKStGadVqQScJ4u4m7Wjni h9MQ== X-Gm-Message-State: AGRZ1gJlI8oVf1Cebdp0zyvBbEWQ9rqEGM3g0pLTwVXih9Vpr1nSwG4g b4/qD5rHxijd2bgIyuQPv9J6SMVlG1MauROR7pIIqwB4j8j5nE2lrHFfsUNaKE2nsLOeYXWrFpS mjtFNhi2Dkh5GXtdAKg2wcEsdsQFLRVPuqU1Jom5bl53ykGBdea7v6Gjl2kNNEEs6Pw== X-Received: by 2002:a17:902:5e4:: with SMTP id f91-v6mr3765002plf.75.1542088212298; Mon, 12 Nov 2018 21:50:12 -0800 (PST) X-Google-Smtp-Source: AJdET5dI0rWQL9rtC4SKpvCNVGZ8m9mtVY3lhxmOzMD39Vo4bOxLsPd/6I9GNk0CW9yc+bl9JIm5 X-Received: by 2002:a17:902:5e4:: with SMTP id f91-v6mr3764966plf.75.1542088211464; Mon, 12 Nov 2018 21:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542088211; cv=none; d=google.com; s=arc-20160816; b=odshe/q8t7hAEHOa0yvV/NatTMFcsVD+f6q6Bcn8fm6bdaiQHq6JKyoGgl/SQjN6N4 ifIScQJI8wbK91VN4+r3C+RmVNn+iFx435V9MPJ+AVUwk4vuz71ZTGBvAbGfgDtqv6Lk rMyDs/BhZypNAzfut6zj3aszw/TxPKHo8o0I3UdGOpv3gPv32uCB7nQwFwu9yVzbyIIR y7+F3bJnicrTMPKPAz7A6dkbIDVsmuYBo7HMTOfJz1YYwIlGYarKsCQXyXDHPYjOTuoH Qjr0/0EB9m5aRbYSuQV7C3GxYPxni4KCMRJeER8a/sJeR/oAA953WSWMw5PvQlnZtCua MkJA== 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=wTosEECzgpOVxDYCqgqKI7W7oqGjn2m6YWtkl7ajxHI=; b=HMTQiJIS8bnyPoHfLuD9DU4l27i8WoZPtOdzSvzanqH7nNtrLOREieiOxUMRQNIggq NcGXRV9ouVPDriGthEB0FbT3fLAwEG2Wuskj5Fk9EJHoTV5jWuTLUjmwgTqYuE3i/CCn 20MgneqT+eFZPHh819OeMZU0jyttH1MWQ8/nBW+9+u38LfcT40Idon6Na3lyeEezgFOQ m3h12BIJ7tkOO441TuQscuByrK0FhgXtR4Tdyap4JFtD0zf4gMIiM4TtAz/FA9Vt131y 2an0RaPmMp/uzlhza+YrcpfCNBV5f1tcNIutPiWRKOwpWhYLYEuISJBaI64EeQ8qlzUT PsOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=XdVSwxaH; 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 k11si19315938pgf.213.2018.11.12.21.50.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Nov 2018 21:50:11 -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=XdVSwxaH; 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 DAE5C21780; Tue, 13 Nov 2018 05:50:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542088211; bh=nuKSvICqPWuXkdr14PpQ2PIFqBt6SzgOfjffwNRA+J0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XdVSwxaHi86+9MEmaSH7gGzA6x1fc6JUMEhnnEdxZoIUnoXqA5dVdOzazIECWPIv8 lA60+PmQDBDtD28gXYpcrQJKnAbQEobYDiDKv5AbH+iUNVqU8+uFSCidomW4P4Y31c 8hB6e4V2MevkvptlFyRLR7Ef1DBd0bHNRJbBqNwg= 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.19 13/44] mm: Fix warning in insert_pfn() Date: Tue, 13 Nov 2018 00:49:19 -0500 Message-Id: <20181113054950.77898-13-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181113054950.77898-1-sashal@kernel.org> References: <20181113054950.77898-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 c467102a5cbc..d988bae46479 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1787,10 +1787,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