Netdev List
 help / color / mirror / Atom feed
From: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
To: Alexander Duyck <alexander.duyck@gmail.com>
Cc: David Laight <David.Laight@aculab.com>,
	Eric Dumazet <edumazet@google.com>,
	David Miller <davem@davemloft.net>,
	Jeff Kirsher <jeffrey.t.kirsher@intel.com>,
	intel-wired-lan <intel-wired-lan@lists.osuosl.org>,
	Netdev <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Chris Healy <cphealy@gmail.com>
Subject: Re: igb driver can cause cache invalidation of non-owned memory?
Date: Wed, 12 Oct 2016 21:12:39 +0300	[thread overview]
Message-ID: <d34b7175-1024-8cc9-d422-d9f75f56c069@cogentembedded.com> (raw)
In-Reply-To: <CAKgT0UdqwpjP0b4knt2d4DqS1Z9dR+vg-smkgBTZDeACGGdx=Q@mail.gmail.com>

> It would make more sense to update the DMA API for
> __dma_page_cpu_to_dev on ARM so that you don't invalidate the cache if
> the direction is DMA_FROM_DEVICE.

No, in generic case it's unsafe.

If CPU issued a write to a location, and sometime later that location is
used as DMA buffer, there is danger that write is still in cache only,
and writeback is pending. Later this writeback can overwrite data
written to memory via DMA, causing corruption.


> The point I was trying to make is that you are invalidating the cache
> in both the sync_for_device and sync_for_cpu.  Do you really need that
> for ARM or do you need to perform the invalidation on sync_for_device
> if that may be pushed out anyway?  If you aren't running with with
> speculative look-ups do you even need the invalidation in
> sync_for_cpu?

I'm not lowlevel arm guru and I don't know for sure. Probably another
CPU core can be accessing locations neighbor page, causing specilative
load of locations in DMA page.


> Changing the driver code for this won't necessarily work on all
> architectures, and on top of it we have some changes planned which
> will end up making the pages writable in the future to support the
> ongoing XDP effort.  That is one of the reasons why I would not be
> okay with changing the driver to make this work.

Well I was not really serious about removing that sync_for_device() in
mainline :)   Although >20% throughput win that this provides is
impressive...

But what about doing something safer, e.g. adding a bit of tracking and
only sync_for_device() what was previously sync_for_cpu()ed?  Will you
accept that?

Nikita

  reply	other threads:[~2016-10-12 18:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-10  8:52 igb driver can cause cache invalidation of non-owned memory? Nikita Yushchenko
2016-10-10  9:01 ` David Miller
2016-10-10  9:51   ` Nikita Yushchenko
2016-10-10 11:57     ` David Miller
2016-10-10 12:27       ` Nikita Yushchenko
2016-10-10 12:31         ` Nikita Yushchenko
2016-10-10 15:11         ` Alexander Duyck
2016-10-10 17:00           ` Nikita Yushchenko
2016-10-10 17:38             ` Alexander Duyck
2016-10-12  6:55               ` Nikita Yushchenko
2016-10-12 15:32                 ` Alexander Duyck
2016-10-12 16:03                   ` David Laight
2016-10-12 16:11                     ` Nikita Yushchenko
2016-10-12 17:56                       ` Alexander Duyck
2016-10-12 18:12                         ` Nikita Yushchenko [this message]
2016-10-12 18:30                           ` Alexander Duyck
2016-10-13 10:39                             ` David Laight
2016-10-13 11:00                             ` Nikita Yushchenko
2016-10-13 20:32                               ` Alexander Duyck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d34b7175-1024-8cc9-d422-d9f75f56c069@cogentembedded.com \
    --to=nikita.yoush@cogentembedded.com \
    --cc=David.Laight@aculab.com \
    --cc=alexander.duyck@gmail.com \
    --cc=cphealy@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=jeffrey.t.kirsher@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox