Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35608662rwd; Mon, 10 Jul 2023 09:47:11 -0700 (PDT) X-Google-Smtp-Source: APBJJlGmUvvLXNmEItqh6pPSy7WY+VHQa8+ztQa1qA1WpxnGOz9T83FW3nFYpUukXfZpvFRRJ6u7 X-Received: by 2002:a17:906:2d6:b0:993:f15f:efb7 with SMTP id 22-20020a17090602d600b00993f15fefb7mr7912244ejk.8.1689007631536; Mon, 10 Jul 2023 09:47:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689007631; cv=none; d=google.com; s=arc-20160816; b=uNGrcHxVGlBvxP6r88V0JwNHK7qQ0UO1nG5SBPkBK1wstVqdOPkkR94JdDXRGWmZK8 Pomm9JEwQDd7SS+UsYboLKdYAqDjqnU2hot9QHg07uiPzE80DTejSzQhdxguVXprFRfL dyFyxDh3yUqH7P5onDP6fJFslbJvR68YOKz8L2UrWBCNOSa08wNqF4yXn3mjLGukymtp gzGIaDrdC5vj0SrI/Q8PvBCPacjhqdKSnPEEIwijGm1aZ0AtUECFL6JVTR4b2Uhm2I4A 1MsL0DXXTQ2R+s+uUOYr8SuhetXiRaRpceU9vN5VxjkF4jMuxag67Yb25TmoQklF62n5 /ybw== 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:cc:to:from :subject:dkim-signature; bh=mm2/VSxT/nyZyaun6FUal/cNeUrFTJktqDyqdA59UVA=; fh=1mpseLkGFXp1jGJr9QrS6J8xZJaGrNTaerrRbpi6Fog=; b=guPIe7SeBOlrj7w896h+H9EDAKN9KJq63gmPyv/m37h6Nfrnh6rd9gGhWTO058obhk JhZWkSk1QL7cRi4Q24SQsHLKkErK9yb5x2xAYrwu5fOVqxtovcijYQBcFCKTE49GrXzF jo3axr0BcjSktXJsVevJOdS0np8ScntAk/dwkMhRZunUhGHidGOCA24/idxYI5MGE6Cv dQ0rrQM4Pj8E5MJ5H/R7KMqt7ZXdK7il2A9mWcsduw/LcvHFa4hgHdAGRPECLFP7JXXC i4yOpf2FayzhqbgaCPAIub3Nw+Q5HrVmXu3uG7XYOuBaSdKrSSiJE0iKasNUZkhP1Ftv tElw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fyMH1Ad6; 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 r5-20020a170906350500b0098e1bbc3db1si9608656eja.791.2023.07.10.09.46.45; Mon, 10 Jul 2023 09:47:11 -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=fyMH1Ad6; 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 S230296AbjGJQmd (ORCPT + 99 others); Mon, 10 Jul 2023 12:42:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230281AbjGJQma (ORCPT ); Mon, 10 Jul 2023 12:42:30 -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 4CC0213D for ; Mon, 10 Jul 2023 09:42:29 -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 B21356112A for ; Mon, 10 Jul 2023 16:42:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B09CBC433C7; Mon, 10 Jul 2023 16:42:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689007348; bh=0UTojvHk3XK1psFQA6O+HJqio8NK7M/LxGZkI05qJUI=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=fyMH1Ad6GzWeAYEV8qki5VVo9qVDrpazHjO1Yev4KPhzao2qrMemW+po2HlqQS91O kfs0wCCBM1F0W6cTjhY/m60fI8l0BcYh6AxcE3m1KlRoMB60f8s1C72dZOsYK1IzXP R6YCezuElY5gYjhUtlNt6Gps9VrxoLb6QoBBKBuKz9dvtPvkdm04oFcra9Yn/9vYGZ kkDr8enaLyp2/rz2fTD2VssZr1tl0AE6k/jzb/2AxU3Ya/mWsz6vnabaDrLNKYhlnE noMXb+b5tKjs95XltGplGH/U+X03pvXsQ9np7cpBBLn2k1ijTxRRaURmHFeNcENN+n iSfg65cMnGVEQ== Subject: [PATCH v3 5/9] SUNRPC: Count pool threads that were awoken but found no work to do From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever , lorenzo@kernel.org, neilb@suse.de, jlayton@redhat.com, david@fromorbit.com Date: Mon, 10 Jul 2023 12:42:26 -0400 Message-ID: <168900734678.7514.887270657845753276.stgit@manet.1015granger.net> In-Reply-To: <168900729243.7514.15141312295052254929.stgit@manet.1015granger.net> References: <168900729243.7514.15141312295052254929.stgit@manet.1015granger.net> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 From: Chuck Lever Measure a source of thread scheduling inefficiency -- count threads that were awoken but found that the transport queue had already been emptied. An empty transport queue is possible when threads that run between the wake_up_process() call and the woken thread returning from the scheduler have pulled all remaining work off the transport queue using the first svc_xprt_dequeue() in svc_get_next_xprt(). Signed-off-by: Chuck Lever --- include/linux/sunrpc/svc.h | 1 + net/sunrpc/svc.c | 2 ++ net/sunrpc/svc_xprt.c | 7 ++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h index 74ea13270679..9dd3b16cc4c2 100644 --- a/include/linux/sunrpc/svc.h +++ b/include/linux/sunrpc/svc.h @@ -43,6 +43,7 @@ struct svc_pool { struct percpu_counter sp_threads_woken; struct percpu_counter sp_threads_timedout; struct percpu_counter sp_threads_starved; + struct percpu_counter sp_threads_no_work; #define SP_TASK_PENDING (0) /* still work to do even if no * xprt is queued. */ diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c index 88b7b5fb6d75..b7a02309ecb1 100644 --- a/net/sunrpc/svc.c +++ b/net/sunrpc/svc.c @@ -518,6 +518,7 @@ __svc_create(struct svc_program *prog, unsigned int bufsize, int npools, percpu_counter_init(&pool->sp_threads_woken, 0, GFP_KERNEL); percpu_counter_init(&pool->sp_threads_timedout, 0, GFP_KERNEL); percpu_counter_init(&pool->sp_threads_starved, 0, GFP_KERNEL); + percpu_counter_init(&pool->sp_threads_no_work, 0, GFP_KERNEL); } return serv; @@ -595,6 +596,7 @@ svc_destroy(struct kref *ref) percpu_counter_destroy(&pool->sp_threads_woken); percpu_counter_destroy(&pool->sp_threads_timedout); percpu_counter_destroy(&pool->sp_threads_starved); + percpu_counter_destroy(&pool->sp_threads_no_work); } kfree(serv->sv_pools); kfree(serv); diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index ecbccf0d89b9..6c2a702aa469 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -776,9 +776,9 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) if (!time_left) percpu_counter_inc(&pool->sp_threads_timedout); - if (signalled() || kthread_should_stop()) return ERR_PTR(-EINTR); + percpu_counter_inc(&pool->sp_threads_no_work); return ERR_PTR(-EAGAIN); out_found: /* Normally we will wait up to 5 seconds for any required @@ -1445,13 +1445,14 @@ static int svc_pool_stats_show(struct seq_file *m, void *p) return 0; } - seq_printf(m, "%u %llu %llu %llu %llu %llu\n", + seq_printf(m, "%u %llu %llu %llu %llu %llu %llu\n", pool->sp_id, percpu_counter_sum_positive(&pool->sp_messages_arrived), percpu_counter_sum_positive(&pool->sp_sockets_queued), percpu_counter_sum_positive(&pool->sp_threads_woken), percpu_counter_sum_positive(&pool->sp_threads_timedout), - percpu_counter_sum_positive(&pool->sp_threads_starved)); + percpu_counter_sum_positive(&pool->sp_threads_starved), + percpu_counter_sum_positive(&pool->sp_threads_no_work)); return 0; }