Skip to contentSkip to conversation

dma-mapping: Deinline dma_[un]map_single_attrs()

PATCH Superseded Denys Vlasenko 2 participants 3 messages Sep 20, 2015 – Sep 22, 2015 Generic include/asm header files

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-mapping: Deinline dma_[un]map_single_attrs()

With this .config: http://busybox.net/~vda/kernel_config_ALLYES_Os,
after deinlining these functions have sizes and callsite counts as follows:

dma_map_single_attrs: 214 bytes, 587 calls
dma_unmap_single_attrs: 115 bytes, 771 calls

This patch reduces kernel size by 152310 bytes.

text data bss dec hex filename
91622364 19945240 36421632 147989236 8d222f4 vmlinux.before 91470054 19945080 36421632 147836766 8cfcf5e vmlinux

CC Christoph Hellwig <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Ingo Molnar <[email protected]>
CC David Woodhouse <[email protected]>
CC Marek Szyprowski <[email protected]>
CC Konrad Rzeszutek Wilk <[email protected]>
CC Don Dutile <[email protected]>
CC Thomas Gleixner <[email protected]>
---
 include/asm-generic/dma-mapping-common.h | 40 ++++++---------------------
 kernel/Makefile                          |  3 +-
 kernel/dma-mapping-common.c              | 47 ++++++++++++++++++++++++++++++++
 3 files changed, 58 insertions(+), 32 deletions(-)
 create mode 100644 kernel/dma-mapping-common.c
include/asm-generic/dma-mapping-common.h +9 -31
index b1bc954..3fa4d28 100644
@@ -8,37 +8,15 @@
 #include <linux/dma-attrs.h>
 #include <asm-generic/dma-coherent.h>
 
-static inline dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
-					      size_t size,
-					      enum dma_data_direction dir,
-					      struct dma_attrs *attrs)
-{
-	struct dma_map_ops *ops = get_dma_ops(dev);
-	dma_addr_t addr;
-
-	kmemcheck_mark_initialized(ptr, size);
-	BUG_ON(!valid_dma_direction(dir));
-	addr = ops->map_page(dev, virt_to_page(ptr),
-			     (unsigned long)ptr & ~PAGE_MASK, size,
-			     dir, attrs);
-	debug_dma_map_page(dev, virt_to_page(ptr),
-			   (unsigned long)ptr & ~PAGE_MASK, size,
-			   dir, addr, true);
-	return addr;
-}
-
-static inline void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
-					  size_t size,
-					  enum dma_data_direction dir,
-					  struct dma_attrs *attrs)
-{
-	struct dma_map_ops *ops = get_dma_ops(dev);
-
-	BUG_ON(!valid_dma_direction(dir));
-	if (ops->unmap_page)
-		ops->unmap_page(dev, addr, size, dir, attrs);
-	debug_dma_unmap_page(dev, addr, size, dir, true);
-}
+dma_addr_t dma_map_single_attrs(struct device *dev, void *ptr,
+				size_t size,
+				enum dma_data_direction dir,
+				struct dma_attrs *attrs);
+
+void dma_unmap_single_attrs(struct device *dev, dma_addr_t addr,
+			    size_t size,
+			    enum dma_data_direction dir,
+			    struct dma_attrs *attrs);
 
 /*
  * dma_maps_sg_attrs returns 0 on error and > 0 on success.
kernel/Makefile +2 -1
index 53abf00..85f1bff 100644
@@ -9,7 +9,8 @@ obj-y     = fork.o exec_domain.o panic.o \
 	    extable.o params.o \
 	    kthread.o sys_ni.o nsproxy.o \
 	    notifier.o ksysfs.o cred.o reboot.o \
-	    async.o range.o smpboot.o
+	    async.o range.o smpboot.o \
+	    dma-mapping-common.o
 
 obj-$(CONFIG_MULTIUSER) += groups.o
 
kernel/dma-mapping-common.c new file +47 -0

47 lines not on this page · raw message

Signature · 1 line
1.8.1.4
#1 lore raw
Quoted 4 lines · Denys Vlasenko
---
 include/asm-generic/dma-mapping-common.h | 40 ++++++---------------------
 kernel/Makefile                          |  3 +-
 kernel/dma-mapping-common.c              | 47 ++++++++++++++++++++++++++++++++

Can we please move that to lib/ ?

Thanks,

tglx

#2 lore raw
Quoted 7 lines · Thomas Gleixner
Quoted 4 lines · Denys Vlasenko
---
 include/asm-generic/dma-mapping-common.h | 40 ++++++---------------------
 kernel/Makefile                          |  3 +-
 kernel/dma-mapping-common.c              | 47 ++++++++++++++++++++++++++++++++

Can we please move that to lib/ ?

Sure. Will send v2 in a minute.