From patchwork Tue Nov 19 17:35:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 11252493 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E2B7E14E5 for ; Tue, 19 Nov 2019 17:49:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A679822319 for ; Tue, 19 Nov 2019 17:49:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A679822319 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D64486B0007; Tue, 19 Nov 2019 12:49:57 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id CEEFA6B0008; Tue, 19 Nov 2019 12:49: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 C04906B000A; Tue, 19 Nov 2019 12:49:57 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0074.hostedemail.com [216.40.44.74]) by kanga.kvack.org (Postfix) with ESMTP id AAFE46B0007 for ; Tue, 19 Nov 2019 12:49:57 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with SMTP id 524BA3ABF for ; Tue, 19 Nov 2019 17:49:57 +0000 (UTC) X-FDA: 76173765234.08.dogs56_73e8b316eca12 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,dan.j.williams@intel.com,:hch@lst.de:linux@armlinux.org.uk:ddutile@redhat.com:stable@vger.kernel.org:m.szyprowski@samsung.com:robin.murphy@arm.com:linux-kernel@vger.kernel.org::dan.j.williams@intel.com,RULES_HIT:30054:30064,0,RBL:134.134.136.20:@intel.com:.lbl8.mailshell.net-62.50.0.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:ft,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: dogs56_73e8b316eca12 X-Filterd-Recvd-Size: 3053 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by imf18.hostedemail.com (Postfix) with ESMTP for ; Tue, 19 Nov 2019 17:49:56 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 09:49:54 -0800 X-IronPort-AV: E=Sophos;i="5.69,218,1571727600"; d="scan'208";a="200430864" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.16]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Nov 2019 09:49:54 -0800 Subject: [PATCH] dma/debug: Fix dma vs cow-page collision detection From: Dan Williams To: hch@lst.de Cc: Russell King , Don Dutile , stable@vger.kernel.org, Marek Szyprowski , Robin Murphy , linux-kernel@vger.kernel.org, linux-mm@kvack.org Date: Tue, 19 Nov 2019 09:35:38 -0800 Message-ID: <157418493888.1639105.6922809760655305210.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.18-3-g996c MIME-Version: 1.0 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: The debug_dma_assert_idle() infrastructure was put in place to catch a data corruption scenario first identified by the now defunct NET_DMA receive offload feature. It caught cases where dma was in flight to a stale page because the dma raced the cpu writing the page, and the cpu write triggered cow_user_page(). However, the dma-debug tracking is overeager and also triggers in cases where the dma device is reading from a page that is also undergoing cow_user_page(). The fix proposed was originally posted in 2016, and Russell reported "Yes, that seems to avoid the warning for me from an initial test", and now Don is also reporting that this fix is addressing a similar false positive report that he is seeing. Link: https://lore.kernel.org/r/CAPcyv4j8fWqwAaX5oCdg5atc+vmp57HoAGT6AfBFwaCiv0RbAQ@mail.gmail.com Reported-by: Russell King Reported-by: Don Dutile Fixes: 0abdd7a81b7e ("dma-debug: introduce debug_dma_assert_idle()") Cc: Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Signed-off-by: Dan Williams --- kernel/dma/debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 099002d84f46..11a6db53d193 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -587,7 +587,7 @@ void debug_dma_assert_idle(struct page *page) } spin_unlock_irqrestore(&radix_lock, flags); - if (!entry) + if (!entry || entry->direction != DMA_FROM_DEVICE) return; cln = to_cacheline_number(entry);