linux/drivers/staging
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
..
android mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
board staging: board: Set PM domain before probe 2015-10-29 09:05:57 +09:00
clocking-wizard
comedi staging: comedi: comedi_test: implement commands on AO subdevice 2015-10-29 08:58:36 +09:00
dgap staging: dgap: add spaces around binary operator '|' 2015-10-24 19:33:42 -07:00
dgnc staging: dgnc: dgnc_driver: Remove useless initialisation 2015-10-16 22:56:23 -07:00
emxx_udc Staging: emxx_udc: Add space around operator. 2015-10-24 19:21:05 -07:00
fbtft spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
fsl-mc staging: fsl-mc: section mismatch bug fix 2015-10-27 14:40:14 +09:00
fwserial
gdm72xx Staging: gdm72xx: Remove unnecessary cast on void pointer 2015-10-16 22:51:48 -07:00
gdm724x staging: gdm724x: remove multiple blank lines 2015-10-24 19:02:42 -07:00
goldfish staging: goldfish: Prefer kernel type u32 over uint32_t 2015-09-12 18:24:38 -07:00
gs_fpgaboot
iio spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
lustre 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 media updates for v4.4-rc1 2015-11-05 12:05:15 -08:00
most staging: most: remove exclusive wait_queue 2015-10-29 08:57:19 +09:00
mt29f_spinand spi: Updates for v4.4 2015-11-05 13:15:12 -08:00
netlogic staging: netlogic: Do not use multiple blank lines. 2015-10-24 19:38:48 -07:00
nvec staging: nvec: Do not use multiple blank lines. 2015-10-27 14:49:09 +09:00
octeon staging: octeon: Do not use multiple blank lines. 2015-10-24 19:28:52 -07:00
octeon-usb staging: octeon-usb: Replace kmalloc with kmalloc_array 2015-10-24 19:28:52 -07:00
olpc_dcon Staging: olpc_dcon: Remove NULL comparison 2015-10-16 23:06:38 -07:00
panel Staging: panel: Logical continuations should be on the previous line 2015-10-29 07:55:17 +09:00
rdma staging: rdma: ipath: Remove unneeded vairable. 2015-10-29 09:09:48 +09:00
rtl8188eu staging: rtl8188eu: pwrGrpCnt variable removed in store_pwrindex_offset function 2015-10-29 09:09:08 +09:00
rtl8192e staging: rtl8192e: _rtl92e_fw_boot_cpu: Remove unneeded goto 2015-10-24 19:23:13 -07:00
rtl8192u Staging: rtl8192u: ieee80211: added missing blank lines 2015-10-29 09:10:55 +09:00
rtl8712 staging: rtl8712: rtl871x_io: Remove unused function 2015-10-29 07:55:17 +09:00
rtl8723au staging: rtl8723au: core: Remove unnecessary functions 2015-10-29 07:55:17 +09:00
rts5208 Staging: rts5208: use dmam_alloc_coherent 2015-10-16 23:17:26 -07:00
skein skein: fix coding style 2015-10-24 19:30:12 -07:00
slicoss staging: slicoss: Fixes block comment style 2015-10-27 14:43:31 +09:00
sm750fb staging: sm750fb: remove unused fields from struct sm750_dev 2015-10-27 17:04:57 +09:00
speakup Staging driver update for 4.4-rc1 2015-11-04 21:40:53 -08:00
ste_rmi4 Staging: ste_rmi4: Remove unnecessary MODULE_ALIAS() 2015-09-12 18:24:38 -07:00
unisys staging: unisys: Remove useless intialisation 2015-10-16 22:59:36 -07:00
vme staging: vme: devices: add spaces around '-' 2015-08-14 18:56:54 -07:00
vt6655 staging: vt6655: Add space around '*' 2015-10-24 19:38:48 -07:00
vt6656 staging: vt6656: Do not use multiple blank lines. 2015-10-27 16:53:12 +09:00
wilc1000 Staging: wilc1000: Prefer eth_broadcast_addr over memset() 2015-10-29 08:51:27 +09:00
wlan-ng drivers:staging:wlan_ng Fix no space is necessary after a cast 2015-10-29 09:05:57 +09:00
xgifb Staging: xgifb: Remove space after cast 2015-10-24 19:11:30 -07:00
Kconfig staging: ft1000: remove obsolete driver 2015-10-24 19:19:43 -07:00
Makefile staging: ft1000: remove obsolete driver 2015-10-24 19:19:43 -07:00
staging.c