Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp5391769rwl; Sun, 8 Jan 2023 14:22:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXuaW3gKQwWQ6jeLVZiNzo8qKdwPpr3B2BsPUkFJ8Iw1mOLQuApslus0U1UPP5asbj9ZashH X-Received: by 2002:a17:907:970a:b0:7c0:fd1a:79ee with SMTP id jg10-20020a170907970a00b007c0fd1a79eemr83258158ejc.63.1673216528976; Sun, 08 Jan 2023 14:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673216528; cv=none; d=google.com; s=arc-20160816; b=qzNUinCLtHXn8UURSU2OlNY0FOxVLC551cTAo4G4uud3Jx6I3hJKy0SQMJyelhz33X R2UjXMZXc4YMqxKiFhTE3TZcVfGzZUiJ1yRjGOPMmzjWqcqXutftOsziXPKwP64DeLZP USKpHmLi7mpXjIz0vSMjdJ5wB8sFsUEPbZNqbof5JB+4GzfVyaoNSmxT8Kfjrw87TauD rFMdaEICWym2UPRbmwAfMSD+Kf8W9Y9/V6RWfqF0+DwTc9XE/ZzmuEtAwm6mqcZAARfU JJCNqW0dPX7CafUFr2lSY1iipi5IwyUzHURF45VNothwGV24QtRB01sfmUoloYslejTZ fHZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Qnu0pdM5SST+QO8GiOn2D5ryU/UxCTAy2vn3F4HM9d8=; b=Crn9pEcStgCfyCj0s0XpiZFB6uC7I0o33E4BAMW50XzQ+XxkEXthc+8e91M6x3W+vT oWUs24e9tiVIsB9zkzl6pX6Mp64mBrpuwBNvNjbO55gaQ7S8Cy6P7Lc1CPvMh4IqTZEJ D+wM1QFj2WiXNQXdFtzA89SMQ+TtQI4MszkZjHn9f4WDhXJk6sY1/nawrqTlc8LELDYG 81lbg9oZhmGG7QNTIT17rcZpFKvTETQ/pfoUsG1ZogKnalsyUexxQfgWCMCYd4C/qZul 5c1PLOH/zh5KnpJYo56uxyfNpcRZCend9JJYFGAkaeZ3lWU8eSzMycnMyGhD5xv7g9k5 fVAQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b0084d3bf44987si3272284ejc.551.2023.01.08.14.21.56; Sun, 08 Jan 2023 14:22:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236103AbjAHVeM convert rfc822-to-8bit (ORCPT + 53 others); Sun, 8 Jan 2023 16:34:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234113AbjAHVeJ (ORCPT ); Sun, 8 Jan 2023 16:34:09 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E55A2652; Sun, 8 Jan 2023 13:34:08 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3A027B80B97; Sun, 8 Jan 2023 21:34:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A71FBC433EF; Sun, 8 Jan 2023 21:34:04 +0000 (UTC) Date: Sun, 8 Jan 2023 16:34:03 -0500 From: Steven Rostedt To: Yunhui Cui Cc: mhiramat@kernel.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, kuniyu@amazon.com, xiyou.wangcong@gmail.com, duanxiongchun@bytedance.com, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v3] sock: add tracepoint for send recv length Message-ID: <20230108163403.37e3f25d@rorschach.local.home> In-Reply-To: <20230107035923.363-1-cuiyunhui@bytedance.com> References: <20230107035923.363-1-cuiyunhui@bytedance.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,NUMERIC_HTTP_ADDR,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 7 Jan 2023 11:59:23 +0800 Yunhui Cui wrote: > Add 2 tracepoints to monitor the tcp/udp traffic > of per process and per cgroup. > > Regarding monitoring the tcp/udp traffic of each process, there are two > existing solutions, the first one is https://www.atoptool.nl/netatop.php. > The second is via kprobe/kretprobe. > > Netatop solution is implemented by registering the hook function at the > hook point provided by the netfilter framework. > > These hook functions may be in the soft interrupt context and cannot > directly obtain the pid. Some data structures are added to bind packets > and processes. For example, struct taskinfobucket, struct taskinfo ... > > Every time the process sends and receives packets it needs multiple > hashmaps,resulting in low performance and it has the problem fo inaccurate > tcp/udp traffic statistics(for example: multiple threads share sockets). > > We can obtain the information with kretprobe, but as we know, kprobe gets > the result by trappig in an exception, which loses performance compared > to tracepoint. > > We compared the performance of tracepoints with the above two methods, and > the results are as follows: > > ab -n 1000000 -c 1000 -r http://127.0.0.1/index.html > without trace: > Time per request: 39.660 [ms] (mean) > Time per request: 0.040 [ms] (mean, across all concurrent requests) > > netatop: > Time per request: 50.717 [ms] (mean) > Time per request: 0.051 [ms] (mean, across all concurrent requests) > > kr: > Time per request: 43.168 [ms] (mean) > Time per request: 0.043 [ms] (mean, across all concurrent requests) > > tracepoint: > Time per request: 41.004 [ms] (mean) > Time per request: 0.041 [ms] (mean, across all concurrent requests > > It can be seen that tracepoint has better performance. > > Signed-off-by: Yunhui Cui > Signed-off-by: Xiongchun Duan > --- From a tracing POV: Reviewed-by: Steven Rostedt (Google) -- Steve