Received: by 10.192.165.156 with SMTP id m28csp541080imm; Tue, 17 Apr 2018 14:56:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49yLudj5VgyGyxqgdlHyoCP30XsZ+KvtLfDJ971+9mh04E4y+nVSm71pNt6p15xSWseC0bF X-Received: by 10.98.0.15 with SMTP id 15mr3463348pfa.72.1524002170442; Tue, 17 Apr 2018 14:56:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524002170; cv=none; d=google.com; s=arc-20160816; b=iyJiJGDKSefUGZibxh5kprs/+YAPt0xZxj+jLxX7zrIP6Hym9h+skvbLZsoH0G1u99 ZKQfZjv5VqR3l5bmFYHzOOFqbhdcjVvV6HwAL5W2vl/N0WHRZ0h8IlKiMz/ABnZFTDHP 8zJn0h9Gl84i6rkH4MpXjghlV/bpDo1TsuOWgC+pE3DmdgZtoSIuYJBlNjSyTLNk3wyf a7SZzCpCcZ1RqoGgTu+ufb6diWFtHJPZswxOo7giz8GStX/vWawOFBNyJXPVafDjbDAe +JGLWXxC4n0tVxklu33zaFjg3I1YKPkhZzyV5jBQbFkUOSeYwXU1SZ5VCabsShih9Sno hbfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=K//I54m0grzKhjngPHcGjBhlOcIAsPO5dkrc2yn29H4=; b=CgDDWSmTre8WwbyDjXq5FIKjUFqJrezgWCkRs++XABbs/2o/zfU/w2hDIwHcwTAA3j lLCj6F9wL7LL/kZ5QFOZYEllsMCZ7TDroj9IivimoDUC/N+V+N/dtDd57rNARl3aM2wL Rr7HpW/JzyX4EVoJU58KsQG2r7KB0o6csWJ+E93s2w4NuILfMFNUTl58iCKUnGFC+yKX v3b7PI+/jB9+erBQZPG7MkuiIG26B7J+3icSU06QbrNdDdAnP9IZzIZMLcJfBHzOy2Xb +lFxoEwe6GxUMVBO1GgetCjlrXkPObvFWVZvyuIGk3BdVrhhVw31bpndqzDq/1B7wlv3 ePiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uCKBBoYg; 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 o69si13901224pfi.322.2018.04.17.14.55.55; Tue, 17 Apr 2018 14:56: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=uCKBBoYg; 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 S1753180AbeDQVyK (ORCPT + 99 others); Tue, 17 Apr 2018 17:54:10 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:40838 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752606AbeDQVyJ (ORCPT ); Tue, 17 Apr 2018 17:54:09 -0400 Received: by mail-it0-f68.google.com with SMTP id u62-v6so18184800ita.5; Tue, 17 Apr 2018 14:54:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=K//I54m0grzKhjngPHcGjBhlOcIAsPO5dkrc2yn29H4=; b=uCKBBoYgwc+dsNLGZWINVPmIGaPOB79iWzS81n35BfcAjicWesvkd6LyibZgemT82P nJGh7gckwZbfGFrm6RTrRWIFI8mNLGYsSmdQKvzDj5VOYLbUVfpCi4XRc92UNcJHdV4H eCWgz0kghPv0sgdqkqnSBGHnfejlPeEKk3ttVE6pdFnvujAZcK072KNcJsedV1BWqokZ 3/NAMj5oJ+2PO37FJRWAxSxTqf75iKdC2Gl5AGLNcKxUMLpp8qoOTyfIdfRzOT+YAOpX PgdalFMd8ezimyUPdwWhqWMPuMr9WQ33x8iOLspGOVUlKfPc4A1lC21KDIqCHMquxceR 8gPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=K//I54m0grzKhjngPHcGjBhlOcIAsPO5dkrc2yn29H4=; b=VoKXkim7ebegXMsG8/KY/VbvEmZWhPGj5aoLT0PCSixdM86YacCgH7CEKmWAmUJf3z ElRlFFlJ5xc7bLzyCrelIHGdH4598/u4xhPCoCC0o+zvbGsvW0ehzpsNWitF/Q86KNlr Rn6Xk9M7N9YyTWERIA7b0ke/70D4FtHa52/f/cZuuhDjJR5GMGxP2/6+Hi0KFu5z7Jh7 X6AfpqffWcR8j3j5miRjdujClNsXZSBcepPHKvQZigRLHcePDVVv4ZwbnBlP+Y9MfVEX mGmCnaLU40oWbfa2sMKBTG2qQNiBbobijkWhvWdrEN8o6kPU/pHrEp3L92AeavCXPg6x fNaA== X-Gm-Message-State: ALQs6tAL4GWbv2MHOrqFZWWrUB/scUOtz6hJ0JiIhJCHPZJsc0gM7aGj L7gSw/Z9mtbpIPw6ckuWiauoIV/qUuIJnOUq154= X-Received: by 2002:a24:1a13:: with SMTP id 19-v6mr3010708iti.142.1524002048500; Tue, 17 Apr 2018 14:54:08 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.181.10 with HTTP; Tue, 17 Apr 2018 14:53:28 -0700 (PDT) In-Reply-To: <010ea3d3-7925-4718-8aee-c1f6de6cc608@gmail.com> References: <1523983016-11005-1-git-send-email-laoar.shao@gmail.com> <010ea3d3-7925-4718-8aee-c1f6de6cc608@gmail.com> From: Yafang Shao Date: Wed, 18 Apr 2018 05:53:28 +0800 Message-ID: Subject: Re: [PATCH v2 net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust To: Eric Dumazet Cc: David Miller , Alexey Kuznetsov , yoshfuji@linux-ipv6.org, Song Liu , netdev@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Apr 18, 2018 at 1:27 AM, Eric Dumazet wrote: > > > On 04/17/2018 09:36 AM, Yafang Shao wrote: >> 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 > > Sorry, I could not parse these :/ > Sorry for the poor expression. Will improve it. I mean with these two tracepoint we could calculate the latency that if the user process can't process this packet immdiately. >> >> Hence in the printk message, sk_cookie is printed as a key to relate >> tcp_rcv_space_adjust with tcp_probe. >> >> Maybe we could export sockfd in this new tracepoint as well, then we >> could relate this new tracepoint with epoll/read/recv* tracepoints, 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 >> >> --- >> v1 -> v2: use sk_cookie as key suggested by Eric. >> --- >> include/trace/events/tcp.h | 33 +++++++++++++++++++++++++++------ >> net/ipv4/tcp_input.c | 2 ++ >> 2 files changed, 29 insertions(+), 6 deletions(-) >> >> diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h >> index 3dd6802..814f754 100644 >> --- a/include/trace/events/tcp.h >> +++ b/include/trace/events/tcp.h >> @@ -10,6 +10,7 @@ >> #include >> #include >> #include >> +#include >> >> #define TP_STORE_V4MAPPED(__entry, saddr, daddr) \ >> do { \ >> @@ -125,6 +126,7 @@ >> __array(__u8, daddr, 4) >> __array(__u8, saddr_v6, 16) >> __array(__u8, daddr_v6, 16) >> + __field(__u64, sock_cookie) >> ), >> >> TP_fast_assign( >> @@ -144,12 +146,24 @@ >> >> TP_STORE_ADDRS(__entry, inet->inet_saddr, inet->inet_daddr, >> sk->sk_v6_rcv_saddr, sk->sk_v6_daddr); >> + >> + /* >> + * sk_cookie is used to identify a socket, with which we could >> + * relate this tracepoint with other tracepoints, >> + * i.e. tcp_probe. >> + * If we needn't this relation, then sk_cookie is useless; >> + * if we need this relation, then tcp_probe is already set, >> + * and sk_cookie is already set in tcp_probe, so we could get >> + * the value directly. >> + */ >> + __entry->sock_cookie = atomic64_read(&sk->sk_cookie); > > Please scrap this comment and simply use the real thing. > > _entry->sock_cookie = sock_gen_cookie(sk); > > We build generic events. > > Being able to filter many TCP events on one socket cookie will be useful > > If you worry about sock_gen_cookie(sk) being too expensive, then we can add an inline helper > for the fast path (when sk_cookie has been already set) > Will improve. >> ), >> >> - 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_cookie=%llu", > > > iproute2/ss command uses hexadcimal output for socket cookie. Please use %llx for consistency. > OK