[PATCH v3 2/3] common: DMA-mapping: add DMA_ATTR_SEQUENTIAL attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch adds the DMA_ATTR_SEQUENTIAL attribute to the DMA-mapping
subsystem.

This attribute can be used as a hint to the DMA-mapping subsystem that
access to memory will be mostly sequential.  With mostly sequential
access TLB efficiency isn't as important, so the system may make
tradeoffs sacrificing TLB efficiency to gain other benefits.

It's expected that we will use this attribute as a hint that memory
allocation should be done page at a time instead of asking the memory
subsystem to try to give us as big of chunks as possible.  Allocating a
page at a time sacrifices TLB efficiency but it is much quicker for the
memory subsystem to process and it also leaves big chunks of memory
available for other users to use.

The name of the hint (DMA_ATTR_SEQUENTIAL) is based on the name
MADV_SEQUENTIAL, which has the same meaning.  If we have expected users,
we could also add DMA_ATTR_RANDOM to indicate that random access is
expected.

Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
---
Changes in v3:
- add DMA_ATTR_SEQUENTIAL attribute new for v3

Changes in v2: None

 Documentation/DMA-attributes.txt | 11 +++++++++++
 include/linux/dma-attrs.h        |  1 +
 2 files changed, 12 insertions(+)

diff --git a/Documentation/DMA-attributes.txt b/Documentation/DMA-attributes.txt
index 18dc52c4f2a0..467e1c5c9cdc 100644
--- a/Documentation/DMA-attributes.txt
+++ b/Documentation/DMA-attributes.txt
@@ -100,3 +100,14 @@ allocated by dma_alloc_attrs() function from individual pages if it can
 be mapped as contiguous chunk into device dma address space. By
 specifying this attribute the allocated buffer is forced to be contiguous
 also in physical memory.
+
+DMA_ATTR_SEQUENTIAL
+-------------------
+
+This is a hint to the DMA-mapping subsystem that access to the buffer
+will be mostly sequential instead of random access.  The DMA-mapping
+subsystem might use this information to make decisions on how hard it
+will work to optimize TLB efficiency.  If we know access is sequential
+and we don't have DMA_ATTR_FORCE_CONTIGUOUS then it's probably wiser
+for the DMA-mapping subsystem to allocate memory out of individual
+pages to avoid stressing the memory subsystem as much.
diff --git a/include/linux/dma-attrs.h b/include/linux/dma-attrs.h
index 99c0be00b47c..5777a2cec5f3 100644
--- a/include/linux/dma-attrs.h
+++ b/include/linux/dma-attrs.h
@@ -18,6 +18,7 @@ enum dma_attr {
 	DMA_ATTR_NO_KERNEL_MAPPING,
 	DMA_ATTR_SKIP_CPU_SYNC,
 	DMA_ATTR_FORCE_CONTIGUOUS,
+	DMA_ATTR_SEQUENTIAL,
 	DMA_ATTR_MAX,
 };
 
-- 
2.6.0.rc2.230.g3dd15c0

--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux