Received: by 10.192.165.156 with SMTP id m28csp310155imm; Tue, 17 Apr 2018 10:29:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/w5zLk7UzYwNNotd19/EoZrQyxCu16cq0+ip9rJzMLK+j6MNxJoP6U2psgmRaYo9JNG/B2 X-Received: by 10.99.126.71 with SMTP id o7mr2450251pgn.366.1523986188032; Tue, 17 Apr 2018 10:29:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523986187; cv=none; d=google.com; s=arc-20160816; b=AWChcotF4ZvWomNNdWEvWEZXkitcGCpoXx/6Q2F6ieszj4ZzKPtkrRbFRwhF4uaqhc IOOk8n26U9s9uoENGmQ2B6kCgwVc5AlNy/2XCcLiYdIgB6J78WuPOsTsbGqsLT0f1YDR aOc3nrwX2kNxPaNxAvDUbhQG32T4e2VFC+DSevtNWS7OoTI2yyg5N7tzRQJpgXwR+D7S Pl/KXPazrj6/Y/pQlJffyCwkzSAMmFNGvEsl4ws8wfFu311mhlEOrt7fLy3+1Tm08N75 bi3t+lJLMdBStzMPKkl7F2Nu+wMXzF0NlespamH25OVULLc9gXHzoRr7nXmKM1TJ//Td SAvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=4vdlGPqJu6Qgr2WLdOy17bsCSOOuSUH55nGFymlS1pY=; b=ebjQeOwU7Dubzt45/fRDe4Dtw3PEQbFq7emQWbF/tUxK67e+EsrXALs+jBDLkM/3Us W2pCC4V26DpbFwQ1E/jCCIVl0u8FxHFmCSOY/79iHcFu9XD2J4PHKgcZCSC5VAvz9Btm tBBuRxhaAh0gaZOfkRDwtErFyfnvV9mbyF61Eqj9TwNaJl72JY9+aYmeOY7LUtYcG93g S1u32NoZOLviUxZrFEFyrWRUXXZtU0JkFDjaQE9VfpzCGZTolUaB5Q60kMDiitmreWUu yjQW7CnwnFdjnzOqXzX38Yy0RJ7iAi8t7Si/iy666gjwxycrmAdsYhOWqAf26uJut2hf 8Lww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PgYfJLJR; 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 94-v6si7340577plb.475.2018.04.17.10.29.33; Tue, 17 Apr 2018 10:29:47 -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=PgYfJLJR; 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 S1752629AbeDQR1r (ORCPT + 99 others); Tue, 17 Apr 2018 13:27:47 -0400 Received: from mail-pg0-f65.google.com ([74.125.83.65]:45357 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbeDQR1p (ORCPT ); Tue, 17 Apr 2018 13:27:45 -0400 Received: by mail-pg0-f65.google.com with SMTP id z21so2006480pgv.12; Tue, 17 Apr 2018 10:27:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=4vdlGPqJu6Qgr2WLdOy17bsCSOOuSUH55nGFymlS1pY=; b=PgYfJLJR+zr743j5avUSlm7Z4ffSdafSGWgPCD3PC38Jk8KqzAvSOW6zDfYmLNbjUA BVObDJX0rjLS7KdHGVIRkVDaBZaYwoo8maa7NieL5CNRwnYl/4xmwvkqvMMPLP+6tDYG PL+l2zi4w5GyfAa+DiI9unIZMsznSn52tdskIKp9BHVm2cv37U0C39xIKg5BQi3qfQ+0 Etr/4ZSgJzeJB+LijzrLx+ItlfbAvfOU6x6+Gg3sW+1CJQqGNO/UlggADk53M9FQafk4 1zTz4tTkGeTZ268Lep2Ov3YDEQ1+GEk3s0BhQAAWRCcNrQGjbhP5JkFcWYLsjCxfIbzi xMMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4vdlGPqJu6Qgr2WLdOy17bsCSOOuSUH55nGFymlS1pY=; b=olx8jtZ35/PXuTpZVswqDUs9PaHSddE7HGfxytw7g6J8igHaFN5oVGJBoWYv600qGk 1gK0do01E5mjed53NhHowF/MlIx3X6dx7k7PWU4l3vQP914hb0pKTs3vDu9NZipYPuTX AlhhYzYgLOkQyG+7PzVnDYsJoR8S9G2nV3zK+H6ek+auiOCBkx6Xla+yA2G2atUEym2e jmWXeGGezK9trOZr8U75/UlZIk1tZ0WOsgxlnVM+61/2gODff2BYSI4nO+7G4yv2P0R9 io/T73Fxsg9sE9mT/Evgb9TSDcxQuPb8aWBEfEZcvLtca6wOftKuxgMDGUOzYxYDo/09 U8ew== X-Gm-Message-State: ALQs6tDGHIBZnsncMHQi1CpV6dXBPQkPqNfvfcyF1mVCxvoKQDNld6EN hWTmFj6aRKRhhaBj3tiKz9HTwgNV X-Received: by 10.99.97.133 with SMTP id v127mr1717344pgb.441.1523986064359; Tue, 17 Apr 2018 10:27:44 -0700 (PDT) Received: from ?IPv6:2620:15c:2c1:103:dcd8:b5d5:bf84:baad? ([2620:15c:2c1:103:dcd8:b5d5:bf84:baad]) by smtp.gmail.com with ESMTPSA id u28sm31701701pfl.15.2018.04.17.10.27.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Apr 2018 10:27:43 -0700 (PDT) Subject: Re: [PATCH v2 net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust To: Yafang Shao , eric.dumazet@gmail.com, davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, songliubraving@fb.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1523983016-11005-1-git-send-email-laoar.shao@gmail.com> From: Eric Dumazet Message-ID: <010ea3d3-7925-4718-8aee-c1f6de6cc608@gmail.com> Date: Tue, 17 Apr 2018 10:27:42 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <1523983016-11005-1-git-send-email-laoar.shao@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 :/ > > 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) > ), > > - 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.