All of lore.kernel.org
 help / color / mirror / Atom feed
From: Keith Busch <kbusch@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Keith Busch <kbusch@meta.com>,
	linux-block@vger.kernel.org, axboe@kernel.dk,
	Sebastian Ott <sebott@redhat.com>
Subject: Re: [PATCH] blk-mq-dma: always initialize dma state
Date: Wed, 10 Dec 2025 16:06:57 +0900	[thread overview]
Message-ID: <aTkcEeRFPHuN8d9f@kbusch-mbp> (raw)
In-Reply-To: <20251210065407.GA650@lst.de>

On Wed, Dec 10, 2025 at 07:54:07AM +0100, Christoph Hellwig wrote:
> On Tue, Dec 09, 2025 at 10:49:15PM -0800, Keith Busch wrote:
> > -	if (blk_can_dma_map_iova(req, dma_dev) &&
> > -	    dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
> > +	if (!blk_can_dma_map_iova(req, dma_dev))
> > +		memset(state, 0, sizeof(*state));
> > +	else if (dma_iova_try_alloc(dma_dev, state, vec.paddr, total_len))
> >  		return blk_rq_dma_map_iova(req, dma_dev, state, iter, &vec);
> 
> What about just doing the memset unconditionally?  It's just two
> 64-bit fields so no real overhead, and it gives us a clean slate that
> avoid introducing other bugs later on.

I didn't do that is because dma_iova_try_alloc() also does that, so it'd
be two repeated and unnecessary memset's on the same address. That feels
undesirable no matter how small the struct is. I could remove the memset
in dma_iova_try_alloc instead and make the caller initialize it. There
are only two existing users of the API, so not a big deal to change it.

  reply	other threads:[~2025-12-10  7:07 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10  6:49 [PATCH] blk-mq-dma: always initialize dma state Keith Busch
2025-12-10  6:54 ` Christoph Hellwig
2025-12-10  7:06   ` Keith Busch [this message]
2025-12-10  8:25     ` Christoph Hellwig
2025-12-10 10:38 ` Sebastian Ott

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=aTkcEeRFPHuN8d9f@kbusch-mbp \
    --to=kbusch@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@meta.com \
    --cc=linux-block@vger.kernel.org \
    --cc=sebott@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.