public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Robin Murphy <robin.murphy@arm.com>
To: Alexander Lobakin <aleksander.lobakin@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Christoph Hellwig <hch@lst.de>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Magnus Karlsson <magnus.karlsson@intel.com>,
	Maciej Fijalkowski <maciej.fijalkowski@intel.com>,
	Alexander Duyck <alexanderduyck@fb.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 1/7] dma: compile-out DMA sync op calls when not used
Date: Mon, 26 Feb 2024 16:27:16 +0000	[thread overview]
Message-ID: <94043c84-0b03-491a-9dd4-2a792d33bca0@arm.com> (raw)
In-Reply-To: <6b003271-cd83-4091-89c6-bb37da62afef@intel.com>

On 19/02/2024 12:53 pm, Alexander Lobakin wrote:
> From: Robin Murphy <robin.murphy@arm.com>
> Date: Wed, 14 Feb 2024 17:20:50 +0000
> 
>> On 2024-02-14 4:21 pm, Alexander Lobakin wrote:
> 
> [...]
> 
>>> -static inline void dma_sync_single_for_cpu(struct device *dev,
>>> dma_addr_t addr,
>>> -        size_t size, enum dma_data_direction dir)
>>> +static inline void __dma_sync_single_for_cpu(struct device *dev,
>>> +        dma_addr_t addr, size_t size, enum dma_data_direction dir)
>>
>> To me it would feel more logical to put all the wrappers inside the
>> #ifdef CONFIG_HAS_DMA and not touch these stubs at all (what does it
>> mean to skip an inline no-op?). Or in fact, if dma_skip_sync() is
>> constant false for !HAS_DMA, then we could also just make the external
>> function declarations unconditional and remove the stubs. Not a critical
>> matter though, and I defer to whatever Christoph thinks is most
>> maintainable.
> 
> It's done like that due to that I'm adding a runtime check in the second
> patch. I don't feel like touching this twice makes sense.

Huh? Why would anything need touching twice? All I'm saying is that it's 
pretty pointless to add any invocations of dma_skip_sync() in !HAS_DMA 
paths where we already know the whole API is stubbed out anyway. The 
only cases which are worth differentiating here are HAS_DMA + 
DMA_NEED_SYNC vs. HAS_DMA + !DMA_NEED_SYNC (with the subsequent runtime 
check then just subdividing the former).

> 
> [...]
> 
>>> @@ -348,18 +348,72 @@ static inline void dma_unmap_single_attrs(struct
>>> device *dev, dma_addr_t addr,
>>>        return dma_unmap_page_attrs(dev, addr, size, dir, attrs);
>>>    }
>>>    +static inline void __dma_sync_single_range_for_cpu(struct device *dev,
>>> +        dma_addr_t addr, unsigned long offset, size_t size,
>>> +        enum dma_data_direction dir)
>>> +{
>>> +    __dma_sync_single_for_cpu(dev, addr + offset, size, dir);
>>> +}
>>> +
>>> +static inline void __dma_sync_single_range_for_device(struct device
>>> *dev,
>>> +        dma_addr_t addr, unsigned long offset, size_t size,
>>> +        enum dma_data_direction dir)
>>> +{
>>> +    __dma_sync_single_for_device(dev, addr + offset, size, dir);
>>> +}
>>
>> There is no need to introduce these two.
> 
> I already replied to this in the previous thread. Some subsys may want
> to check for the shortcut earlier to avoid call ladders of their own
> functions. See patch 6 for example where I use this one.

Ugh, no. If the page pool code wants to be clever poking around and 
sidestepping parts of the documented API, it can flippin' well open-code 
a single addition to call __dma_sync_single_for_device() directly 
itself. I'm not at all keen on having to maintain "common" APIs for such 
niche trickery.

Thanks,
Robin.

  reply	other threads:[~2024-02-26 16:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 16:21 [PATCH net-next v3 0/7] dma: skip calling no-op sync ops when possible Alexander Lobakin
2024-02-14 16:21 ` [PATCH net-next v3 1/7] dma: compile-out DMA sync op calls when not used Alexander Lobakin
2024-02-14 17:20   ` Robin Murphy
2024-02-15  5:06     ` Christoph Hellwig
2024-02-19 12:53     ` Alexander Lobakin
2024-02-26 16:27       ` Robin Murphy [this message]
2024-02-14 18:09   ` Robin Murphy
2024-02-15  5:06     ` Christoph Hellwig
2024-02-14 16:21 ` [PATCH net-next v3 2/7] dma: avoid redundant calls for sync operations Alexander Lobakin
2024-02-14 17:55   ` Robin Murphy
2024-02-15  5:08     ` Christoph Hellwig
2024-02-15 11:36       ` Robin Murphy
2024-02-19 12:49     ` Alexander Lobakin
2024-02-26 15:45       ` Robin Murphy
2024-02-14 16:21 ` [PATCH net-next v3 3/7] iommu/dma: avoid expensive indirect " Alexander Lobakin
2024-02-14 17:58   ` Robin Murphy
2024-02-14 16:21 ` [PATCH net-next v3 4/7] page_pool: make sure frag API fields don't span between cachelines Alexander Lobakin
2024-02-14 16:21 ` [PATCH net-next v3 5/7] page_pool: don't use driver-set flags field directly Alexander Lobakin
2024-02-14 16:22 ` [PATCH net-next v3 6/7] page_pool: check for DMA sync shortcut earlier Alexander Lobakin
2024-02-14 16:22 ` [PATCH net-next v3 7/7] xsk: use generic DMA sync shortcut instead of a custom one Alexander Lobakin

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=94043c84-0b03-491a-9dd4-2a792d33bca0@arm.com \
    --to=robin.murphy@arm.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=alexanderduyck@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=maciej.fijalkowski@intel.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rafael@kernel.org \
    --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