1
0
Fork 0
alistair23-linux/drivers
Mel Gorman d0164adc89 mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd
__GFP_WAIT has been used to identify atomic context in callers that hold
spinlocks or are in interrupts.  They are expected to be high priority and
have access one of two watermarks lower than "min" which can be referred
to as the "atomic reserve".  __GFP_HIGH users get access to the first
lower watermark and can be called the "high priority reserve".

Over time, callers had a requirement to not block when fallback options
were available.  Some have abused __GFP_WAIT leading to a situation where
an optimisitic allocation with a fallback option can access atomic
reserves.

This patch uses __GFP_ATOMIC to identify callers that are truely atomic,
cannot sleep and have no alternative.  High priority users continue to use
__GFP_HIGH.  __GFP_DIRECT_RECLAIM identifies callers that can sleep and
are willing to enter direct reclaim.  __GFP_KSWAPD_RECLAIM to identify
callers that want to wake kswapd for background reclaim.  __GFP_WAIT is
redefined as a caller that is willing to enter direct reclaim and wake
kswapd for background reclaim.

This patch then converts a number of sites

o __GFP_ATOMIC is used by callers that are high priority and have memory
  pools for those requests. GFP_ATOMIC uses this flag.

o Callers that have a limited mempool to guarantee forward progress clear
  __GFP_DIRECT_RECLAIM but keep __GFP_KSWAPD_RECLAIM. bio allocations fall
  into this category where kswapd will still be woken but atomic reserves
  are not used as there is a one-entry mempool to guarantee progress.

o Callers that are checking if they are non-blocking should use the
  helper gfpflags_allow_blocking() where possible. This is because
  checking for __GFP_WAIT as was done historically now can trigger false
  positives. Some exceptions like dm-crypt.c exist where the code intent
  is clearer if __GFP_DIRECT_RECLAIM is used instead of the helper due to
  flag manipulations.

o Callers that built their own GFP flags instead of starting with GFP_KERNEL
  and friends now also need to specify __GFP_KSWAPD_RECLAIM.

The first key hazard to watch out for is callers that removed __GFP_WAIT
and was depending on access to atomic reserves for inconspicuous reasons.
In some cases it may be appropriate for them to use __GFP_HIGH.

