Received: by 10.223.164.202 with SMTP id h10csp2363925wrb; Sat, 18 Nov 2017 20:19:18 -0800 (PST) X-Google-Smtp-Source: AGs4zMY69T8ExePEFYpI/PXK9XTazyWa8OCWLBThP2C5z1LEBpt0iUw8VUCaaNecADs5XRwZ0SKt X-Received: by 10.101.80.4 with SMTP id f4mr9511176pgo.432.1511065158887; Sat, 18 Nov 2017 20:19:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511065158; cv=none; d=google.com; s=arc-20160816; b=09/b936wqYU4QPgWomRE7KEIYGe36FwkSeEPUnX0ypoUSFIENg9mcNkgliq+K/I6Cv k0fWuUq5iALkGc4okyFeoOxVjEfwfF+qAa3C62uYQCN2w7aeryVtijfq8VjhxDj11rua eor0WxghEj1QW5rvNa4mptsxDgopNHrAD3RnGkPGxgx7OnFaDvMbZbw7badAsye1ttxk bVbPt++OWqSJAx94eBJQWL5ZwHXBhGDRknl34TOfmHcis8lVF4NeVmVeqF7Qm21zVG+V JQDtqRPxwQRdNH/hSFTwI38X/1YPaj2xMH4M4pahQOHLr2oRekbwGbf/e00wibTAB+T9 f1dw== 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=rotjEtAR0WpVu0MOZbo1mJNIKTEz+8vfeMaV0uaYsWw=; b=TAg6TuJqRVWbd6C7sJe2MBCalDWnkQ6zxobxj5FZI2GOBfp1i7nf915RQJaRr5Vq5T RwEIDjmRK9NEfl7a1Chf7GvJ+e1eBwO+atjWtzkGZYh9B8OWGIPmp+jo/fJ0bi/SbF7o EIkSi6ZyTYXmItOLN5seDCuPMjunOh8GIx7tpkhKWwLN+h3mL0dunEjCNf8NqgyGaELe ZllLzaapHdNVeifo0x+0oqW6hjMgN19rpoeeNg20ER+vWJtYb5usRkkG3amwzr5oxY1A xtG7yzIlV+5F6QR8pZVO4rren9OfzlGrZ5QYY6UgQzD7uCY5ZCs3CjvsNT4qH0W7LS1d f2yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=U3pwL/ge; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=e5TDOvGF; 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 s24si2503514plp.798.2017.11.18.20.19.06; Sat, 18 Nov 2017 20:19:18 -0800 (PST) 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=U3pwL/ge; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=e5TDOvGF; 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 S1161126AbdKRStr (ORCPT + 92 others); Sat, 18 Nov 2017 13:49:47 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:47894 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935357AbdKRStj (ORCPT ); Sat, 18 Nov 2017 13:49:39 -0500 Received: from pps.filterd (m0109332.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id vAIIn3xW030741; Sat, 18 Nov 2017 10:49:03 -0800 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=rotjEtAR0WpVu0MOZbo1mJNIKTEz+8vfeMaV0uaYsWw=; b=U3pwL/gekzIS0ANkR6z+B31PQiSDr5C5wkv13uI8+Io3WKzSESLAzBZLyeqE91Wqc9aV Xi/6EDJWzz2ptH8/7h+cgkYWQaTeXABfteZC7oH9a31kFQKKfaNVYUYqkyOOzJvrv60S v3/j6FXGLMZAmiIoI5ZYJaMSdWIazFSZg58= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2eakfqgpq9-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Sat, 18 Nov 2017 10:49:03 -0800 Received: from NAM03-DM3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.21) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 18 Nov 2017 13:49:02 -0500 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=rotjEtAR0WpVu0MOZbo1mJNIKTEz+8vfeMaV0uaYsWw=; b=e5TDOvGFEqbJItp3Q8GwGu1QQy0IdlPDOfFbAy/2BPf/RQdmJUQaWZLCYGVJ/q+zbpBnboEMyxB+DPvaa0jJNWlMR8VY4CgeOSbbsKWoYZ6wdOzh6YTEpZIiETnTfSiuJWnLp9DyQnjSXmU3CLa0yq50wDMEoqrkvvD2+KepAkU= Received: from BN6PR15MB1505.namprd15.prod.outlook.com (10.172.151.145) by BN6PR15MB1505.namprd15.prod.outlook.com (10.172.151.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.239.5; Sat, 18 Nov 2017 18:49:00 +0000 Received: from BN6PR15MB1505.namprd15.prod.outlook.com ([10.172.151.145]) by BN6PR15MB1505.namprd15.prod.outlook.com ([10.172.151.145]) with mapi id 15.20.0239.007; Sat, 18 Nov 2017 18:49:00 +0000 From: Song Liu To: Yafang Shao , Brendan Gregg CC: "davem@davemloft.net" , "kuznet@ms2.inr.ac.ru" , "yoshfuji@linux-ipv6.org" , "rostedt@goodmis.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2 net-next] net/tcp: trace all TCP/IP state transition with tcp_set_state tracepoint Thread-Topic: [PATCH v2 net-next] net/tcp: trace all TCP/IP state transition with tcp_set_state tracepoint Thread-Index: AQHTYIKKpfueadhqFUiZzRbHKz9rEqMaesSA Date: Sat, 18 Nov 2017 18:49:00 +0000 Message-ID: <3F850155-217D-4133-A5CE-4F79DA52B646@fb.com> References: <1511019156-22039-1-git-send-email-laoar.shao@gmail.com> In-Reply-To: <1511019156-22039-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.3273) x-originating-ip: [2620:10d:c090:180::1:5ad2] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;BN6PR15MB1505;20:Cdv1Qq2muneo7F/eTLz164i+BrKudKNqhSp51nFR1QVZr3yRdTQ+fZHmooekwsew5KOPWHP8BPK322zFW3RqBZPNYutDWvf4vmXZZJWcelZvA9dkFYx7cpPG2a/C3dK5fDW7qv/Y9Pq6e8Ym7ALqvk9xrsw7tXdmYrVElcUZT6s= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 509205fa-1343-4bd6-c57a-08d52eb50831 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(2017052603199);SRVR:BN6PR15MB1505; x-ms-traffictypediagnostic: BN6PR15MB1505: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(11241501159)(6040450)(2401047)(8121501046)(5005006)(3231022)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BN6PR15MB1505;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BN6PR15MB1505; x-forefront-prvs: 04953B1F22 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(376002)(346002)(189002)(199003)(24454002)(6116002)(102836003)(97736004)(14454004)(2906002)(478600001)(82746002)(4326008)(101416001)(6246003)(68736007)(39060400002)(229853002)(3280700002)(3660700001)(50986999)(76176999)(50226002)(105586002)(106356001)(53936002)(316002)(2950100002)(33656002)(36756003)(8676002)(5660300001)(81156014)(81166006)(99286004)(54906003)(25786009)(305945005)(110136005)(6512007)(189998001)(53546010)(6486002)(6506006)(86362001)(7736002)(6436002)(8936002)(57306001)(2900100001)(83716003)(77096006);DIR:OUT;SFP:1102;SCL:1;SRVR:BN6PR15MB1505;H:BN6PR15MB1505.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <4FD77282B5B06D48907FB31D24CBFEE1@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 509205fa-1343-4bd6-c57a-08d52eb50831 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Nov 2017 18:49:00.1887 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR15MB1505 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-11-18_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 Nov 18, 2017, at 7:32 AM, Yafang Shao wrote: >=20 > The TCP/IP transition from TCP_LISTEN to TCP_SYN_RECV and some other > transitions are not traced with tcp_set_state tracepoint. >=20 > In order to trace the whole tcp lifespans, two helpers are introduced, > void __tcp_set_state(struct sock *sk, int state) > void __sk_state_store(struct sock *sk, int newstate) >=20 > When do TCP/IP state transition, we should use these two helpers or use > tcp_set_state() other than assigning a value to sk_state directly. >=20 > Signed-off-by: Yafang Shao > --- > include/net/tcp.h | 2 ++ > net/ipv4/inet_connection_sock.c | 6 +++--- > net/ipv4/inet_hashtables.c | 2 +- > net/ipv4/tcp.c | 12 ++++++++++++ > 4 files changed, 18 insertions(+), 4 deletions(-) >=20 > diff --git a/include/net/tcp.h b/include/net/tcp.h > index 85ea578..4f2d015 100644 > --- a/include/net/tcp.h > +++ b/include/net/tcp.h > @@ -1247,6 +1247,8 @@ static inline bool tcp_checksum_complete(struct sk_= buff *skb) > "Close Wait","Last ACK","Listen","Closing" > }; > #endif > +void __sk_state_store(struct sock *sk, int newstate); > +void __tcp_set_state(struct sock *sk, int state); > void tcp_set_state(struct sock *sk, int state); >=20 > void tcp_done(struct sock *sk); > diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_s= ock.c > index 4ca46dc..f3967f1 100644 > --- a/net/ipv4/inet_connection_sock.c > +++ b/net/ipv4/inet_connection_sock.c > @@ -783,7 +783,7 @@ struct sock *inet_csk_clone_lock(const struct sock *s= k, > if (newsk) { > struct inet_connection_sock *newicsk =3D inet_csk(newsk); >=20 > - newsk->sk_state =3D TCP_SYN_RECV; > + __tcp_set_state(newsk, TCP_SYN_RECV); > newicsk->icsk_bind_hash =3D NULL; >=20 > inet_sk(newsk)->inet_dport =3D inet_rsk(req)->ir_rmt_port; > @@ -877,7 +877,7 @@ int inet_csk_listen_start(struct sock *sk, int backlo= g) > * It is OK, because this socket enters to hash table only > * after validation is complete. > */ > - sk_state_store(sk, TCP_LISTEN); > + __sk_state_store(sk, TCP_LISTEN); > if (!sk->sk_prot->get_port(sk, inet->inet_num)) { > inet->inet_sport =3D htons(inet->inet_num); >=20 > @@ -888,7 +888,7 @@ int inet_csk_listen_start(struct sock *sk, int backlo= g) > return 0; > } >=20 > - sk->sk_state =3D TCP_CLOSE; > + __tcp_set_state(sk, TCP_CLOSE); > return err; > } > EXPORT_SYMBOL_GPL(inet_csk_listen_start); > diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c > index e7d15fb..72c15b6 100644 > --- a/net/ipv4/inet_hashtables.c > +++ b/net/ipv4/inet_hashtables.c > @@ -430,7 +430,7 @@ bool inet_ehash_nolisten(struct sock *sk, struct sock= *osk) > sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); > } else { > percpu_counter_inc(sk->sk_prot->orphan_count); > - sk->sk_state =3D TCP_CLOSE; > + __tcp_set_state(sk, TCP_CLOSE); > sock_set_flag(sk, SOCK_DEAD); > inet_csk_destroy_sock(sk); > } > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index bf97317..2bc7e04 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -2036,6 +2036,18 @@ int tcp_recvmsg(struct sock *sk, struct msghdr *ms= g, size_t len, int nonblock, > } > EXPORT_SYMBOL(tcp_recvmsg); >=20 > +void __sk_state_store(struct sock *sk, int newstate) > +{ > + trace_tcp_set_state(sk, sk->sk_state, newstate); > + sk_state_store(sk, newstate); > +} > + > +void __tcp_set_state(struct sock *sk, int state) > +{ > + trace_tcp_set_state(sk, sk->sk_state, state); > + sk->sk_state =3D state; > +} > + > void tcp_set_state(struct sock *sk, int state) > { > int oldstate =3D sk->sk_state; > --=20 > 1.8.3.1 >=20 + Brendan From 1584466239707830390@xxx Sun Nov 19 04:12:38 +0000 2017 X-GM-THRID: 1584466239707830390 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread