All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-mapping: Deinline dma_[un]map_single_attrs()
@ 2015-09-20 13:33 Denys Vlasenko
  2015-09-21 19:42 ` Thomas Gleixner
  0 siblings, 1 reply; 3+ messages in thread
From: Denys Vlasenko @ 2015-09-20 13:33 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: Denys Vlasenko, Thomas Gleixner, Ingo Molnar, David Woodhouse,
	Marek Szyprowski, Konrad Rzeszutek Wilk, Don Dutile, linux-kernel

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

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: David Woodhouse <dwmw2@infradead.org>
CC: Marek Szyprowski <m.szyprowski@samsung.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: Don Dutile <ddutile@redhat.com>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: linux-kernel@vger.kernel.org
---
 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

diff --git a/include/asm-generic/dma-mapping-common.h b/include/asm-generic/dma-mapping-common.h
index b1bc954..3fa4d28 100644
--- a/include/asm-generic/dma-mapping-common.h
+++ b/include/asm-generic/dma-mapping-common.h
@@ -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.
diff --git a/kernel/Makefile b/kernel/Makefile
index 53abf00..85f1bff 100644
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -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
 
diff --git a/kernel/dma-mapping-common.c b/kernel/dma-mapping-common.c
new file mode 100644
index 0000000..75e514e
--- /dev/null
+++ b/kernel/dma-mapping-common.c
@@ -0,0 +1,47 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ */
+#include <linux/dma-mapping.h>
+#include <asm-generic/dma-mapping-common.h>
+
+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;
+}
+EXPORT_SYMBOL(dma_map_single_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)
+{
+	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);
+}
+EXPORT_SYMBOL(dma_unmap_single_attrs);
-- 
1.8.1.4


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

* Re: [PATCH] dma-mapping: Deinline dma_[un]map_single_attrs()
  2015-09-20 13:33 [PATCH] dma-mapping: Deinline dma_[un]map_single_attrs() Denys Vlasenko
@ 2015-09-21 19:42 ` Thomas Gleixner
  2015-09-22 13:28   ` Denys Vlasenko
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Gleixner @ 2015-09-21 19:42 UTC (permalink / raw)
  To: Denys Vlasenko
  Cc: Christoph Hellwig, Ingo Molnar, David Woodhouse, Marek Szyprowski,
	Konrad Rzeszutek Wilk, Don Dutile, linux-kernel

On Sun, 20 Sep 2015, Denys Vlasenko wrote:
> ---
>  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

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

* Re: [PATCH] dma-mapping: Deinline dma_[un]map_single_attrs()
  2015-09-21 19:42 ` Thomas Gleixner
@ 2015-09-22 13:28   ` Denys Vlasenko
  0 siblings, 0 replies; 3+ messages in thread
From: Denys Vlasenko @ 2015-09-22 13:28 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Christoph Hellwig, Ingo Molnar, David Woodhouse, Marek Szyprowski,
	Konrad Rzeszutek Wilk, Don Dutile, linux-kernel

On 09/21/2015 09:42 PM, Thomas Gleixner wrote:
> On Sun, 20 Sep 2015, Denys Vlasenko wrote:
>> ---
>>  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.


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

end of thread, other threads:[~2015-09-22 13:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-20 13:33 [PATCH] dma-mapping: Deinline dma_[un]map_single_attrs() Denys Vlasenko
2015-09-21 19:42 ` Thomas Gleixner
2015-09-22 13:28   ` Denys Vlasenko

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.