The second key hazard is callers that assembled their own combination of
GFP flags instead of starting with something like GFP_KERNEL.  They may
now wish to specify __GFP_KSWAPD_RECLAIM.  It's almost certainly harmless
if it's missed in most cases as other activity will wake kswapd.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Vitaly Wool <vitalywool@gmail.com>
Cc: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2015-11-06 17:50:42 -08:00
..
accessibility
acpi driver core update for 4.4-rc1 2015-11-04 21:50:37 -08:00
amba
android
ata Merge branch 'for-4.3-fixes' into for-4.4 2015-11-03 17:29:03 -05:00
atm
auxdisplay
base The majority of the changes are driver updates and new device 2015-11-05 12:59:36 -08:00
bcma
block mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
bluetooth driver core update for 4.4-rc1 2015-11-04 21:50:37 -08:00
bus
cdrom
char powerpc updates for 4.4 2015-11-05 23:38:43 -08:00
clk powerpc updates for 4.4 2015-11-05 23:38:43 -08:00
clocksource Power management and ACPI updates for v4.4-rc1 2015-11-04 18:10:13 -08:00
connector mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
cpufreq Merge branch 'pm-opp' 2015-11-02 00:54:37 +01:00
cpuidle cpuidle: mvebu: disable the bind/unbind attributes and use builtin_platform_driver 2015-10-23 12:40:48 +02:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2015-11-04 09:11:12 -08:00
dca
devfreq
dio
dma char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00
dma-buf
edac Merge branch 'ras-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2015-11-03 17:51:33 -08:00
eisa
extcon Merge branches 'ib-extcon-mfd-4.4', 'ib-mfd-i2c-v4.4', 'ib-mfd-power-4.4', 'ib-mfd-regmap-4.4' and 'ib-mfd-regulator-4.4' into ibs-for-mfd-merged 2015-10-26 14:48:22 +00:00
firewire mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
firmware Half dozen small cleanups plus change to allow pstore 2015-11-05 11:51:18 -08:00
fmc
fpga fpga: socfpga: Fix check of return value of devm_request_irq 2015-10-29 15:20:25 -07:00
gpio spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
gpu mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
hid
hsi hsi: controllers:remove redundant code 2015-10-30 16:10:40 +01:00
hv drivers/hv: share Hyper-V SynIC constants with userspace 2015-11-04 16:24:33 +01:00
hwmon spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
hwspinlock
hwtracing
i2c i2c: pnx: fix runtime warnings caused by enabling unprepared clock 2015-10-23 22:26:28 +02:00
ide ide: pdc202xx_new: Replace timeval with ktime_t 2015-11-03 11:51:08 -05:00
idle
iio spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
infiniband mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
input spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
iommu mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
ipack
irqchip Power management and ACPI updates for v4.4-rc1 2015-11-04 18:10:13 -08:00
isdn TTY/Serial driver patches for 4.4-rc1 2015-11-04 21:35:12 -08:00
leds spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
lguest
lightnvm lightnvm: refactor phys addrs type to u64 2015-11-03 09:53:24 -07:00
macintosh
mailbox
mcb mcb: Destroy IDA on module unload 2015-10-29 09:02:16 +09:00
md mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
media mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
memory char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00
memstick
message
mfd mfd: avoid newly introduced compiler warning 2015-11-06 10:47:12 -08:00
misc - New Device Support 2015-11-06 10:23:50 -08:00
mmc spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
mtd mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
net mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
nfc spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
ntb
nubus
nvdimm block, libnvdimm, nvme: provide a built-in blk_integrity nop profile 2015-10-21 14:43:45 -06:00
nvme Merge branch 'for-4.4/reservations' of git://git.kernel.dk/linux-block 2015-11-04 21:01:27 -08:00
nvmem
of driver core update for 4.4-rc1 2015-11-04 21:50:37 -08:00
oprofile
parisc parisc: reduce syslog debug output 2015-10-22 15:45:18 +02:00
parport
pci Power management and ACPI updates for v4.4-rc1 2015-11-04 18:10:13 -08:00
pcmcia
perf arm64 updates for 4.4: 2015-11-04 14:47:13 -08:00
phy USB patches for 4.4-rc1 2015-11-04 21:26:27 -08:00
pinctrl This is the bulk of GPIO changes for v4.4: 2015-11-02 12:59:12 -08:00
platform - New Device Support 2015-11-06 10:23:50 -08:00
pnp
power - New Device Support 2015-11-06 10:23:50 -08:00
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
remoteproc
reset
rpmsg
rtc spi: Drop owner assignment from spi_drivers 2015-10-28 10:30:17 +09:00
s390 Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux 2015-11-04 11:31:31 -08:00
sbus
scsi SCSI misc on 20151105 2015-11-05 16:20:21 -08:00
sfi
sh
sn
soc
spi Merge remote-tracking branches 'spi/topic/s3c64xx', 'spi/topic/ti-qspi' and 'spi/topic/txx9' into spi-next 2015-11-04 11:02:16 +00:00
spmi char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00
ssb ssb: add Kconfig entry for compiling SoC related code 2015-10-28 21:05:21 +02:00
staging mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
target block: Consolidate static integrity profile properties 2015-10-21 14:42:38 -06:00
tc
thermal Samsung 2nd fixes for v4.3 2015-10-21 17:02:13 +02:00
thunderbolt
tty spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
uio
usb mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
uwb driver core update for 4.4-rc1 2015-11-04 21:50:37 -08:00
vfio
vhost vhost: fix performance on LE hosts 2015-10-27 20:17:03 -07:00
video mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
virt
virtio
vlynq
vme char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00
w1 power supply and reset changes for the v4.4 series 2015-11-05 12:28:15 -08:00
watchdog
xen xen, cpu_hotplug: call device_offline instead of cpu_down 2015-10-23 14:20:48 +01:00
zorro
Kconfig char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00
Makefile char/misc drivers for 4.4-rc1 2015-11-04 22:15:15 -08:00