Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp35608391rwd; Mon, 10 Jul 2023 09:46:56 -0700 (PDT) X-Google-Smtp-Source: APBJJlF4bzZhNpB4XQy7afkTLfmspAbb5S/g0fxa3Y9SpJZpYP1dOPA68zTw51roSlqSIbjiTjWR X-Received: by 2002:ac2:5f9c:0:b0:4dd:9f86:859d with SMTP id r28-20020ac25f9c000000b004dd9f86859dmr10025173lfe.13.1689007615960; Mon, 10 Jul 2023 09:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689007615; cv=none; d=google.com; s=arc-20160816; b=nVtp4OIhv+ZuZVse87/Rs1/jjafx7cKxVnE2f9xV1AySnKT+f0J++SkqV93OzYYHHK egsKEWP1H4hW2tpXaM5LYGE738duZudDj0I6aNNyY31QYN46U6f4y3ZZxv6Mb24q82ZQ g7A6JaxHOvSMKM6wguEwjmlOBoxWdMgCQZ95L84/WfWjh3CvyW72O3Yqfja30MSyc+QD uJ+MXNRXqefrIwE6pqAmyGTltZGgTBwIZg59uoa+DZXO13VI5Ndyw5Bw7Oz+75RgIIDn 8b8ZvQl2KmWHQyqlTorMGR+0/jOnNRMI4TuqG+SI4UF1m/xgByABLMNsM6hF5dyLdGLb lxUw== 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=/HNCXhfHG/YkCtWJQQqEAT7pNzEfW4y7zV1OVzCikLY=; fh=1mpseLkGFXp1jGJr9QrS6J8xZJaGrNTaerrRbpi6Fog=; b=ApBYTkRAQen8KvzQmmZmXVPQecza/z/g5KIWMpAk33Fikj6IRkhkpFhoToAiujnjVO Fk/NqTiZYwhRS0FVXYikViNa2B4zVvzM6Mndih1HzhnKwzI4cZLvGZuNOr55+FxckNTY /kvlHB4f0XucIoFb8dNIZ1MxS9lYCqbHvsJJWyMafQ9dNF86VovGp4MMd6iSl/X9iITO 4C5SI9XVuTfZWaOUdOAMg01hi7/EdAzEBab3V2GRst1ThHgbNKyyvifZs6EQzs73Mbbv etMVSQAFnK7wdzT/CFCz29yZ40blKVfLCOtxzq3FkwPVMmk8TgiVkw47rueWGqhXUWkR Atpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ecKq7pFK; 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 s9-20020aa7c549000000b0051deadf8cacsi9405538edr.181.2023.07.10.09.46.31; Mon, 10 Jul 2023 09:46:55 -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=ecKq7pFK; 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 S230245AbjGJQmR (ORCPT + 99 others); Mon, 10 Jul 2023 12:42:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbjGJQmQ (ORCPT ); Mon, 10 Jul 2023 12:42:16 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0B99AD for ; Mon, 10 Jul 2023 09:42:15 -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 89BD761124 for ; Mon, 10 Jul 2023 16:42:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81DFDC433C8; Mon, 10 Jul 2023 16:42:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689007335; bh=6tgxkoGwbdPWA2kjPEvno7uq9F/lgC1ObR+QkLawEUc=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=ecKq7pFKDiFwIPqhhEETrV2RGneR7uRkLs3apDVw4XI343XTOPtW+PfX52pSKL6da EuDFxX1ZPiViJFifA+c0qBu1Dh9+qOPF3Pz2H5/xxHYNSP7GxzbezifAh8FAAVNsaC gpZ7cm6vmiXouooj/JxjSEqkbMT5sHyFF8I1Wl7HS9zHrRzlbMi70kQ3wCLOyFdUlK Fn2rz2urEKJ4lF0VGvfvpImzSGAADeSVebfqKDEQfY1bX9P2pnwJx0zKMfK/hQaN28 3Tij76G9os9MPoQDlT6CdV2RvLERizJXAVtzG0sE9JQ3u3koZZ9AmBIA1kUWsfFBTP 5nBxiT3Nssbsg== Subject: [PATCH v3 3/9] SUNRPC: Split the svc_xprt_dequeue tracepoint 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:13 -0400 Message-ID: <168900733359.7514.13132763975249250052.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=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 Distinguish between the case where new work was picked up just by looking at the transport queue versus when the thread was awoken. This gives us better visibility about how well-utilized the thread pool is. Signed-off-by: Chuck Lever --- include/trace/events/sunrpc.h | 47 +++++++++++++++++++++++++++++++---------- net/sunrpc/svc_xprt.c | 9 +++++--- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index 9b70fc1c698a..2e83887b58cd 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -2015,34 +2015,57 @@ TRACE_EVENT(svc_xprt_enqueue, SVC_XPRT_ENDPOINT_VARARGS, __entry->pid) ); -TRACE_EVENT(svc_xprt_dequeue, +#define show_svc_pool_flags(x) \ + __print_flags(x, "|", \ + { BIT(SP_TASK_PENDING), "TASK_PENDING" }, \ + { BIT(SP_CONGESTED), "CONGESTED" }) + +DECLARE_EVENT_CLASS(svc_pool_scheduler_class, TP_PROTO( - const struct svc_rqst *rqst + const struct svc_rqst *rqstp ), - TP_ARGS(rqst), + TP_ARGS(rqstp), TP_STRUCT__entry( - SVC_XPRT_ENDPOINT_FIELDS(rqst->rq_xprt) + SVC_XPRT_ENDPOINT_FIELDS(rqstp->rq_xprt) + __string(name, rqstp->rq_server->sv_name) + __field(int, pool_id) + __field(unsigned int, nrthreads) + __field(unsigned long, pool_flags) __field(unsigned long, wakeup) ), TP_fast_assign( - SVC_XPRT_ENDPOINT_ASSIGNMENTS(rqst->rq_xprt); + struct svc_pool *pool = rqstp->rq_pool; + SVC_XPRT_ENDPOINT_ASSIGNMENTS(rqstp->rq_xprt); + __assign_str(name, rqstp->rq_server->sv_name); + __entry->pool_id = pool->sp_id; + __entry->nrthreads = pool->sp_nrthreads; + __entry->pool_flags = pool->sp_flags; __entry->wakeup = ktime_to_us(ktime_sub(ktime_get(), - rqst->rq_qtime)); + rqstp->rq_qtime)); ), - TP_printk(SVC_XPRT_ENDPOINT_FORMAT " wakeup-us=%lu", - SVC_XPRT_ENDPOINT_VARARGS, __entry->wakeup) + TP_printk(SVC_XPRT_ENDPOINT_FORMAT + " service=%s pool=%d pool_flags=%s nrthreads=%u wakeup-us=%lu", + SVC_XPRT_ENDPOINT_VARARGS, __get_str(name), __entry->pool_id, + show_svc_pool_flags(__entry->pool_flags), __entry->nrthreads, + __entry->wakeup + ) ); -#define show_svc_pool_flags(x) \ - __print_flags(x, "|", \ - { BIT(SP_TASK_PENDING), "TASK_PENDING" }, \ - { BIT(SP_CONGESTED), "CONGESTED" }) +#define DEFINE_SVC_POOL_SCHEDULER_EVENT(name) \ + DEFINE_EVENT(svc_pool_scheduler_class, svc_pool_##name, \ + TP_PROTO( \ + const struct svc_rqst *rqstp \ + ), \ + TP_ARGS(rqstp)) + +DEFINE_SVC_POOL_SCHEDULER_EVENT(polled); +DEFINE_SVC_POOL_SCHEDULER_EVENT(awoken); TRACE_EVENT(svc_pool_starved, TP_PROTO( diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index a1ed6fb69793..7ee095d03996 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c @@ -744,8 +744,10 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) WARN_ON_ONCE(rqstp->rq_xprt); rqstp->rq_xprt = svc_xprt_dequeue(pool); - if (rqstp->rq_xprt) + if (rqstp->rq_xprt) { + trace_svc_pool_polled(rqstp); goto out_found; + } /* * We have to be able to interrupt this wait @@ -767,8 +769,10 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) set_bit(RQ_BUSY, &rqstp->rq_flags); smp_mb__after_atomic(); rqstp->rq_xprt = svc_xprt_dequeue(pool); - if (rqstp->rq_xprt) + if (rqstp->rq_xprt) { + trace_svc_pool_awoken(rqstp); goto out_found; + } if (!time_left) percpu_counter_inc(&pool->sp_threads_timedout); @@ -784,7 +788,6 @@ static struct svc_xprt *svc_get_next_xprt(struct svc_rqst *rqstp, long timeout) rqstp->rq_chandle.thread_wait = 5*HZ; else rqstp->rq_chandle.thread_wait = 1*HZ; - trace_svc_xprt_dequeue(rqstp); return rqstp->rq_xprt; }