public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Improve pci_alloc_consistent wrapper on preemptive kernels
@ 2004-07-30 17:02 Andi Kleen
  2004-07-30 17:16 ` Jeff Garzik
  2004-07-30 20:02 ` Andrew Morton
  0 siblings, 2 replies; 12+ messages in thread
From: Andi Kleen @ 2004-07-30 17:02 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, James.Bottomley


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

^ permalink raw reply	[flat|nested] 12+ messages in thread
[parent not found: <2nJ3t-34a-39@gated-at.bofh.it>]

end of thread, other threads:[~2004-07-30 21:42 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-07-30 17:02 [PATCH] Improve pci_alloc_consistent wrapper on preemptive kernels Andi Kleen
2004-07-30 17:16 ` Jeff Garzik
2004-07-30 17:43   ` Andi Kleen
2004-07-30 18:07     ` Jeff Garzik
2004-07-30 18:47       ` Takashi Iwai
2004-07-30 19:28         ` Takashi Iwai
2004-07-30 21:42       ` Andi Kleen
2004-07-30 20:02 ` Andrew Morton
2004-07-30 20:13   ` James Bottomley
2004-07-30 20:20     ` Andrew Morton
2004-07-30 20:28       ` James Bottomley
     [not found] <2nJ3t-34a-39@gated-at.bofh.it>
     [not found] ` <2nJmP-3eq-9@gated-at.bofh.it>
     [not found]   ` <2nJG8-3p6-21@gated-at.bofh.it>
     [not found]     ` <2nK9b-3PM-17@gated-at.bofh.it>
2004-07-30 18:34       ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox