From: Ming Lei <ming.lei@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
linux-block@vger.kernel.org, Keith Busch <kbusch@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Robin Murphy <robin.murphy@arm.com>
Subject: Re: [Regression] b1a000d3b8ec ("block: relax direct io memory alignment")
Date: Wed, 23 Oct 2024 16:14:34 +0800 [thread overview]
Message-ID: <ZxiwaupwAkf1u8VE@fedora> (raw)
In-Reply-To: <20241023061233.GA2612@lst.de>
On Wed, Oct 23, 2024 at 08:12:33AM +0200, Christoph Hellwig wrote:
> On Tue, Oct 22, 2024 at 11:24:31AM +0100, Catalin Marinas wrote:
> > > > We should not allow smaller than cache line alignment on architectures
> > > > that are not cache coherent indeed.
> >
> > Even on architectures that are not fully coherent, the coherency is a
> > property of the device. You may need to somehow pass this information in
> > struct queue_limits if you want it to be optimal.
>
> Well, devices set the queue limits. So this would be a fix in the
> drivers that set the queue limits. SCSI already does this in the
> midlayer code,
I guess it isn't true:
[linux]# cat /sys/block/sda/queue/dma_alignment
3
> so the main places to fix are nvme und ublk.
>
> I cant take care of nvme by copying the scsi pattern.
>
> > That said, the DMA debug code also uses the static L1_CACHE_SHIFT and it
> > will trigger the warning anyway. Some discussion around the DMA API
> > debug came up during the small ARCH_KMALLOC_MINALIGN changes (don't
> > remember it was in private with Robin or on the list). Now kmalloc() can
> > return a small buffer (less than a cache line) that won't be bounced if
> > the device is coherent (see dma_kmalloc_safe()) but the DMA API debug
> > code only checks for direction == DMA_TO_DEVICE, not
> > dev_is_dma_coherent(). For arm64 I did not want to disable small
> > ARCH_KMALLOC_MINALIGN if CONFIG_DMA_API_DEBUG is enabled as this would
> > skew the testing by forcing all allocations to be ARCH_DMA_MINALIGN
> > aligned.
> >
> > Maybe I'm missing something in those checks but I'm surprised that the
> > DMA API debug code doesn't complain about small kmalloc() buffers on x86
> > (which never had any bouncing for this specific case since it's fully
> > coherent). I suspect people just don't enable DMA debugging on x86 for
> > such devices (typically USB drivers have this issue).
>
> I don't think there's too many of these indeed.
Usually it is assumed that it is safe to DMA over kmalloc() buffer...
thanks,
Ming
next prev parent reply other threads:[~2024-10-23 8:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-15 16:40 [Regression] b1a000d3b8ec ("block: relax direct io memory alignment") Ming Lei
2024-10-16 8:04 ` Christoph Hellwig
2024-10-16 8:31 ` Ming Lei
2024-10-16 12:31 ` Christoph Hellwig
2024-10-22 1:21 ` Ming Lei
2024-10-22 7:25 ` Christoph Hellwig
2024-10-22 2:15 ` Jens Axboe
2024-10-22 10:24 ` Catalin Marinas
2024-10-23 0:50 ` Ming Lei
2024-10-23 6:12 ` Christoph Hellwig
2024-10-23 8:14 ` Ming Lei [this message]
2024-10-23 12:23 ` Christoph Hellwig
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=ZxiwaupwAkf1u8VE@fedora \
--to=ming.lei@redhat.com \
--cc=axboe@kernel.dk \
--cc=catalin.marinas@arm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=robin.murphy@arm.com \
/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).