Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp829237pxb; Tue, 3 Nov 2020 13:44:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzmeFXmEftk1aFVSryYp1k5xnJKAH1f4rtcx1lekwEFADKeTq5N/98ZJSEwyz/pJTzI6Qcq X-Received: by 2002:aa7:ca4d:: with SMTP id j13mr23339756edt.119.1604439898758; Tue, 03 Nov 2020 13:44:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604439898; cv=none; d=google.com; s=arc-20160816; b=FSXE5G3VewxBnfIJAr4W6Qgv/cNLDn2dk+X/2SpAx7T9saDx/DqwuN8b3dGwRPF35t oNylsxpXkg0xs2fnp3LQOkJ2NX76CL3BGrEaZ3HCSDOyvZOoJW4scXgM5RlhgAjrHDxj 6ncSX7jb5Qc0+UULA5GDPjo4ik2cCrXAOSzFBVwdz3mw7XGKuka3ReHtyNITwDUbknie D8xWdPIjgcf8d3zN6XFMpORivm7JfAjGQBVzHgWWQS1YcL+M4F4UQHZfyKDOll+iqC1q IKTRAhaNvT1cnhrQQly1zjGRBe88CWacHJmKF1VRLgSZpck2G28xqhRzBIXQCwenkZFm N2cA== 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=mzOxo4PsOd4a0DFl0513YTHZlYhqsxUeHGMQVLWj2N0=; b=z8rlzQKwIePzUXWuiwC3qPYIfZVktMJwjf2VQh3DMsTwMKq9MXZbIyHX2Sz+CKMB1o q8PUqs8f1RTy5b0+XrvU78+xC0TmgL4MiUd68AZKXjB5K+HUP5lAD4anupkwN+tUq7ja IzVn2tY+qS/CfV0KfR2vTwJfw6eCrbCyqRp92FWWa4Cwd2x0bR9Va2NkRdy2wxfjEyEL lKRO4oid7dh9PDvg5kCm7CgfK4yjFrmX00+OIRww3rPx8FEqpFp6YuL5cHgBo9+iZC3R 9FqgyxmmAtBSV6pIxjRnIMPWyW0NTtRbFxxqO0QBz2DZvzKXh6X7Uv8lJwAL7inAL9ML SHxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YCjNBCGX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n15si14789726edw.94.2020.11.03.13.44.35; Tue, 03 Nov 2020 13:44:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YCjNBCGX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732024AbgKCUzZ (ORCPT + 99 others); Tue, 3 Nov 2020 15:55:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:55082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732671AbgKCUzG (ORCPT ); Tue, 3 Nov 2020 15:55:06 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B2EF8223BD; Tue, 3 Nov 2020 20:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436906; bh=4Jxw72oNKrHSViVlrye7VjWtEQ+cRo52KU5GDCZ1/bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YCjNBCGXhUfrHl2/WEF47pFvUa/Gve1HscGZ89z9fja/K4ahBwHRsmIGs3XUhwWad 3I2R55jPTwBvIumVlKGy9EyG4ZmgwL00HDOCPhhUBaopK2P+UUcUAL6vGys5WkwTRk 2Ku3PMlYPdaG0jkngH8gPmTeYEvkk305qOPxPNz4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chuck Lever , Anna Schumaker , Sasha Levin Subject: [PATCH 5.4 061/214] SUNRPC: Mitigate cond_resched() in xprt_transmit() Date: Tue, 3 Nov 2020 21:35:09 +0100 Message-Id: <20201103203256.087374718@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203249.448706377@linuxfoundation.org> References: <20201103203249.448706377@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chuck Lever [ Upstream commit 6f9f17287e78e5049931af2037b15b26d134a32a ] The original purpose of this expensive call is to prevent a long queue of requests from blocking other work. The cond_resched() call is unnecessary after just a single send operation. For longer queues, instead of invoking the kernel scheduler, simply release the transport send lock and return to the RPC scheduler. Signed-off-by: Chuck Lever Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- net/sunrpc/xprt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 41df4c507193b..a6fee86f400ec 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1503,10 +1503,13 @@ xprt_transmit(struct rpc_task *task) { struct rpc_rqst *next, *req = task->tk_rqstp; struct rpc_xprt *xprt = req->rq_xprt; - int status; + int counter, status; spin_lock(&xprt->queue_lock); + counter = 0; while (!list_empty(&xprt->xmit_queue)) { + if (++counter == 20) + break; next = list_first_entry(&xprt->xmit_queue, struct rpc_rqst, rq_xmit); xprt_pin_rqst(next); @@ -1514,7 +1517,6 @@ xprt_transmit(struct rpc_task *task) status = xprt_request_transmit(next, task); if (status == -EBADMSG && next != req) status = 0; - cond_resched(); spin_lock(&xprt->queue_lock); xprt_unpin_rqst(next); if (status == 0) { -- 2.27.0