linux/net/sunrpc
NeilBrown 8db55a032a SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC
rpc tasks can be marked as RPC_TASK_SWAPPER.  This causes GFP_MEMALLOC
to be used for some allocations.  This is needed in some cases, but not
in all where it is currently provided, and in some where it isn't
provided.

Currently *all* tasks associated with a rpc_client on which swap is
enabled get the flag and hence some GFP_MEMALLOC support.

GFP_MEMALLOC is provided for ->buf_alloc() but only swap-writes need it.
However xdr_alloc_bvec does not get GFP_MEMALLOC - though it often does
need it.

xdr_alloc_bvec is called while the XPRT_LOCK is held.  If this blocks,
then it blocks all other queued tasks.  So this allocation needs
GFP_MEMALLOC for *all* requests, not just writes, when the xprt is used
for any swap writes.

Similarly, if the transport is not connected, that will block all
requests including swap writes, so memory allocations should get
GFP_MEMALLOC if swap writes are possible.

So with this patch:
 1/ we ONLY set RPC_TASK_SWAPPER for swap writes.
 2/ __rpc_execute() sets PF_MEMALLOC while handling any task
    with RPC_TASK_SWAPPER set, or when handling any task that
    holds the XPRT_LOCKED lock on an xprt used for swap.
    This removes the need for the RPC_IS_SWAPPER() test
    in ->buf_alloc handlers.
 3/ xprt_prepare_transmit() sets PF_MEMALLOC after locking
    any task to a swapper xprt.  __rpc_execute() will clear it.
 3/ PF_MEMALLOC is set for all the connect workers.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com> (for xprtrdma parts)
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
2022-03-13 12:59:35 -04:00
..
auth_gss SUNRPC/auth: async tasks mustn't block waiting for memory 2022-03-13 12:59:35 -04:00
xprtrdma SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC 2022-03-13 12:59:35 -04:00
addr.c nfsd: don't alloc under spinlock in rpc_parse_scope_id 2021-09-21 17:51:47 -04:00
auth.c NFS: discard NFS_RPC_SWAPFLAGS and RPC_TASK_ROOTCREDS 2022-03-13 12:59:35 -04:00
auth_null.c
auth_unix.c SUNRPC/auth: async tasks mustn't block waiting for memory 2022-03-13 12:59:35 -04:00
backchannel_rqst.c The one new feature this time, from Anna Schumaker, is READ_PLUS, which 2020-10-22 09:44:27 -07:00
cache.c proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
clnt.c SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC 2022-03-13 12:59:35 -04:00
debugfs.c NFS Client Updates for Linux 5.15 2021-09-04 10:25:26 -07:00
fail.h SUNRPC: Server-side disconnect injection 2021-08-20 13:50:33 -04:00
Kconfig SUNRPC: remove RC4-HMAC-MD5 support from KerberosV 2020-09-11 14:39:15 +10:00
Makefile sunrpc: Create a sunrpc directory under /sys/kernel/ 2021-07-08 14:03:23 -04:00
netns.h
rpc_pipe.c fsnotify: fix fsnotify hooks in pseudo filesystems 2022-01-24 14:17:02 +01:00
rpcb_clnt.c SUNRPC: Convert GFP_NOFS to GFP_KERNEL 2022-02-25 18:50:12 -05:00
sched.c SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC 2022-03-13 12:59:35 -04:00
socklib.c skb_copy_and_csum_bits(): don't bother with the last argument 2020-08-20 15:45:13 -04:00
socklib.h SUNRPC: Refactor xs_sendpages() 2020-03-16 12:04:33 -04:00
stats.c proc: remove PDE_DATA() completely 2022-01-22 08:33:37 +02:00
sunrpc.h Replace HTTP links with HTTPS ones: NFS, SUNRPC, and LOCKD clients 2020-09-21 10:21:10 -04:00
sunrpc_syms.c sunrpc: add IDs to multipath 2021-07-08 14:03:23 -04:00
svc.c lockd: use svc_set_num_threads() for thread start and stop 2021-12-13 13:42:58 -05:00
svc_xprt.c Highlights: 2022-01-16 07:42:58 +02:00
svcauth.c SUNRPC: Add svc_rqst::rq_auth_stat 2021-08-10 14:18:35 -04:00
svcauth_unix.c SUNRPC: Set rq_auth_stat in the pg_authenticate() callout 2021-08-10 14:18:35 -04:00
svcsock.c SUNRPC: fix ternary sign expansion bug in tracing 2021-04-22 11:02:28 -04:00
sysctl.c net/sunrpc: fix useless comparison in proc_do_xprt() 2020-11-08 16:28:25 -05:00
sysfs.c SUNRPC: lock against ->sock changing during sysfs read 2022-02-08 09:14:26 -05:00
sysfs.h SUNRPC: take a xprt offline using sysfs 2021-07-08 14:03:24 -04:00
timer.c
xdr.c SUNRPC: xdr_stream_subsegment() must handle non-zero page_bases 2021-10-02 16:10:01 -04:00
xprt.c SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC 2022-03-13 12:59:35 -04:00
xprtmultipath.c SUNRPC keep track of number of transports to unique addresses 2021-08-27 16:36:53 -04:00
xprtsock.c SUNRPC: improve 'swap' handling: scheduling and PF_MEMALLOC 2022-03-13 12:59:35 -04:00