Received: by 10.192.165.156 with SMTP id m28csp1625609imm; Sat, 14 Apr 2018 02:50:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+JYUFF2V3mPvDOL6kHSrw+0JlnjenZMKAehRUFytm010usMd1ju3fStWUAQ6CFhdcFVnyk X-Received: by 10.99.98.66 with SMTP id w63mr5747925pgb.377.1523699410888; Sat, 14 Apr 2018 02:50:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523699410; cv=none; d=google.com; s=arc-20160816; b=BwsTGh6nLBTvtJISiXjtNHi0Ib/Ey/4pb6+BwVIlr6B+QwmZxPlvnPSGMY0icvCgZL OeaBZZ6uwePIixY7WXyP7xUzxs3nvyaFzW7InVbAwg9uZYahDw7Ka7i8hxXkpiQW8Urr oOOsQQVLaxTlqb4wGdVNW9JM+bGBKCU6S9dzUkith0FbVXBU5+X072aVmcz0/KaMGwWn fxHKhOmlsodS1lkjmFpjr80uD0zBXDQBWPhxva1sngAfyq0szPCY55xxzJf6ToCJhpGQ sj7b+lgxhcYabbKl0XFe77K2TlQCEn3Kru13nHanSMKtpJ4IXaH0MhPlRfcvENe9/E8u RCCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=AlhCUbQ0/OPjDOYyvWL6ekzq//iJCXqf0mUlMGelEe8=; b=hFYXMMRF1rFH4yrAOFVA7kCMiTnv/pd5BqWIawnk/XpC8mI+BZZoPRDT8Y6YGX1UK9 UAx9cAtwJaWpu/ncMhxkvSdW9MQ79hcDBGIrzUKOvmE7i25aDk+1rZFxDXDKvJ+2U9fa cNZvLvD6WRaaq17JG7rAnYfSH1Q6EsoOCBQY76NDa8fF/PcP1iIvsloEUQFoEIJNrxlz rnvlXIzmAM8qyei6hkXm2wFjuQYEH9shwANxNrSxVAOk922IBAO0EnJ8b73heP2KjfIc QfP7154Yj3WvOQ1F+w0Y7C4Fzhiw4C2wOajrDB3I01RrcsUBZ4KoaIUwFaH0FwTCrCFM zWnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DBBPZZEw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x190si5923007pgx.378.2018.04.14.02.49.56; Sat, 14 Apr 2018 02:50:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DBBPZZEw; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132AbeDNJsn (ORCPT + 99 others); Sat, 14 Apr 2018 05:48:43 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:40592 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750880AbeDNJsk (ORCPT ); Sat, 14 Apr 2018 05:48:40 -0400 Received: by mail-pf0-f195.google.com with SMTP id y66so7926820pfi.7; Sat, 14 Apr 2018 02:48:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AlhCUbQ0/OPjDOYyvWL6ekzq//iJCXqf0mUlMGelEe8=; b=DBBPZZEwS7NzHw+2P+nT+2heaGv/IohJbvOr+27D1y1vfd/HChfhKfGWI0jYzJ9krn rSagLaKnxpOPJy+qD+in79rh3MjHtOqZ3/Niqa9KXyxyqYSuH1lEJkry466YWZt66A3k LB3sZVROMJAth6UYEUuHZEw5O9hk9Wdyw1p1lpl+W9SIC5KO55BitMZqI87FMJZJON6U 0GNIMKivjYJPekA+QGE1jCL5aw9JK92WE/qxoC85Y0Zapbx46Bz0fO8Pgk1YPqe/Y+ml W73Cf+HbkUawi4E5LV513v+idVrV2EpHEmat6XbvFrflkLQsRfU7CJVZNQODLTHYHnRM yaSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=AlhCUbQ0/OPjDOYyvWL6ekzq//iJCXqf0mUlMGelEe8=; b=iBB3BvAI7N63XV4ZOP5cu+R4hTs+E5JTCvQLymzT5iHFnPb7lYFsYAll9DW9jDqb8F gCiijdS+BeV4QBPzqWeD8SdqnkQVKSelwNiLE4RgRRa0hKauqiUbFlB10ovnCaA32U+6 Fx9XE13uAfuhQLnvq4rchzUR0tX29Fd4c8vgkI+slbHEsadFcai5Qstx1hsj9nPfGC7Z Qfp+W5nRYIUPLabOIVaXoXghJZM443z8SfSwB/zeIJA33TcHYdaJ/UGy2lmQ3GmYSWFy lDYTgpaaejGNQeX13tQRXXP9EtjCLNerwXIApSX0NDQV4pgOsSd+HFJy9xvHspzi7ap9 oyiA== X-Gm-Message-State: ALQs6tDwUFN8nOWwIrr+ST0+tVkfJ6rMo6rc3FOtIubuA4Qi85jAOyoG AgT/kLespfAknHzXAv7ycRM= X-Received: by 10.98.67.141 with SMTP id l13mr14547512pfi.166.1523699320180; Sat, 14 Apr 2018 02:48:40 -0700 (PDT) Received: from li1588-6.members.linode.com (li1588-6.members.linode.com. [139.162.104.6]) by smtp.gmail.com with ESMTPSA id z78sm15955892pfd.23.2018.04.14.02.48.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 14 Apr 2018 02:48:34 -0700 (PDT) From: Yafang Shao To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, songliubraving@fb.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust Date: Sat, 14 Apr 2018 17:48:23 +0800 Message-Id: <1523699303-15699-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org tcp_rcv_space_adjust is called every time data is copied to user space, introducing a tcp tracepoint for which could show us when the packet is copied to user. This could help us figure out whether there's latency in user process. When a tcp packet arrives, tcp_rcv_established() will be called and with the existed tracepoint tcp_probe we could get the time when this packet arrives. Then this packet will be copied to user, and tcp_rcv_space_adjust will be called and with this new introduced tracepoint we could get the time when this packet is copied to user. arrives time : user process time => latency caused by user tcp_probe tcp_rcv_space_adjust Hence in the prink message, sk is printed as a key to connect these two tracepoints. Maybe we could export sockfd in this new tracepoint as well, then we could connect this new tracepoint with epoll/read/recv* tracepoint, and finally that could show us the whole lifespan of this packet. But we could also implement that with pid as these functions are executed in process context. Signed-off-by: Yafang Shao --- include/trace/events/tcp.h | 21 +++++++++++++++------ net/ipv4/tcp_input.c | 2 ++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h index 878b2be..65a6d22 100644 --- a/include/trace/events/tcp.h +++ b/include/trace/events/tcp.h @@ -146,10 +146,11 @@ sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); ), - TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c", + TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c sock=0x%p", __entry->sport, __entry->dport, __entry->saddr, __entry->daddr, - __entry->saddr_v6, __entry->daddr_v6) + __entry->saddr_v6, __entry->daddr_v6, + __entry->skaddr) ); DEFINE_EVENT(tcp_event_sk, tcp_receive_reset, @@ -166,6 +167,13 @@ TP_ARGS(sk) ); +DEFINE_EVENT(tcp_event_sk, tcp_rcv_space_adjust, + + TP_PROTO(const struct sock *sk), + + TP_ARGS(sk) +); + TRACE_EVENT(tcp_set_state, TP_PROTO(const struct sock *sk, const int oldstate, const int newstate), @@ -265,6 +273,7 @@ TP_ARGS(sk, skb), TP_STRUCT__entry( + __field(const void *, skaddr) /* sockaddr_in6 is always bigger than sockaddr_in */ __array(__u8, saddr, sizeof(struct sockaddr_in6)) __array(__u8, daddr, sizeof(struct sockaddr_in6)) @@ -285,6 +294,8 @@ const struct tcp_sock *tp = tcp_sk(sk); const struct inet_sock *inet = inet_sk(sk); + __entry->skaddr = sk; + memset(__entry->saddr, 0, sizeof(struct sockaddr_in6)); memset(__entry->daddr, 0, sizeof(struct sockaddr_in6)); @@ -305,13 +316,11 @@ __entry->srtt = tp->srtt_us >> 3; ), - TP_printk("src=%pISpc dest=%pISpc mark=%#x length=%d snd_nxt=%#x " - "snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u " - "rcv_wnd=%u", + TP_printk("src=%pISpc dest=%pISpc mark=%#x length=%d snd_nxt=%#x snd_una=%#x snd_cwnd=%u ssthresh=%u snd_wnd=%u srtt=%u rcv_wnd=%u sock=0x%p", __entry->saddr, __entry->daddr, __entry->mark, __entry->length, __entry->snd_nxt, __entry->snd_una, __entry->snd_cwnd, __entry->ssthresh, __entry->snd_wnd, - __entry->srtt, __entry->rcv_wnd) + __entry->srtt, __entry->rcv_wnd, __entry->skaddr) ); #endif /* _TRACE_TCP_H */ diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 367def6..4b4d6b9 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -582,6 +582,8 @@ void tcp_rcv_space_adjust(struct sock *sk) u32 copied; int time; + trace_tcp_rcv_space_adjust(sk); + tcp_mstamp_refresh(tp); time = tcp_stamp_us_delta(tp->tcp_mstamp, tp->rcvq_space.time); if (time < (tp->rcv_rtt_est.rtt_us >> 3) || tp->rcv_rtt_est.rtt_us == 0) -- 1.8.3.1