Received: by 10.223.164.202 with SMTP id h10csp557618wrb; Wed, 8 Nov 2017 22:51:41 -0800 (PST) X-Google-Smtp-Source: ABhQp+Q85hN7x7GAiwTNtXXoc4Cc7DZiLB+4J+IPqi/FFU2/pCpkt1ILk1/fgrC8DNG0qovVhwJZ X-Received: by 10.99.173.8 with SMTP id g8mr2834425pgf.87.1510210301456; Wed, 08 Nov 2017 22:51:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510210301; cv=none; d=google.com; s=arc-20160816; b=tP9dRa7ibnoqf5FX6tTf8nNiOFn3aN7aMtiw3XMgopA9mKQDDt31/sU755kuL9+DI1 hFvsh7V9egN0cMDQsNjx9vNsbnjs6HgRiBzj9SYnP9A5Ftd6V2kXjFCZA+GiKkchTVgR zrXqhlElk5XpXKbrts9bTebNZY/yheBce3tVy9Q7o2psWTniBqbrRBtgvmM0AsU3kB0F bPQtOX70MsSzv7yChFt49vvpP1rVworgSki/CgJEcDm5hafKzbJtKsYNuOBRJRRNrmqb Heii1hA2p+CV08XJ2jMuXpgKH1XaXp7caZUBvvAArv7zkHydH2aWFnmrBJ96QMx4/OQ0 8eKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=NVHHgdiModDY4ewsxrn/FMsT6J/FTFQn0fluOD0HRcs=; b=maE6J9Xetcwl+e6IIRMr4fFvOF02zveKTjwFi2wmgIouazWl0r9v8cHPSVx9Jo3VZM 7AEnD2k9ZE7VmWhcym9xaHXiC7wHDmGfPPSNcnkNHQkvO6uIXrBb4SyX7zTCYi7EMr6b qYIYNvfQrb+9f1L0cujB+OWjO6lVUF5TIw+UGH8I1op/RyraEZoGj/JnOWv23lyF4Osn D0tPAliu/RaO7pk1sJAtaNNkFw2uQ8yOCP5RVIQMT3I97uxxHV1M9C3I/QIGk6BKc4ew RyI/LlPb6di6xWc7DOZgvdysjhlTMv/WKlmNWoI6lg04VRBOc5Ay5KbLv4TQPr9Ewbis ztQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ilyFprfO; 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=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si5911622pfi.247.2017.11.08.22.51.30; Wed, 08 Nov 2017 22:51:41 -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=@gmail.com header.s=20161025 header.b=ilyFprfO; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752585AbdKIGuw (ORCPT + 82 others); Thu, 9 Nov 2017 01:50:52 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:51190 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751120AbdKIGuu (ORCPT ); Thu, 9 Nov 2017 01:50:50 -0500 Received: by mail-it0-f67.google.com with SMTP id 72so9961337itl.5; Wed, 08 Nov 2017 22:50:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=NVHHgdiModDY4ewsxrn/FMsT6J/FTFQn0fluOD0HRcs=; b=ilyFprfOqlmXXalS6mNsa8jJOSXznSG0YVv8zGaCfIBIzuqOFA+2TNRXPCFmdO5eq2 oZwivHhkdgJ6qq0eDOPsEXkMdWf3DXpruhbs/6ArzWn0+PRvfiCN9Ose7nPdlYOvsobv MYY8i1N486HZy7MEpTt0AjLk9ofGMh9S2+GwPkNU+VXzbej6wIzg5xppZK6t46WaEyaM b1vol5moKV5RFpicrv/BD+8wc4zf9u6Jh0ES1pnrTOAZ0zGvLQrf1I6+K43pQIPeKEuJ Eeh6ZX2ciK8fY8NtyrdBBo2bPFeiKrKAGwfyb/miTbAv4xpU6PLyTN7BFvPrRuj8BtGk dTwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=NVHHgdiModDY4ewsxrn/FMsT6J/FTFQn0fluOD0HRcs=; b=G27z2/w6Kbo0dudKTvieGD+Rbftwpekq74sSQEIDkvc9c6jtysIXWFQKCFCQ5fK5/u GMC2NdOO+vxLK3D4lzAVFthMY9if9U5I7cpGNt05dMj4z8hF0qMKjbS2YOz4qTbKPb8j 8pl9pWjJBz097mwXWMIoqy6/UfIQGL1Oxm8ujmCN2D7jULPyziBifEjfhoKu8mwUp3ec sXWjpN6KEpE1jdCE237TO+KTz2eG0iKN62cL+0GNmxtDPGNY4JAIIUO+xWDyoHt3xng4 zCnbyCm4204yzXSStOq/F43xJhKe0olazMmGYywuVAaoEYNEVI9gtW4kV+SGL1bSL9K3 1RcA== X-Gm-Message-State: AJaThX7mCFoYD/RgU4jlXioOpf8FBhNDMPCQZ1uvTZFSOReVL5yhmnzz kN9mwqkswOwyWzuzizeCy6Tquwv+KB43rTZUu1Y= X-Received: by 10.36.69.234 with SMTP id c103mr1741793itd.150.1510210249731; Wed, 08 Nov 2017 22:50:49 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.160.73 with HTTP; Wed, 8 Nov 2017 22:50:49 -0800 (PST) In-Reply-To: <20171109064326.skfvvohg7qhgl3lp@ast-mbp> References: <1510207298-14828-1-git-send-email-laoar.shao@gmail.com> <20171109064326.skfvvohg7qhgl3lp@ast-mbp> From: Yafang Shao Date: Thu, 9 Nov 2017 14:50:49 +0800 Message-ID: Subject: Re: [PATCH] net/tcp: introduce TRACE_EVENT for TCP/IPv4 state transition To: Alexei Starovoitov Cc: David Miller , rostedt@goodmis.org, mingo@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, songliubraving@fb.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-11-09 14:43 GMT+08:00 Alexei Starovoitov : > On Thu, Nov 09, 2017 at 02:01:38PM +0800, Yafang Shao wrote: >> With this newly introduced TRACE_EVENT, it will be very easy to minotor >> TCP/IPv4 state transition. >> >> A new TRACE_SYSTEM named tcp is added, in which we can trace other TCP >> event as well. >> >> Two helpers are added, >> static inline void __tcp_set_state(struct sock *sk, int state) >> static inline void __sk_state_store(struct sock *sk, int newstate) >> >> When do TCP/IPv4 state transition, we should use these two helpers or >> use tcp_set_state() instead of assign a value to sk_state directly. >> >> Signed-off-by: Yafang Shao > > when you submit a patch pls make it clear which tree this patch is targeting. > In this case it should have been net-next, > but the patch clearly conflicts with it. > Make sure to rebase. I do it based on this tree git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git OK I will check the net-next then. > >> +/* >> + * To trace TCP state transition. >> + */ >> +static inline void __tcp_set_state(struct sock *sk, int state) >> +{ >> + trace_tcp_set_state(sk, sk->sk_state, state); >> + sk->sk_state = state; >> +} >> + >> +static inline 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_done(struct sock *sk); >> >> int tcp_abort(struct sock *sk, int err); >> diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h >> new file mode 100644 >> index 0000000..abf65af >> --- /dev/null >> +++ b/include/trace/events/tcp.h >> @@ -0,0 +1,58 @@ >> +#undef TRACE_SYSTEM >> +#define TRACE_SYSTEM tcp >> + >> +#if !defined(_TRACE_TCP_H) || defined(TRACE_HEADER_MULTI_READ) >> +#define _TRACE_TCP_H >> + >> +#include >> +#include >> +#include >> +#include >> +#include >> +#include >> + >> +TRACE_EVENT(tcp_set_state, >> + TP_PROTO(struct sock *sk, int oldstate, int newstate), >> + TP_ARGS(sk, oldstate, newstate), >> + >> + TP_STRUCT__entry( >> + __field(__be32, dst) >> + __field(__be32, src) >> + __field(__u16, dport) >> + __field(__u16, sport) >> + __field(int, oldstate) >> + __field(int, newstate) >> + ), >> + >> + TP_fast_assign( >> + if (oldstate == TCP_TIME_WAIT) { >> + __entry->dst = inet_twsk(sk)->tw_daddr; >> + __entry->src = inet_twsk(sk)->tw_rcv_saddr; >> + __entry->dport = ntohs(inet_twsk(sk)->tw_dport); >> + __entry->sport = ntohs(inet_twsk(sk)->tw_sport); >> + } else if (oldstate == TCP_NEW_SYN_RECV) { >> + __entry->dst = inet_rsk(inet_reqsk(sk))->ir_rmt_addr; >> + __entry->src = inet_rsk(inet_reqsk(sk))->ir_loc_addr; >> + __entry->dport = >> + ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port); >> + __entry->sport = inet_rsk(inet_reqsk(sk))->ir_num; >> + } else { >> + __entry->dst = inet_sk(sk)->inet_daddr; >> + __entry->src = inet_sk(sk)->inet_rcv_saddr; >> + __entry->dport = ntohs(inet_sk(sk)->inet_dport); >> + __entry->sport = ntohs(inet_sk(sk)->inet_sport); >> + } >> + >> + __entry->oldstate = oldstate; >> + __entry->newstate = newstate; >> + ), >> + >> + TP_printk("%08X:%04X %08X:%04X, %02x %02x", >> + __entry->src, __entry->sport, __entry->dst, __entry->dport, >> + __entry->oldstate, __entry->newstate) > > direct %x of state is not allowed. > This has to use show_tcp_state_name() like it's done in trace_tcp_set_state > > Also I'm missing the reason to introduce another tracepoint > that looks just like trace_tcp_set_state. > I will check net-next Thanks Yafang From 1583569849861022105@xxx Thu Nov 09 06:44:54 +0000 2017 X-GM-THRID: 1583567187015957636 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread