1
0
Fork 0
alistair23-linux/net/rds
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
..
Kconfig net/rds: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:40:02 -08:00
Makefile Net: rds: Makefile: Remove deprecated items 2010-11-22 08:16:15 -08:00
af_rds.c RDS: convert bind hash table to re-sizable hashtable 2015-11-02 15:36:23 -05:00
bind.c RDS: convert bind hash table to re-sizable hashtable 2015-11-02 15:36:23 -05:00
cong.c rds: rds_cong_queue_updates needs to defer the congestion update transmission 2015-02-11 14:35:44 -08:00
connection.c RDS: Use a single TCP socket for both send and receive. 2015-10-05 03:34:51 -07:00
ib.c RDS: IB: split mr pool to improve 8K messages performance 2015-10-05 11:19:02 -07:00
ib.h RDS: IB: split mr pool to improve 8K messages performance 2015-10-05 11:19:02 -07:00
ib_cm.c RDS: IB: handle rds_ibdev release case instead of crashing the kernel 2015-10-05 11:19:01 -07:00
ib_rdma.c RDS: IB: split mr pool to improve 8K messages performance 2015-10-05 11:19:02 -07:00
ib_recv.c mm, page_alloc: distinguish between being unable to sleep, unwilling to sleep and avoiding waking kswapd 2015-11-06 17:50:42 -08:00
ib_ring.c RDS/IW+IB: Set recv ring low water mark to 1/2 full. 2009-04-09 17:21:14 -07:00
ib_send.c RDS: IB: split send completion handling and do batch ack 2015-10-05 11:19:01 -07:00
ib_stats.c RDS: IB: split mr pool to improve 8K messages performance 2015-10-05 11:19:02 -07:00
ib_sysctl.c net: Convert uses of typedef ctl_table to struct ctl_table 2013-06-13 02:36:09 -07:00
info.c rds: fix an integer overflow test in rds_info_getsockopt() 2015-08-03 15:20:16 -07:00
info.h RDS: Info and stats 2009-02-26 23:39:25 -08:00
iw.c Changes for 4.3 2015-09-09 08:33:31 -07:00
iw.h rds: switch ->inc_copy_to_user() to passing iov_iter 2014-11-24 05:16:43 -05:00
iw_cm.c RDS-TCP: Make RDS-TCP work correctly when it is set up in a netns other than init_net 2015-08-07 11:29:57 -07:00
iw_rdma.c net: rds: changing the return type from int to void 2015-11-02 15:35:19 -05:00
iw_recv.c rds: switch ->inc_copy_to_user() to passing iov_iter 2014-11-24 05:16:43 -05:00
iw_ring.c RDS/IW+IB: Set recv ring low water mark to 1/2 full. 2009-04-09 17:21:14 -07:00
iw_send.c RDS: Convert to ib_alloc_mr 2015-08-30 18:08:46 -04:00
iw_stats.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu 2009-09-15 09:39:44 -07:00
iw_sysctl.c rds: remove the unneed NULL checking 2014-05-09 15:59:45 -04:00
loop.c RDS: use gfp flags from caller in conn_alloc() 2012-03-22 19:29:58 -04:00
loop.h RDS: loopback 2009-02-26 23:39:26 -08:00
message.c rds: Make rds_message_copy_from_user() return 0 on success. 2015-02-07 22:41:56 -08:00
page.c net: Fix (nearly-)kernel-doc comments for various functions 2012-07-10 23:13:45 -07:00
rdma.c RDS: Fix rds MR reference count in rds_rdma_unuse() 2015-08-25 16:28:10 -07:00
rdma_transport.c RDS: check for valid cm_id before initiating connection 2015-08-25 13:35:31 -07:00
rdma_transport.h rds: make local functions/variables static 2010-10-21 04:26:39 -07:00
rds.h RDS: convert bind hash table to re-sizable hashtable 2015-11-02 15:36:23 -05:00
recv.c net: Remove iocb argument from sendmsg and recvmsg 2015-03-02 13:06:31 -05:00
send.c RDS: fix rds-ping deadlock over TCP transport 2015-10-18 22:45:55 -07:00
stats.c net/rds: zero last byte for strncpy 2013-03-08 00:35:44 -05:00
sysctl.c net: rds: use correct size for max unacked packets and bytes 2015-02-04 16:07:27 -08:00
tcp.c RDS-TCP: Do not bloat sndbuf/rcvbuf in rds_tcp_tune 2015-10-05 03:34:53 -07:00
tcp.h RDS-TCP: Support multiple RDS-TCP listen endpoints, one per netns. 2015-08-07 11:29:58 -07:00
tcp_connect.c RDS-TCP: Support multiple RDS-TCP listen endpoints, one per netns. 2015-08-07 11:29:58 -07:00
tcp_listen.c RDS-TCP: Reset tcp callbacks if re-using an outgoing socket in rds_tcp_accept_one() 2015-10-13 04:22:41 -07:00
tcp_recv.c RDS-TCP: Recover correctly from pskb_pull()/pksb_trim() failure in rds_tcp_data_recv 2015-10-27 19:46:34 -07:00
tcp_send.c RDS-TCP: Set up MSG_MORE and MSG_SENDPAGE_NOTLAST as appropriate in rds_tcp_xmit 2015-10-05 03:34:53 -07:00
tcp_stats.c net: rds: fix const array syntax 2011-07-01 16:16:19 -07:00
threads.c RDS: use rds_send_xmit() state instead of RDS_LL_SEND_FULL 2015-10-05 11:19:01 -07:00
transport.c RDS-TCP: Make RDS-TCP work correctly when it is set up in a netns other than init_net 2015-08-07 11:29:57 -07:00