Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6861000rwp; Tue, 18 Jul 2023 06:57:28 -0700 (PDT) X-Google-Smtp-Source: APBJJlHdetV4XTn0Ae5cgbjamubShxiHj6RV84ubvtAco7Q1qLNj+STmzWfnJmRSBbSkTy30SOT7 X-Received: by 2002:a05:651c:229:b0:2b4:45bc:7bd with SMTP id z9-20020a05651c022900b002b445bc07bdmr11115399ljn.4.1689688647681; Tue, 18 Jul 2023 06:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689688647; cv=none; d=google.com; s=arc-20160816; b=XLhed/vS70Tlzj/64H5cjc6M2cy21RhsgOQb4mNzhUAAhZ6fDQYO9wEfN0Yk+FRryo UNJd90bYKAT5kCdh5pqbSnYNDt2ebZW1cqlXynhHhJ1mq/bYNAc5Ba3ZEPO074803Gzf 4VltEM7ZEgul7+CpEEQ18+4c1tQ8VAiO/ST/4sierdERsgim49pbYpqUfyA4oC3cKlkM 8JIz85/xEgMj+2RyK4Hpa3GoZGsrudBPUP4gObr2a6e8MphoGTLdxEoosKO4g2yiQTr/ BnmHWZdu0xVzxkZO4f0SGREPzXD/8w+7HgSN0RVfZaiR/cZLymvR29Z6ILyVetV0NNLQ ttEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/d9QVENLaWPKm2vxkEsxZgKndhSA5eI9iwYD3+ot54s=; fh=GniDH+aJfvtvW3D5c5n8OxjCvOwYX5375UdKaAhaISk=; b=lvvVS8DsInktzn2Kwtc0ZJnr9iIVG6FuG0sdIcpA5ttmrns1f6AxTLHyGndijwRduF 3ntCTAHwluxo4+1u7D6Y5JeiU6mz0KHUJ9YHeqB/5fQFxYoBBkB0TXd0sxsXDjPKSTmc zWK6f6URIATjiX+xJyUZNx2LYnSdpYcjrjCcmvQoRb3kdt4+r7HL7NruRhuOs41tHPzt FF7RwyhomtmbdsnjYJj9CsiO0FLMYweOEmYdJ4l2/ZHClMtJnSrpkWgrlf1Fpc89GMID 3rca343u+r5fLo/SypiZHfrJ8xvmjOl//94jDZaJS/GVCa3BsrmCaEKR9dNaDTzEaUKW eoBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=u56V7Wy9; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a25-20020a1709066d5900b0098f99532db2si1114892ejt.666.2023.07.18.06.56.58; Tue, 18 Jul 2023 06:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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=@kernel.org header.s=k20201202 header.b=u56V7Wy9; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232566AbjGRNuD (ORCPT + 99 others); Tue, 18 Jul 2023 09:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232851AbjGRNuA (ORCPT ); Tue, 18 Jul 2023 09:50:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F362FA for ; Tue, 18 Jul 2023 06:49:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C14C761583 for ; Tue, 18 Jul 2023 13:49:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C398BC433C9; Tue, 18 Jul 2023 13:49:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689688198; bh=P4yDgimb8WXF4N26IwGh/4oB0n6rF6dmM6ksyDzxi8I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=u56V7Wy9GMuazeRHXgPtAafzPgcZr9XOvpuuy5oo//lnEtMTOO++1BfFfYkrx7zGP Hs0MleJrKjAIE7RricKuWuaYJ1Pq7WMcII3a8WfjKmC5fHx0m2aCEYEYYHlMwQ1RXA cowgpKXGRMl7p2tGaNfz9HQ9iS8ZMgoAd0NY7aXYer+K0HpIxjJJ6oLeARrhqzGwle cN2gXH+Pehxi3qVwaGV0JyWbr2zvjVWSCYzyoI1vFwAlXin6z9vB/JlcRDfJ89sxMW Fssbtls4DrLZau335wq6fqNzeCUqc/4cBqdg8w8u+CJO0EKyVif5NaRmvr0l9ci36A x/tydiKsG3PMw== Date: Tue, 18 Jul 2023 09:49:54 -0400 From: Chuck Lever To: NeilBrown Cc: Chuck Lever , Jeff Layton , linux-nfs@vger.kernel.org Subject: Re: [PATCH 07/14] SUNRPC: refactor svc_recv() Message-ID: References: <168966227838.11075.2974227708495338626.stgit@noble.brown> <168966228864.11075.17318657609206358910.stgit@noble.brown> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <168966228864.11075.17318657609206358910.stgit@noble.brown> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, 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-nfs@vger.kernel.org On Tue, Jul 18, 2023 at 04:38:08PM +1000, NeilBrown wrote: > svc_get_next_xprt() does a lot more than get an xprt. It mostly waits. > > So rename to svc_wait_for_work() and don't bother returning a value. Or svc_rqst_wait_for_work() ? > The xprt can be found in ->rq_xprt. > > Also move all the code to handle ->rq_xprt into a single if branch, so > that other handlers can be added there if other work is found. > > Remove the call to svc_xprt_dequeue() that is before we set TASK_IDLE. > If there is still something to dequeue will still get it after a few > more checks - no sleeping. This was an unnecessary optimisation which > muddles the code. I think "This was an unnecessary optimisation" needs to be demonstrated, and the removal needs to be a separate patch. I would also move it before the patch adding trace_svc_pool_polled() so we don't have a series with a patch that adds a tracepoint followed by another patch that removes the same tracepoint. > Drop a call to kthread_should_stop(). There are enough of those in > svc_wait_for_work(). A bit of this clean-up could be moved back to 2/14. > (This patch is best viewed with "-b") > > Signed-off-by: NeilBrown > --- > net/sunrpc/svc_xprt.c | 70 +++++++++++++++++++------------------------------ > 1 file changed, 27 insertions(+), 43 deletions(-) > > diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c > index 44a33b1f542f..c7095ff7d5fd 100644 > --- a/net/sunrpc/svc_xprt.c > +++ b/net/sunrpc/svc_xprt.c > @@ -735,19 +735,10 @@ rqst_should_sleep(struct svc_rqst *rqstp) > return true; > } > > -static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp) > +static void svc_wait_for_work(struct svc_rqst *rqstp) > { > struct svc_pool *pool = rqstp->rq_pool; > > - /* rq_xprt should be clear on entry */ > - WARN_ON_ONCE(rqstp->rq_xprt); > - > - rqstp->rq_xprt = svc_xprt_dequeue(pool); > - if (rqstp->rq_xprt) { > - trace_svc_pool_polled(rqstp); > - goto out_found; > - } > - > set_current_state(TASK_IDLE); > smp_mb__before_atomic(); > clear_bit(SP_CONGESTED, &pool->sp_flags); > @@ -769,10 +760,9 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp) > goto out_found; > } > > - if (kthread_should_stop()) > - return NULL; > - percpu_counter_inc(&pool->sp_threads_no_work); > - return NULL; > + if (!kthread_should_stop()) > + percpu_counter_inc(&pool->sp_threads_no_work); > + return; > out_found: > /* Normally we will wait up to 5 seconds for any required > * cache information to be provided. > @@ -781,7 +771,6 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp) > rqstp->rq_chandle.thread_wait = 5*HZ; > else > rqstp->rq_chandle.thread_wait = 1*HZ; > - return rqstp->rq_xprt; > } > > static void svc_add_new_temp_xprt(struct svc_serv *serv, struct svc_xprt *newxpt) > @@ -855,45 +844,40 @@ static int svc_handle_xprt(struct svc_rqst *rqstp, struct svc_xprt *xprt) > */ > void svc_recv(struct svc_rqst *rqstp) > { > - struct svc_xprt *xprt = NULL; > - struct svc_serv *serv = rqstp->rq_server; > - int len; > - > if (!svc_alloc_arg(rqstp)) > - goto out; > + return; > > try_to_freeze(); > cond_resched(); > - if (kthread_should_stop()) > - goto out; > > - xprt = svc_get_next_xprt(rqstp); > - if (!xprt) > - goto out; > + svc_wait_for_work(rqstp); > > - len = svc_handle_xprt(rqstp, xprt); > + if (rqstp->rq_xprt) { > + struct svc_serv *serv = rqstp->rq_server; > + struct svc_xprt *xprt = rqstp->rq_xprt; > + int len; > > - /* No data, incomplete (TCP) read, or accept() */ > - if (len <= 0) > - goto out_release; > + len = svc_handle_xprt(rqstp, xprt); > > - trace_svc_xdr_recvfrom(&rqstp->rq_arg); > + /* No data, incomplete (TCP) read, or accept() */ > + if (len <= 0) { > + rqstp->rq_res.len = 0; > + svc_xprt_release(rqstp); > + } else { > > - clear_bit(XPT_OLD, &xprt->xpt_flags); > + trace_svc_xdr_recvfrom(&rqstp->rq_arg); > > - rqstp->rq_chandle.defer = svc_defer; > + clear_bit(XPT_OLD, &xprt->xpt_flags); > > - if (serv->sv_stats) > - serv->sv_stats->netcnt++; > - percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived); > - rqstp->rq_stime = ktime_get(); > - svc_process(rqstp); > - return; > -out_release: > - rqstp->rq_res.len = 0; > - svc_xprt_release(rqstp); > -out: > - return; > + rqstp->rq_chandle.defer = svc_defer; > + > + if (serv->sv_stats) > + serv->sv_stats->netcnt++; > + percpu_counter_inc(&rqstp->rq_pool->sp_messages_arrived); > + rqstp->rq_stime = ktime_get(); > + svc_process(rqstp); > + } > + } > } > EXPORT_SYMBOL_GPL(svc_recv); > > >