Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1794655pxb; Wed, 9 Feb 2022 04:47:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJya1PYhcn+UV0OtOVKKfHZPmPwD3muY/c3O1g3ycjFp8TH16G5HT67H+dRJcK7026cfvArP X-Received: by 2002:a17:90b:4d0e:: with SMTP id mw14mr2329465pjb.133.1644410848704; Wed, 09 Feb 2022 04:47:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644410848; cv=none; d=google.com; s=arc-20160816; b=bSmO+e+mjkKECEculDLZLJ2JSHXMv07E3pLNY1NVGFfTBLiUV8eMk73aI3Gi0HwAU6 8cBoWdt8igUEQOYPeZpsVQPSR/+hsPYGPATJV0X8uHyTZGTx+4KfhAmjdA+RP/M86b8E 0HP947OFwMwtnrWBEibaFCB/Sjl0HP/SgG3xwv/ywftjxjKnNSWEM+Irf+xqvzUCZkDg RYCqWHDBmYUuApAkaDQZwWZdYczB7BWuP3gac9qzsJ6G2nJ2PYKp/BXrHOqx8zsUuK06 yxihpxM208hR/b/GRES4D3P0SPVKGmGRhdrE09rMvxB9X80kXsW7Z6DIX9F+/ZUnGqyB NBmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:cc:to:subject:message-id :from:content-transfer-encoding:date:dkim-signature:mime-version; bh=BNdeWlWyJwoe/Qown8c9HOfU3XoCi4raioSLrTWzgSM=; b=vfXB+WgIyaxsZx8bIOLORdRO3mAasyODSMd2B50xdp48NDkkwQPGCQl5dySYiLWHjl Q6Dcl1I2viucqJp02iMjbK4kpmI/SnnRnLkH2P+f8yO/arrYHNIgkkW9d6aZm8F/Selk AldJldVDli98JzPLdE3y9Se/thPdcW8TlGXCYUA3n3nau+xjQSULDFeThv+LIpKuqyE6 H2RQ4o4rMTgTQmkssP5UwFLPixYSW1LOxKcEECDXTj4MOcNlupDUwp2Pd8Bdw3GJ1WSa ScZ0AK/N8HEbaO6nCbtkavmsIZrBpdF9VU3ZA6afg6aYGQ+STMQaSzDrdalWeq02WE/c dhTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Wnd4EZde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s10si11873979plk.387.2022.02.09.04.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Feb 2022 04:47:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=Wnd4EZde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B4B13E1342C2; Wed, 9 Feb 2022 02:28:39 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237533AbiBIH1s (ORCPT + 99 others); Wed, 9 Feb 2022 02:27:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237504AbiBIH1p (ORCPT ); Wed, 9 Feb 2022 02:27:45 -0500 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A9B8DC0613CB; Tue, 8 Feb 2022 23:27:48 -0800 (PST) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1644391664; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BNdeWlWyJwoe/Qown8c9HOfU3XoCi4raioSLrTWzgSM=; b=Wnd4EZdeuWWYLHzuzCdr851hSbcsCfGjQttMK68AorQxXwqfe1jgF7pzrn7tX7iKpiPM3C LlbDTd4ILn5cA8cRMv3uKb6rBWHdLnErfAn8uHy9CFW3pRMGeIzF9QQrWvaJbXyWto1mG9 phSNVfbeeiltzcI/sgpgr4TttTkeHdA= Date: Wed, 09 Feb 2022 07:27:44 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: yajun.deng@linux.dev Message-ID: Subject: Re: [PATCH net-next] net: dev: introduce netdev_drop_inc() To: "Jakub Kicinski" Cc: davem@davemloft.net, rostedt@goodmis.org, mingo@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20220208195306.05a1760f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> References: <20220208195306.05a1760f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20220208162729.41b62ae7@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20220208064318.1075849-1-yajun.deng@linux.dev> <753bb02bfa8c2cf5c08c63c31f193f90@linux.dev> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 February 9, 2022 11:53 AM, "Jakub Kicinski" wrote:=0A= =0A> On Wed, 09 Feb 2022 02:20:07 +0000 yajun.deng@linux.dev wrote:=0A> = =0A>> February 9, 2022 8:27 AM, "Jakub Kicinski" wrote:= =0A>> =0A>> On Tue, 8 Feb 2022 14:43:18 +0800 Yajun Deng wrote:=0A>> =0A>= > We will use 'sudo perf record -g -a -e skb:kfree_skb' command to trace= =0A>> the dropped packets when dropped increase in the output of ifconfig= .=0A>> But there are two cases, one is only called kfree_skb(), another i= s=0A>> increasing the dropped and called kfree_skb(). The latter is what= =0A>> we need. So we need to separate these two cases.=0A>> =0A>> From th= e other side, the dropped packet came from the core network and=0A>> the = driver, we also need to separate these two cases.=0A>> =0A>> Add netdev_d= rop_inc() and add a tracepoint for the core network dropped=0A>> packets.= use 'sudo perf record -g -a -e net:netdev_drop' and 'sudo perf=0A>> scri= pt' will recored the dropped packets by the core network.=0A>> =0A>> Sign= ed-off-by: Yajun Deng =0A>> =0A>> Have you seen the= work that's being done around kfree_skb_reason()?=0A>> =0A>> Yes, I saw = it. The focus of kfree_skb_reason() is trace kfree_skb() and the reason,= =0A>> but the focus of this patch only traces this case of the dropped pa= cket.=0A>> =0A>> I don't want to trace all kfree_skb(), but I just want t= o trace the dropped packet.=0A>> =0A>> This command 'sudo perf record -g = -a -e skb:kfree_skb' would trace all kfree_skb(),=0A>> kfree_skb() would = drowned out the case of dropped packets when the samples were too large.= =0A> =0A> IIRC perf support filters, I think with -f? We can't add a trac= epoint=0A> for every combination of attributes.=0A=0AYes, we can use a co= mmand like this: " sudo perf record -g -a -e skb:kfree_skb --filter 'prot= ocol =3D=3D 0x0800' ",=0AHowever, only the filter is defined in kfree_skb= tracepoint are available.=0A=0AThe purpose of this patch is record {rx_d= ropped, tx_dropped, rx_nohandler} in struct net_device, to distinguish = =0Awith struct net_device_stats. =0A=0AWe don't have any tracepoint recor= ds {rx_dropped, tx_dropped, rx_nohandler} in struct net_device now. =0ACa= n we add {rx_dropped, tx_dropped, rx_nohandler} in kfree_skb tracepoint? = like this:=0A=0A TP_STRUCT__entry(=0A __field(void= *, skbaddr)=0A __field(void *, location)= =0A __field(unsigned short, protocol)=0A __= field(enum skb_drop_reason, reason)=0A __field(unsigned = long, rx_dropped)=0A __field(unsigned long, tx_dropped)= =0A __field(unsigned long, rx_nohandler)=0A=0A ),= =0A=0A TP_fast_assign(=0A __entry->skbaddr =3D skb;= =0A __entry->location =3D location;=0A __en= try->protocol =3D ntohs(skb->protocol);=0A __entry->reason= =3D reason;=0A __entry->rx_dropped =3D (unsigned long)a= tomic_long_read(&skb->dev->rx_dropped);=0A __entry->tx_dro= pped =3D (unsigned long)atomic_long_read(&skb->dev->tx_dropped);=0A = __entry->rx_nohandler =3D (unsigned long)atomic_long_read(&sk= b->dev->rx_nohandler);=0A ),=0A=0AIf so, we can record this but no= t add a tracepoint.