This patch fixes duplicated memset that is introduced by the patch
x86-make-dma_alloc_coherent-return-zeroed-memory-if-cma-is-enabled.patch
in -mm tree, and this change should be folded into it.

If dma_generic_alloc_coherent() is called with __GFP_ZERO, it does a
duplicated memset to the memory area allocated by alloc_pages_node()
with __GFP_ZERO.  This change fixes that inefficiency by clearing
__GFP_ZERO bit in gfp flages before calling alloc_pages_node().  Note
that dma_generic_alloc_coherent() always returns zeroed memory.

Signed-off-by: Akinobu Mita <[email protected]>
Cc: Marek Szyprowski <[email protected]>
Cc: Konrad Rzeszutek Wilk <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Don Dutile <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Andi Kleen <[email protected]>
Cc: [email protected]
Cc: [email protected]
---
 arch/x86/kernel/pci-dma.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c
index f15bf8d..a25e202 100644
--- a/arch/x86/kernel/pci-dma.c
+++ b/arch/x86/kernel/pci-dma.c
@@ -97,6 +97,7 @@ void *dma_generic_alloc_coherent(struct device *dev, size_t 
size,
 
        dma_mask = dma_alloc_coherent_mask(dev, flag);
 
+       flag &= ~__GFP_ZERO;
 again:
        page = NULL;
        /* CMA can be used only in the context which permits sleeping */
-- 
1.8.3.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to