Received: by 10.192.165.156 with SMTP id m28csp322006imm; Tue, 17 Apr 2018 10:41:14 -0700 (PDT) X-Google-Smtp-Source: AIpwx48R8f8pbkMXEFgSMuMJd8krCy4I+CivB7R1jjXFkkE2V9GD4K9jY2wsz5Buo+RDI+HfyZuJ X-Received: by 2002:a17:902:591e:: with SMTP id o30-v6mr2852108pli.309.1523986874601; Tue, 17 Apr 2018 10:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523986874; cv=none; d=google.com; s=arc-20160816; b=awpAkbFibbaQwlIgG/l2XsxU+Tg8Ch/O7GZ3sRcjWjXoc4D4gst9VEOii2ri6ZaAyT 4QvqbkHZ3y+32BeXQdTkA1RCg9ns36H0ZwFbvBc/aBcfD+FOnZrD7uB7AOUVSgHHKBX8 CoGZ40P6IWi/jr55GNO4MtTfYvhnmbf7BEbcGppeDN1kJeQgHxEhAOp48BojG3ppVe8h YePLcXLMMlcdLyWod8+pgtQnwUW5WMOp87rYCCCACG/+KGKp5jN1Q2BZSEXaO7BVUvLJ RhxREUsH7nRwrjYy0j7+8/gO0ReDQpnYZAqeTX4OBk6Rn5OXCJD5QTkYZqAbwDDLYMV3 6HMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:spamdiagnosticmetadata:spamdiagnosticoutput :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=YfB+BTeplrK0t0AuXMiStQ6vW90Um9rvQEbcEXZwdAw=; b=dR5kAH0SoDyEAPv63fZ59q7bxBWkEAoXBtpinqG0GJAHrYtBDwwvVJnxdZFImPpEIL E3PCPQHTzsHVZNUp9YiJp3X6O1i/+DtKEDBghFgOf8o6Ks2Qg5Tedtx8C6c5tFipordw qTExM8pI8/l71Fb1cvfcanFMAKePjh27nqWMPMGN+rIEdq/8B+ApEOhfO1GnXPOotExi izeNqHi6HUclAwpvGBmW8Cbxqw2DgmN+F6fh1Bjc1yxjdKL7zMPAtAYX/CX6Bx1Bqazp N5KahpLeaHxdO0tKN5BNqemcNjnT2Zc0rAk0ds4Hujvcq2PddeiDRKFThy+FP8SmTj/H 6KPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=R1bpTrQH; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=SMlDzKxV; 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=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3-v6si372547ply.356.2018.04.17.10.40.59; Tue, 17 Apr 2018 10:41:14 -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=@fb.com header.s=facebook header.b=R1bpTrQH; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=SMlDzKxV; 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=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684AbeDQRjX (ORCPT + 99 others); Tue, 17 Apr 2018 13:39:23 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:60634 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751230AbeDQRjV (ORCPT ); Tue, 17 Apr 2018 13:39:21 -0400 Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.16.0.22/8.16.0.22) with SMTP id w3HHXkXQ020050; Tue, 17 Apr 2018 10:38:51 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=YfB+BTeplrK0t0AuXMiStQ6vW90Um9rvQEbcEXZwdAw=; b=R1bpTrQHVTl5aqWbwFVdW5omhGTdvf48tAqjQNFZdlbbMuvEZY38w6E1ez0Srhdu+oqu qqpLdQc2cgeHxS/5WrQCOCFbad/VCVEGencAUDWLa6RrPWL3m6ruCvwVrwaOIRgoNL35 0yWHpRPqVzOetlngJlE+6sc/OXM+5XZEP9U= Received: from mail.thefacebook.com ([199.201.64.23]) by m0089730.ppops.net with ESMTP id 2hdn5y827c-17 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 17 Apr 2018 10:38:51 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.22) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 17 Apr 2018 10:38:41 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YfB+BTeplrK0t0AuXMiStQ6vW90Um9rvQEbcEXZwdAw=; b=SMlDzKxVFTc0GabUEc+ntw9bwVw5giNxCaXn0iPcqdHjJOXOVL9+oAbupSCkvuhrOStEO5KvmOjT8Ga9bMKbXDZaFhnUtcGjwKlHjQ7r8bnUZJoQwYL0ykzGkx2wfJ2sd1SZlOnd1UMdsYnSOJJCIHp4H9vBWQKMkEZqyISsOB0= Received: from DM5PR15MB1548.namprd15.prod.outlook.com (10.173.222.139) by DM5PR15MB1642.namprd15.prod.outlook.com (10.175.105.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.10; Tue, 17 Apr 2018 17:38:40 +0000 Received: from DM5PR15MB1548.namprd15.prod.outlook.com ([fe80::d87a:fa34:57e7:1e2c]) by DM5PR15MB1548.namprd15.prod.outlook.com ([fe80::d87a:fa34:57e7:1e2c%17]) with mapi id 15.20.0675.015; Tue, 17 Apr 2018 17:38:39 +0000 From: Song Liu To: Yafang Shao CC: "eric.dumazet@gmail.com" , "davem@davemloft.net" , "kuznet@ms2.inr.ac.ru" , "yoshfuji@linux-ipv6.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust Thread-Topic: [PATCH v2 net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust Thread-Index: AQHT1mqJ9xgfIFuRz0WmbFf0D1CdOKQFOQAA Date: Tue, 17 Apr 2018 17:38:39 +0000 Message-ID: References: <1523983016-11005-1-git-send-email-laoar.shao@gmail.com> In-Reply-To: <1523983016-11005-1-git-send-email-laoar.shao@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3445.6.18) x-originating-ip: [2620:10d:c090:200::5:6fff] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR15MB1642;7:c+eAhB/A4fg0L2eWieWcbnPz3TNIeAO2MHy+p06uNJTPJqhzhvfRvgEcnaSTdlsKQ8XAAlSy9hRnXLEDgG0nUVBlFLape4safI/jkvivCmSl+2V56dWu14+JNMOXw48O5ULg1RrsTDYCeDJfrsIOVC5OJFZbG/w2V43wG6oaQdEDmpj2b2WDKsNKWUx36QxK4T0O1q+BXLe3BhNvkp58XGGlMERfyWm2IFDktwT3aEO7wND5ku7p2lY63F0MVU1Y;20:TtxiD2JJJ+KsGupfPLzyZLbIteBAx08EQr3fAtLqVMwE2UlqNrvMLaNUfCB9Eev9i+i6gHgGxjqMkPm5nW2VUXrbmxL5jFVm//TNbD7l1CBynxolvx2whtmVXvQEVL1gka/AP18GtjDaGn6Sn7HpY1n1OH+724wUsjUZhMkNXjI= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DM5PR15MB1642; x-ms-traffictypediagnostic: DM5PR15MB1642: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(85827821059158); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(3231232)(11241501184)(944501327)(52105095)(10201501046)(6041310)(20161123562045)(20161123564045)(20161123560045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR15MB1642;BCL:0;PCL:0;RULEID:;SRVR:DM5PR15MB1642; x-forefront-prvs: 0645BEB7AA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(376002)(346002)(366004)(396003)(39380400002)(199004)(189003)(59450400001)(39060400002)(68736007)(2616005)(478600001)(5250100002)(14454004)(33656002)(53936002)(305945005)(102836004)(6246003)(53546011)(7736002)(99286004)(6506007)(105586002)(76176011)(106356001)(97736004)(5660300001)(6916009)(83716003)(6512007)(8676002)(81166006)(81156014)(316002)(11346002)(476003)(50226002)(446003)(229853002)(6486002)(486006)(2900100001)(54906003)(2906002)(82746002)(6116002)(6436002)(3660700001)(3280700002)(8936002)(57306001)(186003)(86362001)(46003)(25786009)(36756003)(4326008);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR15MB1642;H:DM5PR15MB1548.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: U0BYtIb0ZeK6UvLUMdeSscURlE58TI+Sg8AadB+RmwLKybcj/y5znw+dH3CF6Ckovvxefvk2R2VDinZJs4D1qYH+aeb3DGZLLC8op6DeBqXUjUnicKCPb8lYRol9LzMkm5Bg5+ikGylZfn2CQMFHZcaNGcx7UbLu5iEaD8fo0z8tzgHJfl1SlAxQrs/Y83cF spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <4DEEA3228AE2C64187283981A4310806@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: b565018c-0415-475c-d9bb-08d5a48a0e33 X-MS-Exchange-CrossTenant-Network-Message-Id: b565018c-0415-475c-d9bb-08d5a48a0e33 X-MS-Exchange-CrossTenant-originalarrivaltime: 17 Apr 2018 17:38:39.1951 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1642 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-17_09:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 17, 2018, at 9:36 AM, Yafang Shao wrote: >=20 > 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. >=20 > 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. >=20 > arrives time : user process time =3D> latency caused by user > tcp_probe tcp_rcv_space_adjust >=20 > Hence in the printk message, sk_cookie is printed as a key to relate > tcp_rcv_space_adjust with tcp_probe. >=20 > 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. >=20 > Signed-off-by: Yafang Shao >=20 > --- > 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(-) >=20 > 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 >=20 > #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) > ), >=20 > TP_fast_assign( > @@ -144,12 +146,24 @@ >=20 > 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 =3D atomic64_read(&sk->sk_cookie); > ), >=20 > - TP_printk("sport=3D%hu dport=3D%hu saddr=3D%pI4 daddr=3D%pI4 saddrv6=3D= %pI6c daddrv6=3D%pI6c", > + TP_printk("sport=3D%hu dport=3D%hu saddr=3D%pI4 daddr=3D%pI4 saddrv6=3D= %pI6c daddrv6=3D%pI6c sock_cookie=3D%llu", > __entry->sport, __entry->dport, > __entry->saddr, __entry->daddr, > - __entry->saddr_v6, __entry->daddr_v6) > + __entry->saddr_v6, __entry->daddr_v6, > + __entry->sock_cookie) > ); >=20 > DEFINE_EVENT(tcp_event_sk, tcp_receive_reset, > @@ -166,6 +180,13 @@ > TP_ARGS(sk) > ); >=20 > +DEFINE_EVENT(tcp_event_sk, tcp_rcv_space_adjust, > + > + TP_PROTO(const struct sock *sk), > + > + TP_ARGS(sk) > +); > + > TRACE_EVENT(tcp_retransmit_synack, >=20 > TP_PROTO(const struct sock *sk, const struct request_sock *req), > @@ -232,6 +253,7 @@ > __field(__u32, snd_wnd) > __field(__u32, srtt) > __field(__u32, rcv_wnd) > + __field(__u64, sock_cookie) > ), >=20 > TP_fast_assign( > @@ -256,15 +278,14 @@ > __entry->rcv_wnd =3D tp->rcv_wnd; > __entry->ssthresh =3D tcp_current_ssthresh(sk); > __entry->srtt =3D tp->srtt_us >> 3; > + __entry->sock_cookie =3D sock_gen_cookie(sk); > ), >=20 > - TP_printk("src=3D%pISpc dest=3D%pISpc mark=3D%#x length=3D%d snd_nxt=3D= %#x " > - "snd_una=3D%#x snd_cwnd=3D%u ssthresh=3D%u snd_wnd=3D%u srtt=3D%u " > - "rcv_wnd=3D%u", > + TP_printk("src=3D%pISpc dest=3D%pISpc mark=3D%#x length=3D%d snd_nxt=3D= %#x snd_una=3D%#x snd_cwnd=3D%u ssthresh=3D%u snd_wnd=3D%u srtt=3D%u rcv_wn= d=3D%u sock_cookie=3D%llu", > __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->sock_cookie) > ); >=20 > #endif /* _TRACE_TCP_H */ > diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c > index f93687f..43ad468 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; >=20 > + trace_tcp_rcv_space_adjust(sk); > + > tcp_mstamp_refresh(tp); > time =3D 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 =3D= =3D 0) > --=20 > 1.8.3.1 >=20 If I understand this correctly, you can get all the information you need wi= th a kprobe on tcp_rcv_space_adjust(). Why is it necessary to introduce a new= =20 tracepoint?=20 Thanks, Song