Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752755AbeAFRrC (ORCPT + 1 other); Sat, 6 Jan 2018 12:47:02 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:57314 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751136AbeAFRrA (ORCPT ); Sat, 6 Jan 2018 12:47:00 -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: AQHThfCANksnTHI7NUW60HCrevSlvqNk38uAgAANbwCAAjN8gA== Date: Sat, 6 Jan 2018 17:46:33 +0000 Message-ID: <544ED2FF-A44E-493D-B84E-46A58EEAB201@fb.com> References: <1515134569-23812-1-git-send-email-laoar.shao@gmail.com> <9A0D3ED9-7FFD-4E96-A42C-90871C2CC0C6@fb.com> In-Reply-To: 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::996c] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR15MB1512;7:2xOYVNk/Q0e16yg8WJNDmVtrPcWQtbqyRAoLqfNKUqXfG7jQ1mDINdRxEdimqtwafzYWl203XelQ1SZAajIMeJ6lRLnbEg43/gOu9ooR/UKrXvEG7iT6F6yQE6IfQdT1wvusxfJMlGFvtpEzrW6DocOVg4TqknZ9Mc5YhyI28V1P+B1l6d40M04skiPUpdvIYlgQz35dvRHlrfpPsDs/qSiOn/EIg92ehdjQmcjH041ZkS/uNoz569hL4xAGlpuG;20:/skIS1WNgAN/GL1jJ+sF6KVItNGuaoowYSu4z9IJ8Yh/q+fhifoYphzanSDq6kZO5cYz4lzyV7inUKgr32kdqyJ8zX9v59dWhPHZi0kXDED3f5dUl0c4A8ZvHmZZho32tRfYGU4hdxr9gCy+CQrO+iqikYzJKpPx7QnPapnXZDs= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 4a943151-072f-42b1-ad3e-08d5552d6d66 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(3008032)(2017052603307)(7153060)(7193020);SRVR:CY4PR15MB1512; x-ms-traffictypediagnostic: CY4PR15MB1512: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(67672495146484); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(3231023)(11241501184)(944501075)(10201501046)(6041268)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:CY4PR15MB1512;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:CY4PR15MB1512; x-forefront-prvs: 0544D934E1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39860400002)(396003)(376002)(346002)(366004)(39380400002)(24454002)(189003)(199004)(36756003)(53546011)(6916009)(2950100002)(6436002)(6506007)(81156014)(5660300001)(81166006)(6486002)(77096006)(83716003)(4326008)(76176011)(82746002)(14454004)(478600001)(6116002)(102836004)(39060400002)(25786009)(86362001)(8936002)(50226002)(68736007)(3280700002)(6246003)(99286004)(53936002)(33656002)(54906003)(2900100001)(6512007)(106356001)(105586002)(305945005)(2906002)(7736002)(229853002)(57306001)(316002)(3660700001)(97736004)(8676002);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: kgcCXor8eGRbhpCw2AtCmJjz5NpxgkrT+jcgdbJmuAoQpMyMiPd/e7NUqV7dD6VFrdkyCyItpioQuQ6rJ4UHgg== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 4a943151-072f-42b1-ad3e-08d5552d6d66 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2018 17:46:33.8878 (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-06_11:,, 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 5, 2018, at 12:09 AM, Yafang Shao wrote: > > On Fri, Jan 5, 2018 at 3:21 PM, Song Liu wrote: >> >>> 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 >> > > As of now, there're two sk_family, which are AF_INET and AF_INET6, and > three sk_protocol which are IPPROTO_TCP, IPPROTO_SCTP and > IPPROTO_DCCP. > > Thanks > Yafang How about we do not change the TP_PROTO line? The patch will be like: @@ -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 = sk->sk_family; __entry->protocol = sk->sk_protocol; __entry->sport = ntohs(inet->inet_sport); __entry->dport = ntohs(inet->inet_dport); @@ xxxxx - 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), 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