From patchwork Fri Aug 24 15:45:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 10575495 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 AEE6517DF for ; Fri, 24 Aug 2018 15:45:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0A4C2B4D9 for ; Fri, 24 Aug 2018 15:45:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E9FD2B736; Fri, 24 Aug 2018 15:45:50 +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.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable 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 3E6F82B4D9 for ; Fri, 24 Aug 2018 15:45:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3815D6B3041; Fri, 24 Aug 2018 11:45:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 307DC6B3044; Fri, 24 Aug 2018 11:45:49 -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 1A9A96B3045; Fri, 24 Aug 2018 11:45:49 -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 CCB656B3041 for ; Fri, 24 Aug 2018 11:45:48 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id c8-v6so6360840pfn.2 for ; Fri, 24 Aug 2018 08:45:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id; bh=wUcH4rSBEckFBzp9TlVT9PmS9qcToYAYEsYEe+ftmJ4=; b=D/xNGq6qPrdwDXfEhoL7xEWXsWrAKQip/Adh0jd3bPPwLWQGWawmmga1gQzwOo5FSm Wl6/wgzJtZJBj95sVsYlZIm41ysWKpcBiOmLEazsSo88yt2dttRCov2LwhZF8WFzLTWg N3YtUtixVL00MS/fU1T8UttnskJXkfzZJp45xfm9gwCGBvmRnyaD+gyKWNgiIsSsOJ6e T9frlLHlItLVYDswHJBF9RXr2lIZktKRa7IXPeTZEYje8SPMYd9M5fAajQ6iXTXpxS9a rGQO9aG8VMtAYx8h1SRloNF9YKLMsDlFGaeucoZsOgJIE1PWX34nC/DyK6kUIp/IXbsL leaA== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz X-Gm-Message-State: APzg51DTh0tdEkfLxlDP+XtYbsoCe+sY3TkgAuqgfnkfjZ1xFlTLLgj9 TGY6M5w10nSyv93Ot3x/JPDMPMw49aeldM14CVWHZLRyPFsYaP6Fy7RwWVYoNSOmUIh5Vd8RoEl UEh+XzaKyg6cw4V3WluhoGNXrzaWkusiJuE7DKzNaQg9vnfOEWnki6OOYYgUxzNgixg== X-Received: by 2002:a62:1192:: with SMTP id 18-v6mr2615770pfr.54.1535125548510; Fri, 24 Aug 2018 08:45:48 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYbz1rA/XNMiAMpfZ20xkAbHr2xnlGh8uLiMNlfOa/my8WwQLBY0f63mJSf6d5oHo2eBlAz X-Received: by 2002:a62:1192:: with SMTP id 18-v6mr2615732pfr.54.1535125547798; Fri, 24 Aug 2018 08:45:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535125547; cv=none; d=google.com; s=arc-20160816; b=GtiSgChWRlzF8iqperVlV/FhMd6dY4GAZfC2SjhhPR2BY9a9wZW7hqdVEZ7ifPf35m 5aszLrl5qGu/2/4wjcOocqQbyGWx+9tD9TD68RwGLxdXBzrDvNyxPvPz+HzKSc+yYYHl OgXN2i2tIqTcHsIyZP1I74Elq/yU/WNqEJK4fwFwK3jcwzw+PK1AEIPbEe4p2VmzLXOR zPrSqhDptB7pQ/cZFLCJXlRVOJPw2fwusaRTtKlanT8miJ6Sb8VPUF+4zbUvLhSmPuTy UAIIUMECAa1F2i8KUax5LWDPj4cJsbgx9sHfbejChyq8EB0GtcpN7oTUaSmwX2k4PQEV +J8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=wUcH4rSBEckFBzp9TlVT9PmS9qcToYAYEsYEe+ftmJ4=; b=cY8tYUbMQCVEX3j/kojwHpIdiZBrUUfRIxXf6OMtWxPIMGJBv1e/ito610cpxR1bq7 fuLH0rJrTodUV0WZEbzcurKvlP0vWPjwgn1vC14ShXNxUiA+vd/HCFnZYrs/Z3B0rAZf qNI1Kupja7fDIvP6hutlj0ckIQGcRaCSE6Ht3jjLxItWa4cw1nmC3zcfWaK0RwT6HvwC JewqUBMXaZYrIDJOOxnAHOIZTUaZHvjl44grrBuzbsK2zUWl5FqMsPaPKTRYiYgX/ZXC bbs9SS8z+vCAH1Qlmi00QHKEcS6nHNwZAI0+JTswsGV8ncUtjS3IvqX1aaJqe3SZpEf4 tnUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz Received: from mx1.suse.de (mx2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id w16-v6si6642430ply.462.2018.08.24.08.45.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Aug 2018 08:45:47 -0700 (PDT) Received-SPF: pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) client-ip=195.135.220.15; Authentication-Results: mx.google.com; spf=pass (google.com: domain of jack@suse.cz designates 195.135.220.15 as permitted sender) smtp.mailfrom=jack@suse.cz X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 4984AAF68; Fri, 24 Aug 2018 15:45:46 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id 1D4391E3D86; Fri, 24 Aug 2018 17:45:46 +0200 (CEST) From: Jan Kara To: Cc: , Ross Zwisler , Dan Williams , , Dave Jiang , Jan Kara Subject: [PATCH] mm: Fix warning in insert_pfn() Date: Fri, 24 Aug 2018 17:45:42 +0200 Message-Id: <20180824154542.26872-1-jack@suse.cz> X-Mailer: git-send-email 2.16.4 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 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. Signed-off-by: Jan Kara --- mm/memory.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 83aef222f11b..e82cd2125d72 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