linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat
@ 2017-07-24 17:29 ` Robin Murphy
  2017-08-01  7:58   ` Marek Szyprowski
  2017-08-25 14:56   ` Christoph Hellwig
  0 siblings, 2 replies; 3+ messages in thread
From: Robin Murphy @ 2017-07-24 17:29 UTC (permalink / raw)
  To: hch, m.szyprowski; +Cc: linux-kernel

Thanks to the nested inlining, all drivers correctly calling
dma_mapping_error() after a mapping a page or single buffer generate two
calls to get_arch_dma_ops() per callsite, which all adds up to a fair
old chunk of useless code, e.g. ~3KB for an arm64 defconfig plus extras:

   text	   data	    bss	    dec	    hex	filename
13051391	1503898	 327768	14883057	 e318f1	vmlinux.o.old
13050751	1503898	 327768	14882417	 e31671	vmlinux.o.new

Give the compiler a hand by making it clear we want the same ops.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
---
 include/linux/dma-mapping.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
index 843ab866e0f4..239e53d12ee8 100644
--- a/include/linux/dma-mapping.h
+++ b/include/linux/dma-mapping.h
@@ -541,10 +541,11 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
 
 static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 {
-	debug_dma_mapping_error(dev, dma_addr);
+	const struct dma_map_ops *ops = get_dma_ops(dev);
 
-	if (get_dma_ops(dev)->mapping_error)
-		return get_dma_ops(dev)->mapping_error(dev, dma_addr);
+	debug_dma_mapping_error(dev, dma_addr);
+	if (ops->mapping_error)
+		return ops->mapping_error(dev, dma_addr);
 	return 0;
 }
 
-- 
2.12.2.dirty

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat
  2017-07-24 17:29 ` [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat Robin Murphy
@ 2017-08-01  7:58   ` Marek Szyprowski
  2017-08-25 14:56   ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Szyprowski @ 2017-08-01  7:58 UTC (permalink / raw)
  To: Robin Murphy, hch; +Cc: linux-kernel

Hi Robin,

On 2017-07-24 19:29, Robin Murphy wrote:
> Thanks to the nested inlining, all drivers correctly calling
> dma_mapping_error() after a mapping a page or single buffer generate two
> calls to get_arch_dma_ops() per callsite, which all adds up to a fair
> old chunk of useless code, e.g. ~3KB for an arm64 defconfig plus extras:
>
>     text	   data	    bss	    dec	    hex	filename
> 13051391	1503898	 327768	14883057	 e318f1	vmlinux.o.old
> 13050751	1503898	 327768	14882417	 e31671	vmlinux.o.new
>
> Give the compiler a hand by making it clear we want the same ops.

Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>

Similar pattern is used in drivers/xen/swiotlb-xen.c for mmap and
get_sgtable. This could be also fixed, although those are not used so
frequently as dma_mapping_error.

> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
>   include/linux/dma-mapping.h | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
> index 843ab866e0f4..239e53d12ee8 100644
> --- a/include/linux/dma-mapping.h
> +++ b/include/linux/dma-mapping.h
> @@ -541,10 +541,11 @@ static inline void dma_free_noncoherent(struct device *dev, size_t size,
>   
>   static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
>   {
> -	debug_dma_mapping_error(dev, dma_addr);
> +	const struct dma_map_ops *ops = get_dma_ops(dev);
>   
> -	if (get_dma_ops(dev)->mapping_error)
> -		return get_dma_ops(dev)->mapping_error(dev, dma_addr);
> +	debug_dma_mapping_error(dev, dma_addr);
> +	if (ops->mapping_error)
> +		return ops->mapping_error(dev, dma_addr);
>   	return 0;
>   }
>   

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat
  2017-07-24 17:29 ` [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat Robin Murphy
  2017-08-01  7:58   ` Marek Szyprowski
@ 2017-08-25 14:56   ` Christoph Hellwig
  1 sibling, 0 replies; 3+ messages in thread
From: Christoph Hellwig @ 2017-08-25 14:56 UTC (permalink / raw)
  To: Robin Murphy; +Cc: hch, m.szyprowski, linux-kernel

Thanks,

applied to the dma-mapping-4.14 tree.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-25 14:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20170724172940epcas4p4b06b8fd5c66a475e1f8be1361981a14b@epcas4p4.samsung.com>
2017-07-24 17:29 ` [PATCH] dma-mapping: Reduce dma_mapping_error() inline bloat Robin Murphy
2017-08-01  7:58   ` Marek Szyprowski
2017-08-25 14:56   ` Christoph Hellwig

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).