Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2046432rwd; Mon, 15 May 2023 06:39:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4CvAi4HczgtdbJwhHQ35EygeQXUvOr2pG9o2A3dsLQ/03JPlsAp9Ga518Kxu4bgXv/UDqx X-Received: by 2002:a05:6a20:8f08:b0:102:472b:424c with SMTP id b8-20020a056a208f0800b00102472b424cmr25034585pzk.22.1684157995501; Mon, 15 May 2023 06:39:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684157995; cv=none; d=google.com; s=arc-20160816; b=dteFXwk0x/Uu/68bjQ3uP0ArwxVAQ/GjP2c6CmmX0KkjpM9xxNOb4uh1DUWqfLWYm/ 4gXYurr5ZHPaZJyRk+wENCiduL3ugHyiHPx4DkyQ+LjpFah9P8QIhx0doSIOk6hZ+TzJ Nt3ajFgElmWRIBTJzh74RZZTSYbW1/OfJ/H2F84M8XSvQwiD7jqhgiPfQLEOwYNQGyEf R4xhazxeIoYCIRNS6ydaGRTs82e6U+ilYnAA047sgOrj8Y1qKLcA+A5CCV78X51JoFU5 vSkCn6q78Kl0g/dtBpd7UNIKg/HVstO6MwoGcXjUoxv7bGx4K8MSUVx7gWY27kt2wlmA zBFw== 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=5fv61I39NdqtYCEV2RV9Qw61qvbhSZgcuvwUTZgfzaU=; b=Y0i7NPmM6u/OWDWOk7TIQ/IUB/8beqrm51vJiRVzvpjWK73fgk4Ln4BOpXu5KZ3lmL kn+2y5WQv17YOj0lJQEcjS9e0SFrmq3jS6/cB8MtkDOVLkmDylFb8rF9qQqFeT8BipqA YmkE8pvrE8JMRxtAkdpj38LchSnEnRsWjrwAma8OdXZms0mmNquW+1jTcND85Adf0amQ X+hW1IdhU3OleIfuu5SiiMwOOV4qDMB4iNESQzdbxdj8PjZaFgdqKIWcWKazmZhMJ6DC ueYZsRNKSHA4MwR+ViIHXJVa/OhGFb6Y/ZC6URQ3HBIiGuO0Ik2kAzCeB2cxTrH4WKl8 1GvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AHFOaLrJ; 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 k2-20020a63ab42000000b0053079f84a1asi10244342pgp.759.2023.05.15.06.39.41; Mon, 15 May 2023 06:39: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=AHFOaLrJ; 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 S241883AbjEONdG (ORCPT + 99 others); Mon, 15 May 2023 09:33:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241879AbjEONdG (ORCPT ); Mon, 15 May 2023 09:33:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54516E69 for ; Mon, 15 May 2023 06:33:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E5408617FB for ; Mon, 15 May 2023 13:33:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 33754C433EF; Mon, 15 May 2023 13:33:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684157581; bh=UX5dBEOvzI+VJ3/nDoYVwDa423Kh9seDFIkHWcTue6U=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=AHFOaLrJfsOVzi+tsd1sqSf65oxMoZMV2J7+SEEpwVNvLFzWNDK89OwyJ4Ov7dj7U tSjdTG4PxzqMd6cWNOhRqZS/tAeEumDb9Wet0CQAIxuOQIah0m9UPcT9zg0AWjSTEA fOLPFYRtsLvoZoRo3nwBHWJNXX7HRCb5DLQD+UfDjJpNaEaVno15fleMNscOJLlYFd lKHptxEmkdEsQn494qwvfwK4qwJ8W68xAxm96zkSW7r1enykxcAngO2ODUXxR64gcq hEpfVCE26m6HABTi/NoQKeb/1GDQlfH5rDAEtLqybZscLfAnzf4edibK1PlH4w2RBC No0qWZ+LIxQrw== Subject: [PATCH 4/4] SUNRPC: Trace struct svc_sock lifetime events From: Chuck Lever To: linux-nfs@vger.kernel.org Cc: Chuck Lever Date: Mon, 15 May 2023 09:33:00 -0400 Message-ID: <168415758025.9504.3906067170627211847.stgit@manet.1015granger.net> In-Reply-To: <168415745478.9504.1882537002036193828.stgit@manet.1015granger.net> References: <168415745478.9504.1882537002036193828.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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 Capture a timestamp and pointer address during the creation and destruction of struct svc_sock to record its lifetime. This helps to diagnose transport reference counting issues. Signed-off-by: Chuck Lever --- include/trace/events/sunrpc.h | 39 +++++++++++++++++++++++++++------------ net/sunrpc/svcsock.c | 4 +++- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/include/trace/events/sunrpc.h b/include/trace/events/sunrpc.h index 31bc7025cb44..69e42ef30979 100644 --- a/include/trace/events/sunrpc.h +++ b/include/trace/events/sunrpc.h @@ -2104,31 +2104,46 @@ DEFINE_SVC_DEFERRED_EVENT(drop); DEFINE_SVC_DEFERRED_EVENT(queue); DEFINE_SVC_DEFERRED_EVENT(recv); -TRACE_EVENT(svcsock_new_socket, +DECLARE_EVENT_CLASS(svcsock_lifetime_class, TP_PROTO( + const void *svsk, const struct socket *socket ), - - TP_ARGS(socket), - + TP_ARGS(svsk, socket), TP_STRUCT__entry( + __field(unsigned int, netns_ino) + __field(const void *, svsk) + __field(const void *, sk) __field(unsigned long, type) __field(unsigned long, family) - __field(bool, listener) + __field(unsigned long, state) ), - TP_fast_assign( + struct sock *sk = socket->sk; + + __entry->netns_ino = sock_net(sk)->ns.inum; + __entry->svsk = svsk; + __entry->sk = sk; __entry->type = socket->type; - __entry->family = socket->sk->sk_family; - __entry->listener = (socket->sk->sk_state == TCP_LISTEN); + __entry->family = sk->sk_family; + __entry->state = sk->sk_state; ), - - TP_printk("type=%s family=%s%s", - show_socket_type(__entry->type), + TP_printk("svsk=%p type=%s family=%s%s", + __entry->svsk, show_socket_type(__entry->type), rpc_show_address_family(__entry->family), - __entry->listener ? " (listener)" : "" + __entry->state == TCP_LISTEN ? " (listener)" : "" ) ); +#define DEFINE_SVCSOCK_LIFETIME_EVENT(name) \ + DEFINE_EVENT(svcsock_lifetime_class, name, \ + TP_PROTO( \ + const void *svsk, \ + const struct socket *socket \ + ), \ + TP_ARGS(svsk, socket)) + +DEFINE_SVCSOCK_LIFETIME_EVENT(svcsock_new); +DEFINE_SVCSOCK_LIFETIME_EVENT(svcsock_free); TRACE_EVENT(svcsock_marker, TP_PROTO( diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c index 2058641ab9f6..e30716248989 100644 --- a/net/sunrpc/svcsock.c +++ b/net/sunrpc/svcsock.c @@ -1476,7 +1476,7 @@ static struct svc_sock *svc_setup_socket(struct svc_serv *serv, else svc_tcp_init(svsk, serv); - trace_svcsock_new_socket(sock); + trace_svcsock_new(svsk, sock); return svsk; } @@ -1669,6 +1669,8 @@ static void svc_sock_free(struct svc_xprt *xprt) struct svc_sock *svsk = container_of(xprt, struct svc_sock, sk_xprt); struct socket *sock = svsk->sk_sock; + trace_svcsock_free(svsk, sock); + tls_handshake_cancel(sock->sk); if (sock->file) sockfd_put(sock);