mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-12 21:57:43 +00:00
SUNRPC/call_alloc: async tasks mustn't block waiting for memory
[ Upstream commit c487216bec
]
When memory is short, new worker threads cannot be created and we depend
on the minimum one rpciod thread to be able to handle everything.
So it must not block waiting for memory.
mempools are particularly a problem as memory can only be released back
to the mempool by an async rpc task running. If all available
workqueue threads are waiting on the mempool, no thread is available to
return anything.
rpc_malloc() can block, and this might cause deadlocks.
So check RPC_IS_ASYNC(), rather than RPC_IS_SWAPPER() to determine if
blocking is acceptable.
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
aba111deed
commit
5364fe2992
2 changed files with 6 additions and 2 deletions
|
@ -883,8 +883,10 @@ int rpc_malloc(struct rpc_task *task)
|
|||
struct rpc_buffer *buf;
|
||||
gfp_t gfp = GFP_NOIO | __GFP_NOWARN;
|
||||
|
||||
if (RPC_IS_ASYNC(task))
|
||||
gfp = GFP_NOWAIT | __GFP_NOWARN;
|
||||
if (RPC_IS_SWAPPER(task))
|
||||
gfp = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN;
|
||||
gfp |= __GFP_MEMALLOC;
|
||||
|
||||
size += sizeof(struct rpc_buffer);
|
||||
if (size <= RPC_BUFFER_MAXSIZE)
|
||||
|
|
|
@ -645,8 +645,10 @@ xprt_rdma_allocate(struct rpc_task *task)
|
|||
return -ENOMEM;
|
||||
|
||||
flags = RPCRDMA_DEF_GFP;
|
||||
if (RPC_IS_ASYNC(task))
|
||||
flags = GFP_NOWAIT | __GFP_NOWARN;
|
||||
if (RPC_IS_SWAPPER(task))
|
||||
flags = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN;
|
||||
flags |= __GFP_MEMALLOC;
|
||||
|
||||
if (!rpcrdma_get_rdmabuf(r_xprt, req, flags))
|
||||
goto out_fail;
|
||||
|
|
Loading…
Reference in a new issue