Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3617995pxb; Tue, 19 Apr 2022 06:42:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLr1SUpi8S+6vu51mCC9dYJhzps1z7LMQ5hYNaJ7LDn242eAaiJsa5moq2aLFd8zEQrRBr X-Received: by 2002:a17:906:d54b:b0:6df:7cff:42b7 with SMTP id cr11-20020a170906d54b00b006df7cff42b7mr13437627ejc.731.1650375743425; Tue, 19 Apr 2022 06:42:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650375743; cv=none; d=google.com; s=arc-20160816; b=ev7HK2W+EKHwkVrM9k1MBFTs4xYvv/cSTq8WXcq5ptjUIjlrXYRiXpFlTbMW992h2x 9N/YrjjIW/4RVEbX7ur/opx7zJmwiFE/FZwkgX0YdkODhQAeZo0W05airPCc93oTTDls ZH3bRTw2hGqHZ/xZAUIxxbf0Y4F6OdLWxUcHtNS5hJkEk0MjNjvKyEd7Kpda7a1pa/Sv 0q/d0K775j/Jk6v1yWHRQZC6xByM7OSPNG9L1g9FNyCYCRuCHjiZ9OPQ1AEhePvKJLE0 4YcmdiDDH9IaiZaW9hr7CLrB/RPJfmvRxeyzQWOQBYjbzxKVhgws4fwlIfMbJq1DmPPs aUiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SulCmwiVaZtocFkDO6woUQjDKmHAXiX0BLMuUWXqsvg=; b=ZspzAxKf4pgv7kLD9bCox4mEYf7c+EAgQExdfeYPuFaalcWzgVyilYUbPo5xpp5hoA 6gH6/lzmoyhqIU0BrLuQMcTtEDonHYPydJ0Gwhr2io2PKD6lknmmG2iwgDuj+aQlIIVo vP+NKuSov7m6kFuXM7CrVzSRQD8vmqhN9tvaQkdoNBwXUyA4b2Xvs56DNsqISQoaIEPi 8KfLqpGHJHqxTQCPiFF2UBkEpgoWOIiOswjY6bA/QDn5+UhNpMHFokp1iU1NbszdoXIq 41ADTWF+wR0QLqoaf4g+1zIhpAZhvKp1mWL8N2aLEqqezixXRwShS/yuEKfLsRZuYmEO Fhbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O7CcXwUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r6-20020a50aac6000000b0041cc318987fsi8725366edc.550.2022.04.19.06.41.57; Tue, 19 Apr 2022 06:42:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=O7CcXwUB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245075AbiDROBR (ORCPT + 99 others); Mon, 18 Apr 2022 10:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242302AbiDRNjO (ORCPT ); Mon, 18 Apr 2022 09:39:14 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062892E6AB; Mon, 18 Apr 2022 05:58:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id CD674B80EC3; Mon, 18 Apr 2022 12:58:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27BD3C385A7; Mon, 18 Apr 2022 12:58:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286734; bh=wtfqNst6K4hfexhqxmxSOroEH8SOUtlwIWYGv2Z1h3M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O7CcXwUBXkmE3ejF1tyDWEZ5KoLWqFdLlWD431medZEl4ktrlIFG1NtWNiHyq5U/d +YVfarrqNA+bkFWN+J3I9YXrEZuK2SbHZKpfcxvrxyxsnq5YUdcRHl6JpoVFyloE5z d4oIHbzXslWtiqXqvn/R2WeJGJZTmCiVq9Dk5AgI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, NeilBrown , Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 229/284] SUNRPC/call_alloc: async tasks mustnt block waiting for memory Date: Mon, 18 Apr 2022 14:13:30 +0200 Message-Id: <20220418121218.227245899@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: NeilBrown [ Upstream commit c487216bec83b0c5a8803e5c61433d33ad7b104d ] 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 Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- net/sunrpc/sched.c | 4 +++- net/sunrpc/xprtrdma/transport.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 253132130c42..4e0ebb4780df 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -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) diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c index ead20e6754ab..90c99919ea30 100644 --- a/net/sunrpc/xprtrdma/transport.c +++ b/net/sunrpc/xprtrdma/transport.c @@ -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; -- 2.35.1