[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1442928673-5254-1-git-send-email-dvlasenk@redhat.com>
Date: Tue, 22 Sep 2015 15:31:13 +0200
From: Denys Vlasenko <dvlasenk@...hat.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Denys Vlasenko <dvlasenk@...hat.com>,
Christoph Hellwig <hch@....de>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
David Woodhouse <dwmw2@...radead.org>,
Marek Szyprowski <m.szyprowski@...sung.com>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Don Dutile <ddutile@...hat.com>, linux-kernel@...r.kernel.org
Subject: [PATCH v2] 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
Signed-off-by: Denys Vlasenko <dvlasenk@...hat.com>
CC: Christoph Hellwig <hch@....de>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: Ingo Molnar <mingo@...hat.com>
CC: David Woodhouse <dwmw2@...radead.org>
CC: Marek Szyprowski <m.szyprowski@...sung.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
CC: Don Dutile <ddutile@...hat.com>
CC: Thomas Gleixner <tglx@...utronix.de>
CC: linux-kernel@...r.kernel.org
---
Changes since v1: moved dma-mapping-common.c to lib/.
include/asm-generic/dma-mapping-common.h | 40 ++++++---------------------
lib/Makefile | 1 +
lib/dma-mapping-common.c | 47 ++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 31 deletions(-)
create mode 100644 lib/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/lib/Makefile b/lib/Makefile
index 13a7c6a..d973812 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -27,6 +27,7 @@ obj-y += bcd.o div64.o sort.o parser.o halfmd4.o debug_locks.o random32.o \
gcd.o lcm.o list_sort.o uuid.o flex_array.o iov_iter.o clz_ctz.o \
bsearch.o find_bit.o llist.o memweight.o kfifo.o \
percpu-refcount.o percpu_ida.o rhashtable.o reciprocal_div.o
+obj-y += dma-mapping-common.o
obj-y += string_helpers.o
obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o
obj-y += hexdump.o
diff --git a/lib/dma-mapping-common.c b/lib/dma-mapping-common.c
new file mode 100644
index 0000000..75e514e
--- /dev/null
+++ b/lib/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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists