From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Christoph Hellwig <hch@lst.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
Mark Rutland <mark.rutland@arm.com>,
Robin Murphy <robin.murphy@arm.com>,
Ard Biesheuvel <ardb@kernel.org>
Subject: Re: [PATCH] arm64: dma: Drop cache invalidation from arch_dma_prep_coherent()
Date: Wed, 7 Sep 2022 15:10:35 +0100 [thread overview]
Message-ID: <YximWx/g2FjA/Ypl@shell.armlinux.org.uk> (raw)
In-Reply-To: <20220907090434.GB30704@lst.de>
On Wed, Sep 07, 2022 at 11:04:34AM +0200, Christoph Hellwig wrote:
> On Wed, Aug 24, 2022 at 11:00:02PM +0100, Catalin Marinas wrote:
> > (I was wondering why not just invalidate without clean but it could be
> > that the allocated memory was zeroed and we want that to make it to the
> > PoC)
>
> The memory is zerod after arch_dma_prep_coherent. So a pure invalidate
> seems like the right thing to do here.
My thoughts on Christoph's comment...
That seems backwards to me.
If we allocate memory, clean (and maybe invalidate) the cache, and then
zero the memory _after_ the clean, then couldn't we be creating dirty
cache lines. There are caches out there that are write-allocate, which
means that by writing zeros to memory, you drag cache lines back into
the cache. These dirty cache lines could then be written back at some
random time later, corrupting the data that has been DMA'd to the
buffer or placed there via the uncached mapping (if the architecture
doesn't hit those cache lines.)
It has to be:
- allocate
- zero
- deal with the cache
not:
- allocate
- deal with the cache
- zero
Moreover, if one does:
- allocate
- invalidate
- zero
- clean+(invalidate?)
then aren't we making the zero operation potentially more expensive than
if we had cache lines already there - I'm thinking there about a
no-write-allocate cache here. Those cache lines could have been used to
buffer the zeroing writes and then written out later. Depending on the
architecture, having cached lines may mean that write merging happens,
meaning writebacks to memory occur in larger chunks.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-09-07 14:11 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-23 12:21 [PATCH] arm64: dma: Drop cache invalidation from arch_dma_prep_coherent() Will Deacon
2022-08-24 9:58 ` Ard Biesheuvel
2022-08-24 11:23 ` Will Deacon
2022-08-24 11:49 ` Ard Biesheuvel
2022-08-24 22:00 ` Catalin Marinas
2022-09-07 9:04 ` Christoph Hellwig
2022-09-07 14:10 ` Russell King (Oracle) [this message]
2022-09-07 14:14 ` Christoph Hellwig
2022-09-07 14:15 ` Russell King (Oracle)
2022-09-07 9:03 ` Christoph Hellwig
2022-09-07 9:27 ` Robin Murphy
2022-09-07 16:25 ` Will Deacon
2022-09-07 17:50 ` Robin Murphy
2022-09-08 10:32 ` Catalin Marinas
2022-09-08 11:32 ` Robin Murphy
2022-09-08 13:02 ` Catalin Marinas
2022-09-08 13:27 ` Catalin Marinas
2022-09-08 13:32 ` Will Deacon
2022-09-08 15:49 ` Catalin Marinas
2022-09-07 16:28 ` Will Deacon
2022-09-22 20:02 ` Catalin Marinas
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=YximWx/g2FjA/Ypl@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=hch@lst.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=mark.rutland@arm.com \
--cc=robin.murphy@arm.com \
--cc=will@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;
as well as URLs for NNTP newsgroup(s).