linux/drivers
Keshavamurthy, Anil S eb3fa7cb51 Intel IOMMU: Avoid memory allocation failures in dma map api calls
Intel IOMMU driver needs memory during DMA map calls to setup its internal
page tables and for other data structures.  As we all know that these DMA map
calls are mostly called in the interrupt context or with the spinlock held by
the upper level drivers(network/storage drivers), so in order to avoid any
memory allocation failure due to low memory issues, this patch makes memory
allocation by temporarily setting PF_MEMALLOC flags for the current task
before making memory allocation calls.

We evaluated mempools as a backup when kmem_cache_alloc() fails
and found that mempools are really not useful here because
 1) We don't know for sure how much to reserve in advance
 2) And mempools are not useful for GFP_ATOMIC case (as we call
    memory alloc functions with GFP_ATOMIC)

(akpm: point 2 is wrong...)

With PF_MEMALLOC flag set in the current->flags, the VM subsystem avoids any
watermark checks before allocating memory thus guarantee'ing the memory till
the last free page.  Further, looking at the code in mm/page_alloc.c in
__alloc_pages() function, looks like this flag is useful only in the
non-interrupt context.

If we are in the interrupt context and memory allocation in IOMMU driver fails
for some reason, then the DMA map api's will return failure and it is up to
the higher level drivers to retry.  Suppose, if upper level driver programs
the controller with the buggy DMA virtual address, the IOMMU will block that
DMA transaction when that happens thus preventing any corruption to main
memory.

So far in our test scenario, we were unable to create any memory allocation
failure inside dma map api calls.

Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: Andi Kleen <ak@suse.de>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Muli Ben-Yehuda <muli@il.ibm.com>
Cc: "Siddha, Suresh B" <suresh.b.siddha@intel.com>
Cc: Arjan van de Ven <arjan@infradead.org>
Cc: Ashok Raj <ashok.raj@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2007-10-22 08:13:18 -07:00
..
acorn/char unicode diacritics support 2007-10-17 08:42:52 -07:00
acpi Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
amba
ata Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
atm Fix misspellings of "system", "controller", "interrupt" and "necessary". 2007-10-19 23:10:43 +02:00
auxdisplay
base memory hotplug: rearrange memory hotplug notifier 2007-10-22 08:13:17 -07:00
block remove unused return within void return function 2007-10-20 02:18:21 +02:00
bluetooth
cdrom Use helpers to obtain task pid in printks 2007-10-19 11:53:43 -07:00
char Documentation: Remove references to dead "cyclades=" boot option 2007-10-20 00:01:12 +02:00
clocksource
connector
cpufreq
cpuidle
crypto
dca I/OAT: Add DCA services 2007-10-16 09:43:09 -07:00
dio
dma I/OAT: Add completion callback for async_tx interface use 2007-10-18 14:37:32 -07:00
edac NULL terminate the pci_device_ids in pasemi_edac 2007-10-19 11:53:56 -07:00
eisa
fc4
firewire fix typo "insted" -> "instead" 2007-10-20 01:55:04 +02:00
firmware define global BIT macro 2007-10-19 11:53:42 -07:00
hid changed email 2007-10-20 00:47:32 +02:00
hwmon Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
i2c typo fixes 2007-10-20 01:34:40 +02:00
ide Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
ieee1394 ieee1394: ieee1394_core.c: use DEFINE_SPINLOCK for spinlock definition 2007-10-16 23:59:59 +02:00
infiniband [INET]: Justification for local port range robustness. 2007-10-18 22:00:17 -07:00
input Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
isdn Spelling fix: explicitly 2007-10-19 23:22:55 +02:00
kvm
leds fix typo "sort" -> "short" 2007-10-20 01:55:58 +02:00
lguest Merge branch 'xen-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen 2007-10-17 11:10:11 -07:00
macintosh Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
mca
md Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
media more UTF-8 conversions 2007-10-19 23:22:11 +02:00
message Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
mfd typo fixes 2007-10-20 01:34:40 +02:00
misc typo fixes 2007-10-20 01:34:40 +02:00
mmc mmc: at91_mci: cleanup: use MCI_ERRORS 2007-10-17 21:35:10 +02:00
mtd typo fixes 2007-10-20 01:34:40 +02:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
nubus
of [SPARC/64]: Consolidate of_register_driver 2007-10-17 21:17:42 -07:00
oprofile
parisc [PARISC] Fix infinite loop in /proc/iomem 2007-10-18 12:34:22 -07:00
parport sysctl: parport remove binary paths 2007-10-18 14:37:23 -07:00
pci Intel IOMMU: Avoid memory allocation failures in dma map api calls 2007-10-22 08:13:18 -07:00
pcmcia remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
pnp PNP: add debug message for adding new device 2007-10-17 08:43:04 -07:00
power Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
ps3 remove asm/bitops.h includes 2007-10-19 11:53:41 -07:00
rapidio
rtc typo fixes 2007-10-20 01:34:40 +02:00
s390 Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
sbus vfc_dev conversion to mutex: fallout 2007-10-20 15:04:06 -07:00
scsi Spelling fix: explicitly 2007-10-19 23:22:55 +02:00
serial Blackfin serial driver Kconfig: depend on DMA not being enabled rather than a specific DMA size 2007-10-21 22:30:01 +08:00
sh
sn
spi Fix misspellings of "system", "controller", "interrupt" and "necessary". 2007-10-19 23:10:43 +02:00
ssb [PATCH] ssb: fix build failure 2007-10-16 21:04:11 -04:00
tc lk201: remove obsolete driver 2007-10-17 08:42:57 -07:00
telephony
uio
usb typo fixes 2007-10-20 01:34:40 +02:00
video Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2007-10-19 20:36:17 -07:00
w1 Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
watchdog Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
xen Add missing newlines to some uses of dev_<level> messages 2007-10-18 14:37:28 -07:00
zorro Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +02:00
Kconfig mv watchdog tree under drivers 2007-10-18 10:39:03 +00:00
Makefile Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux-acpi-2.6 2007-10-19 13:12:46 -07:00