From: Andi Kleen <ak@suse.de>
To: akpm@osdl.org
Cc: linux-kernel@vger.kernel.org, James.Bottomley@HansenPartnership.com
Subject: [PATCH] Improve pci_alloc_consistent wrapper on preemptive kernels
Date: Fri, 30 Jul 2004 19:02:27 +0200 [thread overview]
Message-ID: <20040730190227.29913e23.ak@suse.de> (raw)
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
next reply other threads:[~2004-07-30 17:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-30 17:02 Andi Kleen [this message]
2004-07-30 17:16 ` [PATCH] Improve pci_alloc_consistent wrapper on preemptive kernels 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040730190227.29913e23.ak@suse.de \
--to=ak@suse.de \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.