Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751934AbcJJL62 (ORCPT ); Mon, 10 Oct 2016 07:58:28 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:35224 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbcJJL61 (ORCPT ); Mon, 10 Oct 2016 07:58:27 -0400 Date: Mon, 10 Oct 2016 07:57:31 -0400 (EDT) Message-Id: <20161010.075731.2449861168238706.davem@davemloft.net> To: nikita.yoush@cogentembedded.com Cc: jeffrey.t.kirsher@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, cphealy@gmail.com Subject: Re: igb driver can cause cache invalidation of non-owned memory? From: David Miller In-Reply-To: <10474d19-df1a-3b09-917e-70659be3a56c@cogentembedded.com> References: <0b57cbe2-84f7-6c0a-904a-d166571234b5@cogentembedded.com> <20161010.050125.1981283393312167625.davem@davemloft.net> <10474d19-df1a-3b09-917e-70659be3a56c@cogentembedded.com> X-Mailer: Mew version 6.7 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 10 Oct 2016 04:57:39 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1055 Lines: 32 From: Nikita Yushchenko Date: Mon, 10 Oct 2016 12:51:28 +0300 > Hmm... I'm not about device writing to memory. This absolutely is about whether the device wrote into the area or not. > Sequence in igb driver is: > > dma_map(full_page) > > sync_to_cpu(half_page); > skb_add_rx_frag(skb, half_page); > napi_gro_receive(skb); > ... > dma_unmap(full_page) > > What I'm concerned about is - same area is first passed up to network > stack, and _later_ dma_unmap()ed. Is this indeed safe? dma_unmap() should never write anything unless the device has meanwhile written to that chunk of memory. If the device made no intervening writes into the area, dma_unmap() should not cause any data to be written to that area, period. In your example above, consider the case where the device never writes into the memory area after sync_to_cpu(). In that case there is nothing that dma_unmap() can possibly write. All the data has been synced, and no device writes into the memory are have occurred.