From patchwork Thu Mar 3 17:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767849 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF6B8C433FE for ; Thu, 3 Mar 2022 17:48:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235373AbiCCRtS (ORCPT ); Thu, 3 Mar 2022 12:49:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235232AbiCCRtR (ORCPT ); Thu, 3 Mar 2022 12:49:17 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02DBB5523C; Thu, 3 Mar 2022 09:48:31 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id bd1so5196155plb.13; Thu, 03 Mar 2022 09:48:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=fVdTMm1MoKAuDl3iNhPobLEeG1YoGE3fthuxjoz4iSA=; b=jkbOP7jlYnjdcFidIOClWrppzpnklc9u0W3moffTBKxusrl5uAr7xlPupLd5473VF5 +Sj0+YizxQCNa+R9yA/dvV/4K1ABDpXdpqLvTMUQ3ijU4LLSEHSA+sY9tbLSaS9GEx3Q J07mkxts/EgTdH1t5xbN0aF0m6urTX+fJCrB6Ifzn32swLc+5znS+54XLXYlUbkUdRWD pYyLXRm+t/hy50AqSWJOiNEPAKhpJJaTVuvN7ca7Iba+0uJlx1z/HwHxosd5iYy6xZdX 3VCNNH/B2UMO6nUhhOKPQbdUvaHe3sfGlN5fO4UabuzoqRBBtdaz0/4Fui24Ei0vwlOL nqwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fVdTMm1MoKAuDl3iNhPobLEeG1YoGE3fthuxjoz4iSA=; b=Mg5Nn8HaiVEDB2wW2COc64dw5NldA8oQIxEPSkF9fCsRZ2GcZvVPo0RYe1/0jdxR5W f90SR8SD4rjsD6KVpbRd+64fIrtPjfMfIr2CGH5vNBWNvolMQyG04+ihcBeVOcNQ3l1j rfnccuOEhZjPXxOvDeIDdsBXT7IawvKJcGwrwTT+WcVCNKYv1fFGj3pqU5kAG2/YataH V4yS4YwWvkYtoz+ZwEB53BP2Bi1bmFUfLPMmIrkwwZaAv/5euG00ASGSzUp20iy6BYIJ 1hvG+UTJHKyZ4yPwQgtihb753ac4tjNB/BDhd/m42xKR9oq80qj4DWivPdBKqbQ06AcJ 72cQ== X-Gm-Message-State: AOAM530Ym3xDkIH0NLZyF8iJabaQgb1kthXey4tGEVvDxNW4Vfbd79TL fMH+p4HMrabPR60grnxz9AI= X-Google-Smtp-Source: ABdhPJxFwGvu2yyZFcAIvZ3WCf6FLkeewdn6Pk6SDmXp1q8qvo3oUeW+6qKa0qTbMdowgohmv6PMxA== X-Received: by 2002:a17:902:b18d:b0:151:7456:4f77 with SMTP id s13-20020a170902b18d00b0015174564f77mr18266833plr.41.1646329710532; Thu, 03 Mar 2022 09:48:30 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:48:30 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress() Date: Fri, 4 Mar 2022 01:47:01 +0800 Message-Id: <20220303174707.40431-2-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in sch_handle_egress() with kfree_skb_reason(). The drop reason SKB_DROP_REASON_QDISC_EGRESS is introduced. Considering the code path of qdisc egerss, we make it distinct with the drop reason of SKB_DROP_REASON_QDISC_DROP in the next commit. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index d67941f78b92..ebd18850b63e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -394,6 +394,10 @@ enum skb_drop_reason { * entry is full */ SKB_DROP_REASON_NEIGH_DEAD, /* neigh entry is dead */ + SKB_DROP_REASON_QDISC_EGRESS, /* qdisc of type egress check + * failed (mapbe an eBPF program + * is tricking?) + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 1977f301260d..3cadf13448c6 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -45,6 +45,7 @@ EM(SKB_DROP_REASON_NEIGH_FAILED, NEIGH_FAILED) \ EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL) \ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ + EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 2d6771075720..828946d74a19 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3860,7 +3860,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev) case TC_ACT_SHOT: mini_qdisc_qstats_cpu_drop(miniq); *ret = NET_XMIT_DROP; - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_EGRESS); return NULL; case TC_ACT_STOLEN: case TC_ACT_QUEUED: From patchwork Thu Mar 3 17:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767850 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9CE6AC433FE for ; Thu, 3 Mar 2022 17:48:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235404AbiCCRt2 (ORCPT ); Thu, 3 Mar 2022 12:49:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235436AbiCCRt0 (ORCPT ); Thu, 3 Mar 2022 12:49:26 -0500 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CCF55F4D5; Thu, 3 Mar 2022 09:48:37 -0800 (PST) Received: by mail-pf1-x441.google.com with SMTP id g1so5328620pfv.1; Thu, 03 Mar 2022 09:48:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=D1g8qA5j8HhiVDyi8ohQbfHFEifnjz8mXbMbMyXSicQ=; b=Ce1JdhIuvGhIrcqjHwGoNPahbnjRpKTM43NNwCZdOc/n8WGjrO57m2InBBjPAOSKKJ w3/dyVzo/Kw3frLbWokOlji6QtgkjJS8yr98MZN61UXvcP/nYowJWuj1vmd1JPZ1gW70 sK6AL9xub8zx9sy4hEai+bjYJ/QvNu/AJB/2DbHn92sUCpjIGdoGXhFdcsXXDBcRvWXa moiTiM+1VLohnTygSpwKa01DZ+ycUAHwfHxosd0oQ7aMYv7AJIVd0npY252wvnMXsEI9 YAuRCPhsIPSyOS41CswhD3aolNOjdn200t5YL8ySLxogLmsVVzpCJbv/97TJQ7emuxFi dhhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=D1g8qA5j8HhiVDyi8ohQbfHFEifnjz8mXbMbMyXSicQ=; b=m1Dm3+lobGE7zTVORxtdRjuqvGWtmtviHJ1mF0uApu0utN8XJZ4oy6KmYzNUDlGdJQ /SA2xddO8Vve/5VsAhrghLi9GITTDFrgpHkxelolWYHgPSj4Rm9Bz1r02MKsNM7UQH21 tS4Zki5hSnOpQFPvJOY05TzKm4SK6clvbl1dU+qnrEKzdk3hty0R8sOrVHXNESIyDoo6 yn6wGcDDDa721RP1odqJzVDEzDRA3/S2H640HLX1PF+VKKBZcJiG7dW2zgjhCAWcOa7s Ema4WUWFl8+/5GWKX4ELtPe1aHHgfEzXwXV3ULbEtdLpLP6FNXjtO9nj4GLsxYiMqYj3 waAg== X-Gm-Message-State: AOAM532325thWfk77VCszzSghIwtH7rmteS8HwYtnBomtnKYnj3plhdO mkLJybXur4zdd/pbg+h0NzI= X-Google-Smtp-Source: ABdhPJyH+4en9Ep5dOvKPJxVosUVrhXXIelwbmW+FzG5d5mSh0UuFCCqVPtaVistFfeaclEbvETULg== X-Received: by 2002:a63:894a:0:b0:37c:4f5f:b144 with SMTP id v71-20020a63894a000000b0037c4f5fb144mr4589641pgd.42.1646329716655; Thu, 03 Mar 2022 09:48:36 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:48:36 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 2/7] net: skb: introduce the function kfree_skb_list_reason() Date: Fri, 4 Mar 2022 01:47:02 +0800 Message-Id: <20220303174707.40431-3-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong To report reasons of skb drops, introduce the function kfree_skb_list_reason() and make kfree_skb_list() an inline call to it. This function will be used in the next commit in __dev_xmit_skb(). Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 8 +++++++- net/core/skbuff.c | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index ebd18850b63e..e344603aecc4 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1194,10 +1194,16 @@ static inline void kfree_skb(struct sk_buff *skb) } void skb_release_head_state(struct sk_buff *skb); -void kfree_skb_list(struct sk_buff *segs); +void kfree_skb_list_reason(struct sk_buff *segs, + enum skb_drop_reason reason); void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt); void skb_tx_error(struct sk_buff *skb); +static inline void kfree_skb_list(struct sk_buff *segs) +{ + kfree_skb_list_reason(segs, SKB_DROP_REASON_NOT_SPECIFIED); +} + #ifdef CONFIG_TRACEPOINTS void consume_skb(struct sk_buff *skb); #else diff --git a/net/core/skbuff.c b/net/core/skbuff.c index b32c5d782fe1..46d7dea78011 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -777,16 +777,17 @@ void kfree_skb_reason(struct sk_buff *skb, enum skb_drop_reason reason) } EXPORT_SYMBOL(kfree_skb_reason); -void kfree_skb_list(struct sk_buff *segs) +void kfree_skb_list_reason(struct sk_buff *segs, + enum skb_drop_reason reason) { while (segs) { struct sk_buff *next = segs->next; - kfree_skb(segs); + kfree_skb_reason(segs, reason); segs = next; } } -EXPORT_SYMBOL(kfree_skb_list); +EXPORT_SYMBOL(kfree_skb_list_reason); /* Dump skb information and contents. * From patchwork Thu Mar 3 17:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767851 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A6CDC433FE for ; Thu, 3 Mar 2022 17:48:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235469AbiCCRtb (ORCPT ); Thu, 3 Mar 2022 12:49:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235451AbiCCRt3 (ORCPT ); Thu, 3 Mar 2022 12:49:29 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 870C75643C; Thu, 3 Mar 2022 09:48:43 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id z11so5217053pla.7; Thu, 03 Mar 2022 09:48:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PWlHozXjBpcdg0186JVwtvZRV5XBQhKzqyfGbgLa+ro=; b=RSNd65ABZfgCCUj4gIPsIjZxcfZhjb9yg1d+zUzHV09fMdn0okF8PFv+JIkzox3P+W csI+wFGuHlyr5yYzYcRS6UDAino+dwfTC0U74PTMI7K8AwiH9cH3unzO9lTHG//4DieA ka9mBpkL1Xy2pyLIVWD8YpQXGukl4jxSN1LhO7UpodsqpYUTTJ7NYFf7PR+Cwt8MeAtg HTdeN5F0mrwr+3r9X6/uArvZauAxDN50U1mJmRK8CP8hDnNYQykzo4ocJLsGzXS2DAJg HIHcqdyn3GuhRVD5LhQfYVuQjtZBVrQqTJ5O0Kph94UjVKTe+szuIq/egnbhA+VN5lV5 lf7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PWlHozXjBpcdg0186JVwtvZRV5XBQhKzqyfGbgLa+ro=; b=KNzLzBgs1gkvP8LN8szr5R71wrqlXshMsrDkhvPh6dqzpG+62mxTZuylLfX3b+mnjW fSNAPFv9lgDisegrmgRcQWfZyyHfJkBFYUvAJXQhvRajjYHIjZcNxllEeSejgU8tIavO d0ZJcGW9VTY+oN+t8zRS4CRoSa6XjTHTk99jcwqwsvZHpnsUGQcSIKHrxmEsQBaENvbT NDBw6DzADY6gNrjjYu6CNxsN7fje2x64kvIEhDzXdJrCO/3B9zNQOHauwupCHBS+kve6 NbD78VlMOFVBTTxDyJdB+TGo9uIkRhCS1Thzo+X3yvE6a4sd6Ld9o/ISbygRKV020B78 subw== X-Gm-Message-State: AOAM531PIdR3N78J4t5kG6ZJbadL9u+P+SQRchpduYS9P5rNORtN8JE6 9YLufUgHdGKYn5FXgLlY8Qw= X-Google-Smtp-Source: ABdhPJwlyKDmkv2A2G/wEiPnMyYQww/ts0ITpwATX8699WJbhzAbVAwiOdqVU4+pIr+Snuw5mSFvGA== X-Received: by 2002:a17:902:7606:b0:151:6e0f:8986 with SMTP id k6-20020a170902760600b001516e0f8986mr20427236pll.20.1646329723071; Thu, 03 Mar 2022 09:48:43 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:48:42 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 3/7] net: dev: add skb drop reasons to __dev_xmit_skb() Date: Fri, 4 Mar 2022 01:47:03 +0800 Message-Id: <20220303174707.40431-4-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Add reasons for skb drops to __dev_xmit_skb() by replacing kfree_skb_list() with kfree_skb_list_reason(). The drop reason of SKB_DROP_REASON_QDISC_DROP is introduced for qdisc enqueue fails. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 5 +++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index e344603aecc4..62f9d15ec6ec 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -398,6 +398,10 @@ enum skb_drop_reason { * failed (mapbe an eBPF program * is tricking?) */ + SKB_DROP_REASON_QDISC_DROP, /* dropped by qdisc when packet + * outputting (failed to enqueue to + * current qdisc) + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 3cadf13448c6..80fe15d175e3 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -46,6 +46,7 @@ EM(SKB_DROP_REASON_NEIGH_QUEUEFULL, NEIGH_QUEUEFULL) \ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ + EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 828946d74a19..3280ba2502cd 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3730,7 +3730,8 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, no_lock_out: if (unlikely(to_free)) - kfree_skb_list(to_free); + kfree_skb_list_reason(to_free, + SKB_DROP_REASON_QDISC_DROP); return rc; } @@ -3785,7 +3786,7 @@ static inline int __dev_xmit_skb(struct sk_buff *skb, struct Qdisc *q, } spin_unlock(root_lock); if (unlikely(to_free)) - kfree_skb_list(to_free); + kfree_skb_list_reason(to_free, SKB_DROP_REASON_QDISC_DROP); if (unlikely(contended)) spin_unlock(&q->busylock); return rc; From patchwork Thu Mar 3 17:47:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767853 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0ED1C433F5 for ; Thu, 3 Mar 2022 17:49:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235484AbiCCRtr (ORCPT ); Thu, 3 Mar 2022 12:49:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235497AbiCCRtn (ORCPT ); Thu, 3 Mar 2022 12:49:43 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2A5E65D15; Thu, 3 Mar 2022 09:48:49 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id ev16-20020a17090aead000b001bc3835fea8so5596105pjb.0; Thu, 03 Mar 2022 09:48:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IXXy8tItDSSNPgkXBETgYqVVttiEbKcqnrza3F8IHCE=; b=pOrj5jl3YXlc2w/1NfpmwsvrF+hmx9DIeQniHkiOpV5W6oszyySG3oYnO357Xm3Q24 brqM9cRWHGsUx+LoGKrvKz3TwywgbllQ3T9/cjkHjdcVbR04ReRU+40nXesEK6VxBjy/ zVSRgM26ZIELoQC+U5YXUQnd+mDeUNnL0iUqROcATHknIMZ5Iref+0z2sHc+w+DCcMEl nDxa7bUtitKesIVmz90CVOIG/ylOWjsMOXIGLXgj1BsXvxk851g/X6tbkc9i72Ns8+Bx 2WvGOGbBFT0dm7XideOVIZhzeJ2evOPwFJf1E/QScC9GQEsDsgiOozuQNVAL+OcEKffY UPIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IXXy8tItDSSNPgkXBETgYqVVttiEbKcqnrza3F8IHCE=; b=7xIxQern6jFe/wv3dUUVFNh4PPynl1Aaa8lFDf+YaK7NluCEooLR77NrTv9ieJPzPb DSCTuPd2JeqdE6OAMot5EsYNGY1+hJGlO2ggUJ5RbYC0u8frkjem7m/Ap6umjbQTbK/q hCaxjEhVv4QRrapcrdJ+sVwytgaRU7o2qKLqDcSMXoi1h6WCsYD0pjs6u59TR/2kShcF SZ8rKpwHScceZszFwVx+iSKi3COO2Xa0Awyts7FEF0S56/evpUZBtznt388+mxCujAQP D5UL9DAhyVz5AoGYpKXdKesxGblwGPlEMllO7fzZ0rSFOnVDy2O4cYvZy8TKp96N4Wnh SB+Q== X-Gm-Message-State: AOAM531IpLDnwjZVw+leKl4GcAxwjTZOo/CpJvoGc8W6Ty2D/SXOD9YD E0XmVCh7uZf1t1HnwdGJwbU= X-Google-Smtp-Source: ABdhPJzVfMHjCXoC86qooxkiZAIGtZZC/FFA8uzCjjU3tqADFukDqdmvC64oxouAHFXyFdtQdNEF/w== X-Received: by 2002:a17:90a:800c:b0:1bc:6faa:623f with SMTP id b12-20020a17090a800c00b001bc6faa623fmr6574738pjn.76.1646329729201; Thu, 03 Mar 2022 09:48:49 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:48:48 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 4/7] net: dev: use kfree_skb_reason() for enqueue_to_backlog() Date: Fri, 4 Mar 2022 01:47:04 +0800 Message-Id: <20220303174707.40431-5-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in enqueue_to_backlog() with kfree_skb_reason(). The skb rop reason SKB_DROP_REASON_CPU_BACKLOG is introduced for the case of failing to enqueue the skb to the per CPU backlog queue. The further reason can be backlog queue full or RPS flow limition, and I think we meedn't to make further distinctions. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 6 ++++++ include/trace/events/skb.h | 1 + net/core/dev.c | 6 +++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 62f9d15ec6ec..d2cf87ff84c2 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -402,6 +402,12 @@ enum skb_drop_reason { * outputting (failed to enqueue to * current qdisc) */ + SKB_DROP_REASON_CPU_BACKLOG, /* failed to enqueue the skb to + * the per CPU backlog queue. This + * can be caused by backlog queue + * full (see netdev_max_backlog in + * net.rst) or RPS flow limit + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 80fe15d175e3..29c360b5e114 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -47,6 +47,7 @@ EM(SKB_DROP_REASON_NEIGH_DEAD, NEIGH_DEAD) \ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ + EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 3280ba2502cd..373fa7a33ffa 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4541,10 +4541,12 @@ static bool skb_flow_limit(struct sk_buff *skb, unsigned int qlen) static int enqueue_to_backlog(struct sk_buff *skb, int cpu, unsigned int *qtail) { + enum skb_drop_reason reason; struct softnet_data *sd; unsigned long flags; unsigned int qlen; + reason = SKB_DROP_REASON_NOT_SPECIFIED; sd = &per_cpu(softnet_data, cpu); rps_lock_irqsave(sd, &flags); @@ -4566,6 +4568,8 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu, if (!__test_and_set_bit(NAPI_STATE_SCHED, &sd->backlog.state)) napi_schedule_rps(sd); goto enqueue; + } else { + reason = SKB_DROP_REASON_CPU_BACKLOG; } drop: @@ -4573,7 +4577,7 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu, rps_unlock_irq_restore(sd, &flags); atomic_long_inc(&skb->dev->rx_dropped); - kfree_skb(skb); + kfree_skb_reason(skb, reason); return NET_RX_DROP; } From patchwork Thu Mar 3 17:47:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767852 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C97ACC433EF for ; Thu, 3 Mar 2022 17:49:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235451AbiCCRtq (ORCPT ); Thu, 3 Mar 2022 12:49:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235479AbiCCRtn (ORCPT ); Thu, 3 Mar 2022 12:49:43 -0500 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF7B6692B3; Thu, 3 Mar 2022 09:48:55 -0800 (PST) Received: by mail-pj1-x1043.google.com with SMTP id ge19-20020a17090b0e1300b001bcca16e2e7so8312953pjb.3; Thu, 03 Mar 2022 09:48:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YLrSI94Uiwy3g6pV3msifjgFEANBJZPbxRHw7SSLhdA=; b=hQlBrnsB4zTkyzKjNDTGpsGuorfYjPy4uEgWUm4YjxbMyGa9bMPPI+J/hMqtw+Rgc0 s3EOI9NVgzy3OIw3qwMAXFO6vc9YU1jpS25u05VmL/xPQ4WaHF6pWzkTvzK+mzU5v8cn EcNOrm5XNM7Yo2LpUvGrtawiw6/EPvNkGNYRj9UUzupS/6tebwPT7AqIAwA/Ty3Kuggw pf3JzResSzZUrdgPEUj53rnCaD/Ml63/Hh+oDam3No/Jt40HOrA2ycWFchlGZqp6Qx9n cn+JCfQQEUoOfnZ8PNMcQncdnulysWU5S5lIgCNXnlL8p0HgpFS32gN3+pEnDIRXV7Pr /hLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YLrSI94Uiwy3g6pV3msifjgFEANBJZPbxRHw7SSLhdA=; b=4ouTQKhgVxfEjKt5bTxd1rmhS734N+0vqkvJ8MnNVw03UhHkIXVYkiRciAsoK239BM S4/48uXjL2xRGjCdHwjR/GJpzE111S01tqYda1ScaZF4zbFkyz9FIueZFgt7VU8oalKD ieeTXe0cCdLpTjQspjVhLVAHUGdz6k6MfudrlpII7Fbz716GIVeZaZqxCjmausyPTGT6 waF6ZbGU4P1B2I4yfMIoe7MQ2aEsan9RuQX6hB2KgSsx1wZ0SQnQbW6JR2KxXp2aKD45 8x28BLic+OX2GsW23UES2L1Nndjy0mpflaH38L4gzP130j5fWveGjyGklGquU/1RbJ74 3o/A== X-Gm-Message-State: AOAM531ESp0JfeJW50sk1I3NhJxrnRZ5n5Iv0oiPJi35abzRS+JMznWM q2+D5KwnpQCaLumFytB2Xnw= X-Google-Smtp-Source: ABdhPJwsG12VObYnwUeH0gp7hc4IbKOA/gSOfwxebw1OiTTj6/7iK2UweTExsKBSouovle2zNYKk4w== X-Received: by 2002:a17:902:b709:b0:151:49e7:d4e1 with SMTP id d9-20020a170902b70900b0015149e7d4e1mr28460027pls.144.1646329735295; Thu, 03 Mar 2022 09:48:55 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:48:54 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 5/7] net: dev: use kfree_skb_reason() for do_xdp_generic() Date: Fri, 4 Mar 2022 01:47:05 +0800 Message-Id: <20220303174707.40431-6-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in do_xdp_generic() with kfree_skb_reason(). The drop reason SKB_DROP_REASON_XDP is introduced for this case. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 1 + include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index d2cf87ff84c2..23bbfcd6668b 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -408,6 +408,7 @@ enum skb_drop_reason { * full (see netdev_max_backlog in * net.rst) or RPS flow limit */ + SKB_DROP_REASON_XDP, /* dropped by XDP in input path */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 29c360b5e114..c117430375c0 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -48,6 +48,7 @@ EM(SKB_DROP_REASON_QDISC_EGRESS, QDISC_EGRESS) \ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ + EM(SKB_DROP_REASON_XDP, XDP) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 373fa7a33ffa..ae85e024c7b7 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4797,7 +4797,7 @@ int do_xdp_generic(struct bpf_prog *xdp_prog, struct sk_buff *skb) } return XDP_PASS; out_redir: - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_XDP); return XDP_DROP; } EXPORT_SYMBOL_GPL(do_xdp_generic); From patchwork Thu Mar 3 17:47:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767854 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DF97C433EF for ; Thu, 3 Mar 2022 17:49:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235466AbiCCRts (ORCPT ); Thu, 3 Mar 2022 12:49:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235470AbiCCRtr (ORCPT ); Thu, 3 Mar 2022 12:49:47 -0500 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24FB15C86F; Thu, 3 Mar 2022 09:49:02 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id 27so5145868pgk.10; Thu, 03 Mar 2022 09:49:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Fnjte6kAZ17izSIaUaIdGjFx4P4niSUH+nE3s7tzWho=; b=Ecw71FSwoCGeKrXGC9d1uyLYUYckAoIiXkLLDDRSjaN5bse+7vkAafwMj/rs2mZACW BGZhGvXWMN/Yxn1m+0BV7uMyQMYx+c3zmTuYYzD31a2lPQwq4scVxpc6eKnyZOqBwLJu td890TNZBLAlv5Yw+Zc1L9dUhQRNTJnVXrOdUyjyq9dt/t2o1ENIou6G6NegsyA23rng 2f/k7XimrO/nq7m5Ak7fmnIq9fkirvYdTQEI4k6ZYdNzyx8cmSVHRYKz7BSAduqCLac8 x2wzsoKMGlXIigY3mubQXI/JuBwrQrtDNB9zcHPZmEnq7hApYt9XYeWo3q+1zf8oBP+C +WPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fnjte6kAZ17izSIaUaIdGjFx4P4niSUH+nE3s7tzWho=; b=ShOl958FaBh99ADFSsfgv/3GVzcCOX4udU8Ah1TxPzpm244yneFNJzdPhM+llWkgtS oUGL+3B/6zZItril0J+JnAofCRjsGCY+54L3ATYNrTGW3XddmyzQJebLFIXx2B2Gtrdx YZ5Medmn7gUpquNxUvsS2oWF/AHoPdGJepawEOOSL2athbYlhItYT0KRgFETYCVi2SfI svrQ1rogXSOYwm3kUFVBDY6XoQcdcnMG+EDOM/1VDxVfmkxwl70zNzrHiWI+lgXcWhmI coC/bSQzW4MF8ucxNWUbz1uGwjDU0c/t7kZtEWHH/8af0HxW/WJp19R981QIPn4Lm2qp QpCA== X-Gm-Message-State: AOAM533gPJj/d9woRamielZPcyad5q5FojZS1HUfAa9+c//GS787KYoQ 1wfP3BJ8CWEl9y3tejmiOqs= X-Google-Smtp-Source: ABdhPJxQTgNyldxx1uY5XEeSOV5k01ICFsEJ7XLVVQxIGf3dXzoDhbHUjrKnqn3czM1bSRfH8B+39A== X-Received: by 2002:a63:e808:0:b0:378:b7a4:145c with SMTP id s8-20020a63e808000000b00378b7a4145cmr16698010pgh.78.1646329741424; Thu, 03 Mar 2022 09:49:01 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.48.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:49:00 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 6/7] net: dev: use kfree_skb_reason() for sch_handle_ingress() Date: Fri, 4 Mar 2022 01:47:06 +0800 Message-Id: <20220303174707.40431-7-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Replace kfree_skb() used in sch_handle_ingress() with kfree_skb_reason(). Following drop reasons are introduced: SKB_DROP_REASON_QDISC_INGRESS Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 4 ++++ include/trace/events/skb.h | 1 + net/core/dev.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 23bbfcd6668b..04508d15152e 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -409,6 +409,10 @@ enum skb_drop_reason { * net.rst) or RPS flow limit */ SKB_DROP_REASON_XDP, /* dropped by XDP in input path */ + SKB_DROP_REASON_QDISC_INGRESS, /* qdisc of type ingress check + * failed (maybe an eBPF program + * is tricking?) + */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index c117430375c0..d635951c9db8 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -49,6 +49,7 @@ EM(SKB_DROP_REASON_QDISC_DROP, QDISC_DROP) \ EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EM(SKB_DROP_REASON_XDP, XDP) \ + EM(SKB_DROP_REASON_QDISC_INGRESS, QDISC_INGRESS) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index ae85e024c7b7..429ad8265e8c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5013,7 +5013,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret, break; case TC_ACT_SHOT: mini_qdisc_qstats_cpu_drop(miniq); - kfree_skb(skb); + kfree_skb_reason(skb, SKB_DROP_REASON_QDISC_INGRESS); return NULL; case TC_ACT_STOLEN: case TC_ACT_QUEUED: From patchwork Thu Mar 3 17:47:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12767855 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95B3FC433FE for ; Thu, 3 Mar 2022 17:49:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235514AbiCCRuB (ORCPT ); Thu, 3 Mar 2022 12:50:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235548AbiCCRt5 (ORCPT ); Thu, 3 Mar 2022 12:49:57 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C0516D87E; Thu, 3 Mar 2022 09:49:08 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id e13so5231277plh.3; Thu, 03 Mar 2022 09:49:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ruUEYX+oGrKbn1ZFxR7e2X74GRqZCSY8RPwITu5sMBQ=; b=U8UL49W6S95k93kWUmUrZFOzV7AbqOjJ1bvHbZte2nKkMImfo75O4/DPZLqHC3elEp c+LZNgdegz2lHbu/RdR6vG9Ln7uG/fSitvZ+uxszFFHomApmFxo+8Lcz2+48izzHzbf4 UiOBTkVeiHLPhO0AhY+CCq8jEARbdisLO4M1/Qio4qV7PEdJmuzR5LNMnCfVzQXSKh6F CspWJg5YFdFl7tbLlAByeDrhMJV6OruBTPfRuxH9AuHQo+iUO+D20ot/ll3ZcwpDlDJI Ua2+yPUkeHalmu+tZdRjZawPc6L5eGbNH78deLTVZx78YQdW0fCfMYTLg7rXDAhE4o5z x5Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ruUEYX+oGrKbn1ZFxR7e2X74GRqZCSY8RPwITu5sMBQ=; b=pTJifR9+MbYeLJoW/empF7Hs+1DYx98wgjMKwmByw2ibuq7spHUrZyxURaql0a07My NCHyQrYEAmIEvnSZ//xNh3QbAkg6BUVQrNNx/m8hJqvZXHweHhAgF3n5LZJatLTsPfiZ tnxjRYBjrOxHG52HADJdDkDrRGVGaK9sU80XqsSKx9A8VCLHKTCcFW+bma+8/CYVIZYF EXbZCM4aaJNB7QqQ5oIuhTLbddYkTJxD0LJNhNd6WYj7AOaYW+nZrPHF3pOR6FKISvi3 wewukAUjpdkxSJ6NNu08jZrGBQJFFpW8TIwZ7v8ljOfc0QiFbiUxw1SUu75W1x8FVr7k w1bg== X-Gm-Message-State: AOAM533fOeeyG8o4pkBaxQ7uCgAP4gc93Y56xD2WmVbbTiEuTTbgMzIS DpWhLtZ4yqudYiIJwebHCFc= X-Google-Smtp-Source: ABdhPJzYUCmgCQ43Sq8ZW/63tx2sfXwtI21Xs+ZjEulnRLAPyr/CB2m3mSf68xNzY2i7M7IZsAqTyA== X-Received: by 2002:a17:902:ec8c:b0:151:b231:70da with SMTP id x12-20020a170902ec8c00b00151b23170damr2229816plg.5.1646329747662; Thu, 03 Mar 2022 09:49:07 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id a38-20020a056a001d2600b004f0f0f852a4sm3209395pfx.77.2022.03.03.09.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 09:49:07 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: dsahern@kernel.org, kuba@kernel.org Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, imagedong@tencent.com, edumazet@google.com, talalahmad@google.com, keescook@chromium.org, ilias.apalodimas@linaro.org, alobakin@pm.me, flyingpeng@tencent.com, mengensun@tencent.com, atenart@kernel.org, bigeasy@linutronix.de, memxor@gmail.com, arnd@arndb.de, pabeni@redhat.com, willemb@google.com, vvs@virtuozzo.com, cong.wang@bytedance.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net-next 7/7] net: dev: use kfree_skb_reason() for __netif_receive_skb_core() Date: Fri, 4 Mar 2022 01:47:07 +0800 Message-Id: <20220303174707.40431-8-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220303174707.40431-1-imagedong@tencent.com> References: <20220303174707.40431-1-imagedong@tencent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Menglong Dong Add reason for skb drops to __netif_receive_skb_core() when packet_type not found to handle the skb. For this purpose, the drop reason SKB_DROP_REASON_PTYPE_ABSENT is introduced. Take ether packets for example, this case mainly happens when L3 protocol is not supported. Signed-off-by: Menglong Dong --- include/linux/skbuff.h | 5 +++++ net/core/dev.c | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 04508d15152e..f3945d21cecf 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -413,6 +413,11 @@ enum skb_drop_reason { * failed (maybe an eBPF program * is tricking?) */ + SKB_DROP_REASON_PTYPE_ABSENT, /* not packet_type found to handle + * the skb. For an etner packet, + * this means that L3 protocol is + * not supported + */ SKB_DROP_REASON_MAX, }; diff --git a/net/core/dev.c b/net/core/dev.c index 429ad8265e8c..0bdea7d113f5 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5330,11 +5330,13 @@ static int __netif_receive_skb_core(struct sk_buff **pskb, bool pfmemalloc, *ppt_prev = pt_prev; } else { drop: - if (!deliver_exact) + if (!deliver_exact) { atomic_long_inc(&skb->dev->rx_dropped); - else + kfree_skb_reason(skb, SKB_DROP_REASON_PTYPE_ABSENT); + } else { atomic_long_inc(&skb->dev->rx_nohandler); - kfree_skb(skb); + kfree_skb(skb); + } /* Jamal, now you will not able to escape explaining * me how you were going to use this. :-) */