lkml.org 
[lkml]   [2004]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] Improve pci_alloc_consistent wrapper on preemptive kernels

This is a minor optimization for the pci_alloc_consistent wrapper for
the generic dma API. When the kernel is compiled preemptive the caller
can decide if the allocation needs to be GFP_KERNEL or GFP_ATOMIC.

I had this optimization previously in x86-64 private code, but it needs to move
up now that x86-64 uses the generic DMA API.


diff -urpN -X ../KDIFX linux-2.6.8rc2-mm1/include/asm-generic/pci-dma-compat.h linux-2.6.8rc2-mm1-amd64/include/asm-generic/pci-dma-compat.h
--- linux-2.6.8rc2-mm1/include/asm-generic/pci-dma-compat.h 2004-04-06 13:12:19.000000000 +0200
+++ linux-2.6.8rc2-mm1-amd64/include/asm-generic/pci-dma-compat.h 2004-07-30 17:02:49.000000000 +0200
@@ -5,6 +5,13 @@
#define _ASM_GENERIC_PCI_DMA_COMPAT_H

#include <linux/dma-mapping.h>
+#include <linux/config.h>
+
+#ifdef CONFIG_PREEMPT
+#define preempt_atomic() in_atomic()
+#else
+#define preempt_atomic() 1
+#endif

/* note pci_set_dma_mask isn't here, since it's a public function
* exported from drivers/pci, use dma_supported instead */
@@ -15,11 +22,12 @@ pci_dma_supported(struct pci_dev *hwdev,
return dma_supported(hwdev == NULL ? NULL : &hwdev->dev, mask);
}

+/* Would be better to move this out of line. It's already quite big. */
static inline void *
pci_alloc_consistent(struct pci_dev *hwdev, size_t size,
dma_addr_t *dma_handle)
{
- return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, GFP_ATOMIC);
+ return dma_alloc_coherent(hwdev == NULL ? NULL : &hwdev->dev, size, dma_handle, preempt_atomic() ? GFP_ATOMIC : GFP_KERNEL);
}

static inline void
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:04    [W:0.999 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site