From patchwork Tue Nov 3 20:35:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 317145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C94A0C4742C for ; Tue, 3 Nov 2020 20:55:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 99375223AC for ; Tue, 3 Nov 2020 20:55:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604436910; bh=4Jxw72oNKrHSViVlrye7VjWtEQ+cRo52KU5GDCZ1/bQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kgELeTIWt6V21tZtnTQlNM8UtW2+ggfY/68HkKy50/kob03V2dBanCuSsR1NM9Kgg 8ifta2Pid/ZgTKL81TbGcIHxGNqJDMW/dTIfnSdIAtqe4QHFHLxXNrBKRSzYLqhiSu ixBv/GH5jSuHJyz+DndqAEX3R5EpMf13P5x0ewj0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732679AbgKCUzJ (ORCPT ); Tue, 3 Nov 2020 15:55:09 -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 Precedence: bulk List-ID: X-Mailing-List: stable@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) {