Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751361AbeAEHVx (ORCPT + 1 other); Fri, 5 Jan 2018 02:21:53 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39906 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751056AbeAEHVv (ORCPT ); Fri, 5 Jan 2018 02:21:51 -0500 From: Song Liu To: Yafang Shao CC: David Miller , "brendan.d.gregg@gmail.com" , "marcelo.leitner@gmail.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH net-next] net: tracepoint: adding new tracepoint arguments in inet_sock_set_state Thread-Topic: [PATCH net-next] net: tracepoint: adding new tracepoint arguments in inet_sock_set_state Thread-Index: AQHThfCANksnTHI7NUW60HCrevSlvqNk38uA Date: Fri, 5 Jan 2018 07:21:43 +0000 Message-ID: <9A0D3ED9-7FFD-4E96-A42C-90871C2CC0C6@fb.com> References: <1515134569-23812-1-git-send-email-laoar.shao@gmail.com> In-Reply-To: <1515134569-23812-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::910e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1512;7:JnsxdepuHGYpewkkWfpIvkAcOHhfWn820pEo3oWITtxjsm8rLqcR+agFQuiRR1QwfJRmA31w/eAZEX5UPpt2v+5ChMPPFSblvcEsXfUyzd+3E+VamwDIO/fRNJBvui1O4kkHYQu4vRzvw1lPboRLmweKGbadl6TRq/RtmMqg5O90PsMvV7KPW2f5H6ZhiQe1WeQt9DHImdDCzuV+yDJ3in/eJGYuUNGPPhAm1q1DGFoZ+civr8651vxyEqZ/pEou;20:7zpYkBbDgfXNEoF8mUbgjOkzTr/6Bkr6mqh7YGQLUeKm0lhxV9G9MsDII2TVO6NJeka6FzZaYEvvPhqk9qsCgOp1UxuHsOtJ0PbH/91DqF/T7eA6cZ12A47gKcKFM5iKk+Rspt+Q/JLjGX2hS7iHQSjjhi7fEC0Olt9/sM5Lnes= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: f5b9e579-037e-4e0f-c315-08d5540cf92a x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060);SRVR:CY4PR15MB1512; x-ms-traffictypediagnostic: CY4PR15MB1512: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(10201501046)(3002001)(3231023)(11241501184)(944501075)(6041268)(20161123564045)(20161123562045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(6072148)(201708071742011);SRVR:CY4PR15MB1512;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR15MB1512; x-forefront-prvs: 05437568AA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(366004)(39380400002)(376002)(39860400002)(24454002)(189003)(199004)(106356001)(86362001)(5660300001)(6116002)(2950100002)(53546011)(14454004)(6916009)(97736004)(81166006)(3660700001)(8676002)(4326008)(2906002)(76176011)(102836004)(83716003)(478600001)(81156014)(25786009)(3280700002)(50226002)(57306001)(39060400002)(305945005)(229853002)(6512007)(316002)(7736002)(99286004)(6246003)(105586002)(6486002)(53936002)(8936002)(36756003)(6506007)(54906003)(68736007)(2900100001)(6436002)(77096006)(33656002)(82746002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR15MB1512;H:CY4PR15MB1512.namprd15.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; x-microsoft-antispam-message-info: +z1A7KC14UGWotWrQXKBrdKo30U1EBaG/2wb5lzayDYkvSyEeno/otAtVs5bUaKCumADHlK1r2ICy7eBOxkhBQ== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <876D133E47F2554E907C9F4667619C94@namprd15.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: f5b9e579-037e-4e0f-c315-08d5540cf92a X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jan 2018 07:21:43.6963 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1512 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-05_04:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: > On Jan 4, 2018, at 10:42 PM, Yafang Shao wrote: > > sk->sk_protocol and sk->sk_family are exposed as tracepoint arguments. > Then we can conveniently use these two arguments to do the filter. > > Suggested-by: Brendan Gregg > Signed-off-by: Yafang Shao > --- > include/trace/events/sock.h | 24 ++++++++++++++++++------ > net/ipv4/af_inet.c | 6 ++++-- > 2 files changed, 22 insertions(+), 8 deletions(-) > > diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h > index 3537c5f..c7df70f 100644 > --- a/include/trace/events/sock.h > +++ b/include/trace/events/sock.h > @@ -11,7 +11,11 @@ > #include > #include > > -/* The protocol traced by sock_set_state */ > +#define family_names \ > + EM(AF_INET) \ > + EMe(AF_INET6) > + > +/* The protocol traced by inet_sock_set_state */ > #define inet_protocol_names \ > EM(IPPROTO_TCP) \ > EM(IPPROTO_DCCP) \ > @@ -37,6 +41,7 @@ > #define EM(a) TRACE_DEFINE_ENUM(a); > #define EMe(a) TRACE_DEFINE_ENUM(a); > > +family_names > inet_protocol_names > tcp_state_names > > @@ -45,6 +50,9 @@ > #define EM(a) { a, #a }, > #define EMe(a) { a, #a } > > +#define show_family_name(val) \ > + __print_symbolic(val, family_names) > + > #define show_inet_protocol_name(val) \ > __print_symbolic(val, inet_protocol_names) > > @@ -108,9 +116,10 @@ > > TRACE_EVENT(inet_sock_set_state, > > - TP_PROTO(const struct sock *sk, const int oldstate, const int newstate), > + TP_PROTO(const struct sock *sk, const int family, const int protocol, > + const int oldstate, const int newstate), Are there cases we need protocol and/or family that is different to sk->sk_protocol/sk_family? If not, I think we don't need to change the TP_PROTO. Thanks, Song > > - TP_ARGS(sk, oldstate, newstate), > + TP_ARGS(sk, family, protocol, oldstate, newstate), > > TP_STRUCT__entry( > __field(const void *, skaddr) > @@ -118,6 +127,7 @@ > __field(int, newstate) > __field(__u16, sport) > __field(__u16, dport) > + __field(__u16, family) > __field(__u8, protocol) > __array(__u8, saddr, 4) > __array(__u8, daddr, 4) > @@ -133,8 +143,9 @@ > __entry->skaddr = sk; > __entry->oldstate = oldstate; > __entry->newstate = newstate; > + __entry->family = family; > + __entry->protocol = protocol; > > - __entry->protocol = sk->sk_protocol; > __entry->sport = ntohs(inet->inet_sport); > __entry->dport = ntohs(inet->inet_dport); > > @@ -145,7 +156,7 @@ > *p32 = inet->inet_daddr; > > #if IS_ENABLED(CONFIG_IPV6) > - if (sk->sk_family == AF_INET6) { > + if (family == AF_INET6) { > pin6 = (struct in6_addr *)__entry->saddr_v6; > *pin6 = sk->sk_v6_rcv_saddr; > pin6 = (struct in6_addr *)__entry->daddr_v6; > @@ -160,7 +171,8 @@ > } > ), > > - TP_printk("protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s", > + TP_printk("family=%s protocol=%s sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s", > + show_family_name(__entry->family), > show_inet_protocol_name(__entry->protocol), > __entry->sport, __entry->dport, > __entry->saddr, __entry->daddr, > diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c > index bab98a4..1d52796 100644 > --- a/net/ipv4/af_inet.c > +++ b/net/ipv4/af_inet.c > @@ -1223,14 +1223,16 @@ int inet_sk_rebuild_header(struct sock *sk) > > void inet_sk_set_state(struct sock *sk, int state) > { > - trace_inet_sock_set_state(sk, sk->sk_state, state); > + trace_inet_sock_set_state(sk, sk->sk_family, sk->sk_protocol, > + sk->sk_state, state); > sk->sk_state = state; > } > EXPORT_SYMBOL(inet_sk_set_state); > > void inet_sk_state_store(struct sock *sk, int newstate) > { > - trace_inet_sock_set_state(sk, sk->sk_state, newstate); > + trace_inet_sock_set_state(sk, sk->sk_family, sk->sk_protocol, > + sk->sk_state, newstate); > smp_store_release(&sk->sk_state, newstate); > } > > -- > 1.8.3.1 >