From patchwork Fri Mar 4 06:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768499 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 10375C433EF for ; Fri, 4 Mar 2022 06:01:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238241AbiCDGCg (ORCPT ); Fri, 4 Mar 2022 01:02:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238246AbiCDGCe (ORCPT ); Fri, 4 Mar 2022 01:02:34 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FC4C18644E; Thu, 3 Mar 2022 22:01:47 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id c1so6638470pgk.11; Thu, 03 Mar 2022 22:01:47 -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=L9IOl6pjPg22QK2MP5IDPTP2U5QiFnZFZ9yjUF6EnBk=; b=WLZRGNecUiHs3lVzcetuym+N87W3/xfs34bO97KIUwpQVSf+vD71DIzI0QpGxHsGSc ZVR6+nCFWbbrXOi+cHcqKczkXD/6omNp6EpYx0NLfuox5L3Z9PVfyJypIJJ7IJSLalkK 2RErbyDPeAXW3TbmNak9JXgQL16xVrR5Oew0j2urZiUPhe3JbXHjc4b9mndc3jp38la7 KqSSSsdwQ0tlAlqNXXSOSHT8xxzwnh6gXkMseQ05LBZ4+cd0ULt/I8+B9QcJdvmR92mZ HVcRcWTDxEbNWYeRiza0bW9wNrFxvIIex2pW2PKv5x/F7o41KTfA8uReCgFUIEETPoMw 4X3A== 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=L9IOl6pjPg22QK2MP5IDPTP2U5QiFnZFZ9yjUF6EnBk=; b=J0sUcC+C/ouizHgrLLxpvL1dny1Fot97fMHysJ7Q3vEoxQFLGA5aSO/A89eXwyio/M TstcEuyYlBpcWxhbqupyUINg+hibnKtfNkskXXTfO8Dx+sOWYEBB/T6W7SQ3PBkVO2+i wrU+uRjZxaSJLrNa955gUQ2Y/hgMr7flXGe3LvnvmLeQ0BUqaqjNoSeFJ3gunxVwyBAo 5Gz+WC2FgeJIdwqfc1Y/huKg+cqR7iFRtCdUqNBxzFvo/v7Iz2aEn7gL3O5BDWjHtalu 1+RFhZat99F3QhQKtxYjYb7B65ROC/4zwHsc6U4Q34+cQlbhZoN50g0Soe/UuYpfAzc+ Gzjg== X-Gm-Message-State: AOAM530I+8y2rXa4EZjsschhOIBQfG0nP1xSzP+nYYd2qkvYzKCY+W7V h4/UTZOGHtkf+49mjNfo79NpTSfiLgI= X-Google-Smtp-Source: ABdhPJxYqFNPC/jDWUbDysKVzCiVab2X9l5McdowJYkNBxDit8vdq6NEL9TTOOoV78Vp0Z14SkPVyg== X-Received: by 2002:a63:8a4c:0:b0:37e:31f8:15f2 with SMTP id y73-20020a638a4c000000b0037e31f815f2mr90695pgd.225.1646373707078; Thu, 03 Mar 2022 22:01:47 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:01:46 -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 v2 1/7] net: dev: use kfree_skb_reason() for sch_handle_egress() Date: Fri, 4 Mar 2022 14:00:40 +0800 Message-Id: <20220304060046.115414-2-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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_TC_EGRESS is introduced. Considering the code path of tc egerss, we make it distinct with the drop reason of SKB_DROP_REASON_QDISC_DROP in the next commit. Signed-off-by: Menglong Dong --- v2: - rename SKB_DROP_REASON_QDISC_EGRESS to SKB_DROP_REASON_TC_EGRESS --- 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 d67941f78b92..4328dfc3281c 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -394,6 +394,7 @@ enum skb_drop_reason { * entry is full */ SKB_DROP_REASON_NEIGH_DEAD, /* neigh entry is dead */ + SKB_DROP_REASON_TC_EGRESS, /* dropped in TC egress HOOK */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 1977f301260d..53755e8191a1 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_TC_EGRESS, TC_EGRESS) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 2d6771075720..353322e72a61 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_TC_EGRESS); return NULL; case TC_ACT_STOLEN: case TC_ACT_QUEUED: From patchwork Fri Mar 4 06:00:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768500 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 8FA15C433EF for ; Fri, 4 Mar 2022 06:02:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238267AbiCDGCs (ORCPT ); Fri, 4 Mar 2022 01:02:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238264AbiCDGCp (ORCPT ); Fri, 4 Mar 2022 01:02:45 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE8DB187BB3; Thu, 3 Mar 2022 22:01:53 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id s8so2704117pfk.12; Thu, 03 Mar 2022 22:01:53 -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=tjhKldmhGAQAKgh1N5IQxYI+us242gVIaXzKgAhlpB4=; b=HtuTEnJ2wd9lCxrNLk5HQGdIgKm6ydkREnk7Fbin73qK0AS181fzvfDRlyo/i7DLU/ 3HJlN8+mVLRrfddY02FDoLEt1B0M+K3f5OxrvdGN7pLdZ2maBhCfGWHQFhoY35oF18cx 1VXIEVEr+U+1AGdE+NsWF2882RkLDbJD2x1YYOzAPFLauMXd+cHvwQCVXgL12MB183vX zFx2xNHo523CMr5LcS1MxfhYE0Iz7b1QIl+j8dC9GWybtcgWvVm3+7Uc4vgpHCpzLGI+ 2vFa0a7vVoGUr2G75DBdGONf/DHEI0/v9pzzxJ33UBHV5LHxqbao0A5TGqGbL0UZ648q qInw== 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=tjhKldmhGAQAKgh1N5IQxYI+us242gVIaXzKgAhlpB4=; b=pWu0ML+CdHzD+HW9ZrSGNnhR1nunVKvNuVGxUV7L2GMrhyk7VuIADW+1DZPYgJ3RDn /Z837lb3i5yUTX1vyP6TBzwZeeMr3fdCMLAjWd774G9BU0+1y0Wt6cypwqX8T+1jxUGY vQaPYGizMoObDS0ui2ffv2vlZzzN39DoSbSl07rXJgM8hQIZOqZ8RJBSdHGiWlLOGXO5 6YBjzYcNNBZpbCo1aMkrNKPf/RX9BQqpf6G+NG2mIr2qex1jFfIyGHUNoze0O4zkE4gk GAeiOyxl85Z5nqlsp+HSN+pav0NzqP+CPuc/YFGudm3OV1kXwdBo1Wt31VNXwCfMbja0 aNAQ== X-Gm-Message-State: AOAM532zFT9fqBndZNlFtLIE793RvU0rpbHhjht6J67CYcNgmG03D4SG OcX2T+w0U8iWJWZ/zi1s6MA= X-Google-Smtp-Source: ABdhPJzVdfO3qBUbuK9q3ei1i1cI197lrtsYkwOThyAy7Xhufbk4bao0s5MjPWsA5RcuSutnEC/UoA== X-Received: by 2002:a62:3085:0:b0:4e0:1218:6d03 with SMTP id w127-20020a623085000000b004e012186d03mr41186844pfw.19.1646373713307; Thu, 03 Mar 2022 22:01:53 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.01.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:01:52 -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 v2 2/7] net: skb: introduce the function kfree_skb_list_reason() Date: Fri, 4 Mar 2022 14:00:41 +0800 Message-Id: <20220304060046.115414-3-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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 4328dfc3281c..9d219e266dc7 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1191,10 +1191,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 Fri Mar 4 06:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768501 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 3851DC433F5 for ; Fri, 4 Mar 2022 06:02:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238263AbiCDGCu (ORCPT ); Fri, 4 Mar 2022 01:02:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238277AbiCDGCr (ORCPT ); Fri, 4 Mar 2022 01:02:47 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 391D418644E; Thu, 3 Mar 2022 22:02:00 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id y11so6785729pfa.6; Thu, 03 Mar 2022 22:02:00 -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=M1KGGJ++5jvrBcGkFVx4NiuAGaDCJ+LibUibMFb2wJo=; b=eGL+lMsza+NRI7f1au4IUVjPjVgjopU7gUu3TDgoNEPCYpCFiUliOlTBqgPgRJ3XJW mdVvtktc4gIoB12ZWU6m0PLLuZt8P/QoxAowaCMHs3B8IM3jxJnEsKNO2iyA+ToA5Lb0 WfypiescCI9F83DvithbGm638ZLN9JAI5PZztfs68fLbbwlnFKfSQtDP5/lf8ktWU6zO GFrudvjp30eeucmgSXGADFxguxKt/JykSFEdT+D78up4Szpe/3zF2EKpckvWWJruVdBl Ap5EpgNNNc1LQcQBQ+g+0SzS/BsvKGAE6tXxNGsL8agqKEhq/IVsii8H7rawW2p6jPeW 788Q== 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=M1KGGJ++5jvrBcGkFVx4NiuAGaDCJ+LibUibMFb2wJo=; b=bEwkrgPp+wRqMfueH29DS+nHZslJLR+X66GkmddrgZFCQnk//KiGJIFolCCHOqb930 8WMUGlQMD/JLqlAyzlnnPLkQaIsmdTW+6vUqf/5927inBKK9I0t3AOHNHRmqoKygnkyK zgTgDMKGviHu0sPnAErcH57BjdwNDFe2K9pSIdHRIuywffiC/VpRs7dqZ05BR1yx/yf1 NfmcxY4glveJorbNdAFHKP6lra0Ootjb4i/olJAHSQMgQUpOyKSQ2UHF9IuNH6xBzkSu 6JlQDR4GeQg35EUW+RCNFQOhRaYx3m/uRbzl6Kkqrd0sZhVMesxO8NRLsXbOO344rSO9 FdoQ== X-Gm-Message-State: AOAM530+7uPmy7pZ3HU98ypB8FBzgaB8eZL0/GPsNBRZtvMeEz8dqv0+ VLhcexDFCihe3Xtvcid/NGM= X-Google-Smtp-Source: ABdhPJxDUYrkMB4n7fkWhNNcvZb9Nko0XU74IJcdXzXHcXNn77Ko6MKFcATl2GCXVUQK9EGDUxW8Ng== X-Received: by 2002:a05:6a00:987:b0:4f3:e5d3:448d with SMTP id u7-20020a056a00098700b004f3e5d3448dmr32437882pfg.14.1646373719728; Thu, 03 Mar 2022 22:01:59 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.01.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:01:59 -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 v2 3/7] net: dev: add skb drop reasons to __dev_xmit_skb() Date: Fri, 4 Mar 2022 14:00:42 +0800 Message-Id: <20220304060046.115414-4-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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 9d219e266dc7..a3d65e749ea3 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -395,6 +395,10 @@ enum skb_drop_reason { */ SKB_DROP_REASON_NEIGH_DEAD, /* neigh entry is dead */ SKB_DROP_REASON_TC_EGRESS, /* dropped in TC egress HOOK */ + 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 53755e8191a1..dbf3e2e3c1b4 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_TC_EGRESS, TC_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 353322e72a61..2ba331b5b775 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 Fri Mar 4 06:00:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768502 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 DAA96C433F5 for ; Fri, 4 Mar 2022 06:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238254AbiCDGDB (ORCPT ); Fri, 4 Mar 2022 01:03:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238293AbiCDGCy (ORCPT ); Fri, 4 Mar 2022 01:02:54 -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 DBA9D187BB5; Thu, 3 Mar 2022 22:02:06 -0800 (PST) Received: by mail-pg1-x543.google.com with SMTP id t14so6668982pgr.3; Thu, 03 Mar 2022 22:02:06 -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=pNFrY2MhzoakFNW6ci8QTeSX3zRLAuHfLCZuqh4I71Y=; b=jAlc4UdrydDIJ23f6GwmZhCfGK6niQ/+YpwSezFPqnTOJFGSLxHlgKFpyV//3VNK4/ Xhh/7ciTu/9l4h2AvwzUpKwaRtkBqHTJyvtM8kyXe6E94F4jjeJMf2RAOblwkdF6mMPz p2rZ+Km1e3L0z5aOQaL+9M80Yq8Z3GgiqTX6YJHQOvlI9yTtGEfoFZAjmsWjpmbT0zp5 Oe+pyMnFQNAZwB1urqENLAcHnx9zRk4N5qJsQo6u+guiRUb61zwCn2ztSSnSviXY9MHR aeTVTH3sUXufgVoponxiCE4/STG8366xtXcTs6UimhUf9o7L/L83CJ64s19z40kib2Tg r7iQ== 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=pNFrY2MhzoakFNW6ci8QTeSX3zRLAuHfLCZuqh4I71Y=; b=BydA6o4eQ+DB0bGKeiVzWwJaKpYzQdyHZzwM4JcTSqBQvOMJaUj9LZWmQ9OjvDEG5P MSFn/oKwzo+6SPR8ToJXSA1j330AwK6rmoITF5Pl1WZMSJWRY6CY8TYkdhleQLX6IbkK ypVMkCG8U92cTWHW7albfTigRtF2EXN8kYM0uOZLiE4Ygn4pMhdlmGNMJUG/Cx7A7hM7 SLImZOsSqH1Yx1eNkr14FqKpbVvRsuKV17ou5TLfRXlmEiIuI/I56Jc+grNgTisEubUl AJBOwLqRajo8DVkZWu2FXExs6xUYw4dlN3gE2VjlLJNSULoQl/Jotu5WsmKgiK+qtO6O coQg== X-Gm-Message-State: AOAM533NVqHDFXO6DF19Qsemqo0BroPsLQmP+O40GbVZG2FZ/z2kxw9d H8mZ8SERSKNXQMmZ2i5MYjY= X-Google-Smtp-Source: ABdhPJze2Haz8Mif3fbJheI8tbVi5baPyGwsK2vbIP09IJMY7YTDREKH/KMasC9N+huECprL2fbLyw== X-Received: by 2002:a63:82c1:0:b0:37c:99c3:e3ef with SMTP id w184-20020a6382c1000000b0037c99c3e3efmr1052751pgd.27.1646373726392; Thu, 03 Mar 2022 22:02:06 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:02:05 -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 v2 4/7] net: dev: use kfree_skb_reason() for enqueue_to_backlog() Date: Fri, 4 Mar 2022 14:00:43 +0800 Message-Id: <20220304060046.115414-5-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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 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 needn'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 | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index a3d65e749ea3..cf168f353338 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -399,6 +399,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 dbf3e2e3c1b4..3bb90ca893ae 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_TC_EGRESS, TC_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 2ba331b5b775..0d097d0e710f 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); @@ -4567,13 +4569,14 @@ static int enqueue_to_backlog(struct sk_buff *skb, int cpu, napi_schedule_rps(sd); goto enqueue; } + reason = SKB_DROP_REASON_CPU_BACKLOG; drop: sd->dropped++; 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 Fri Mar 4 06:00:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768503 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 69E1BC433F5 for ; Fri, 4 Mar 2022 06:02:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238279AbiCDGDD (ORCPT ); Fri, 4 Mar 2022 01:03:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238319AbiCDGDA (ORCPT ); Fri, 4 Mar 2022 01:03:00 -0500 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A5C180D1E; Thu, 3 Mar 2022 22:02:13 -0800 (PST) Received: by mail-pj1-x1042.google.com with SMTP id v1-20020a17090a088100b001bf25f97c6eso835389pjc.0; Thu, 03 Mar 2022 22:02:13 -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=2ULoADH/G/w/GjzXvy9sGJIyoEGuMSEszufVomHB7uA=; b=bz2SH/N4U/Rx1gWGIr1xhDyrbbxaMEpULkXndj5gbwo6CRHugq43j09+Bj2POVoucU xjPWuFpQrOnpW9NlurPUHWZGVqm82+t4Gp/goX4qQiAWF4j+8Z3oCpyaCpl7Lfb1K/jE d8i5lAH26cEpgKOfCSq4LnIf7HfiBndcRtEDW11HXXfXmDg39ELXhiFmbcg+93gLSrNz +VdN4AcUzf8e+Rskekk2biMYNzm5SMmQXnjyEq4dG1x+blnRW0C8r+n1M/TSyXvL4D2X bfpC4721F+UdZGNDr7KpQEQytfeNVMDxTWhTMVaLVK9hOL3iKoJj/F1rbTTVX7Na/R4j J7dg== 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=2ULoADH/G/w/GjzXvy9sGJIyoEGuMSEszufVomHB7uA=; b=G7Gv9Zs4nZ14snOtpt9QZXbkFuE6+DgUe6/mlqO4LjycHEuGn5z48R9mDoi/Ny3CcN WClcq2qChuaTSLJ4gsyg4u0fz1zcIUgxna1v8M5OlqO3jOvEX3bLzJPDT8NR4bJ/nwXf AS19F0tht4dDlvjf71ogPh+TvVBu8Yc0z3D+Mps2dh6oRkcSQyv1epHNl5tf3vK7Rxsj +QZlWlSzxgzv7sUvsTLP3iqykDyjeys5MjLS+q2rWGxto63TTVD3WZNGJ2N2nLadSKRE jSNJvidqG4gJPAvjXTWCCMyIL9gi32s8DsMCoK685gUop4vIAPeg3Bs+KuvajUY18VyZ F2Tw== X-Gm-Message-State: AOAM533fMwPQDr2HYARwHfNMqL1kwhTP+RcpaBVJnrs4jM+U6Rx5D/C+ DgNlB9USvKeRh2b8O3EjakY= X-Google-Smtp-Source: ABdhPJzhsX1xOnjhKTkwadwDJeFX8fWua5amWOWJcVyIqY/a8MXA7kUgitMl879r7HardqTehx+2gg== X-Received: by 2002:a17:902:8d93:b0:14d:d2e9:37f with SMTP id v19-20020a1709028d9300b0014dd2e9037fmr39027415plo.83.1646373732883; Thu, 03 Mar 2022 22:02:12 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.02.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:02:12 -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 v2 5/7] net: dev: use kfree_skb_reason() for do_xdp_generic() Date: Fri, 4 Mar 2022 14:00:44 +0800 Message-Id: <20220304060046.115414-6-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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 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 cf168f353338..e13ef6ca5470 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -405,6 +405,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 3bb90ca893ae..8c4c343c830f 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -48,6 +48,7 @@ EM(SKB_DROP_REASON_TC_EGRESS, TC_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 0d097d0e710f..5ad74a46452b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4796,7 +4796,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 Fri Mar 4 06:00:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768504 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 127B5C433F5 for ; Fri, 4 Mar 2022 06:02:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238302AbiCDGD1 (ORCPT ); Fri, 4 Mar 2022 01:03:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238292AbiCDGDG (ORCPT ); Fri, 4 Mar 2022 01:03:06 -0500 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDE29187E2F; Thu, 3 Mar 2022 22:02:19 -0800 (PST) Received: by mail-pf1-x443.google.com with SMTP id e15so5205243pfv.11; Thu, 03 Mar 2022 22:02:19 -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=BZGaInOiLUr+kDcdbjgKggubDUn9ZQLD7jeoPnkVS2s=; b=X2D2HuQnHwkQXfRLFYyVBS+xgxKSezpHpx9+UUiBNEKHvHglkYxe1hTdVlfMlDRkjA AmUEsAkUQKWEtINhcqPvAdsNrtCXm0rcba/81UiBgDORly6jQvX+7/gG2B/fgJ01daD4 KehFzJ9VkizihcP6avYCS/WtidoLD56xL1TMK2HP80pfEjFFLl2l+eROYC7jCxq/pCje iIkBwcVRR72rT9LkY2nQ3nhB10bKeKFWRG58DMcGO7PNXrbmUOZ0/R0jOjKxYIavAgrC GSAZu/sinpmEOd1O7b8xXYd7zllr3kTxrIEbsvLN/+fzosAaWR6HWsyoJQHofnpWkgpO QILg== 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=BZGaInOiLUr+kDcdbjgKggubDUn9ZQLD7jeoPnkVS2s=; b=SSNkeQ7h+yvnmE4h+nhlWSRtzCBXVbsRMvbxWd7BH3E8WO5/V8tTrG0GK9bcukdfqT iT1FEZyoojOfSgFkRq/oOjEZS/GcW0+rITQ7WJeNUbGwCQq4zZCqrdQ7yqY4rv5F7uG4 2OKmaEPKqDzaFtuBaXHDYgF/n8gmIL20odt0GZu8UyCTUL95S9r1O8EDmqpK1EDb0Xyh RDa49zxe/W0jHvI6imxcf2a1h3heJ2Gr80odVMR1YwH2UCwBAYLoGH0Ds0FRT1XCPRJg wJzaZeqW0J8SeCN5FcX/17lj59niFvHI5T9he4rb7pQ/H7/q/6/Gs/cmqrZfds+eV3Un mA3A== X-Gm-Message-State: AOAM531LRj9AMX90e9UqQK/bWPYHUMTEP3koNnAHBcCEG8BMUxZ18bZ2 wOcXKrL59AlQETw6pdqkWao= X-Google-Smtp-Source: ABdhPJzD0P/BUERhKEQF5HyY9TzVl0iLBvCrwTO3xzYQUfje/ZoAOrI29HqAe4bRg3hgUIoSpwtjag== X-Received: by 2002:a65:5189:0:b0:378:f265:982e with SMTP id h9-20020a655189000000b00378f265982emr13066548pgq.582.1646373739173; Thu, 03 Mar 2022 22:02:19 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.02.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:02:18 -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 v2 6/7] net: dev: use kfree_skb_reason() for sch_handle_ingress() Date: Fri, 4 Mar 2022 14:00:45 +0800 Message-Id: <20220304060046.115414-7-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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_ingress() with kfree_skb_reason(). Following drop reasons are introduced: SKB_DROP_REASON_TC_INGRESS Signed-off-by: Menglong Dong --- v2: - rename SKB_DROP_REASON_QDISC_INGRESS to SKB_DROP_REASON_TC_INGRESS --- 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 e13ef6ca5470..d0a10fa477be 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -406,6 +406,7 @@ enum skb_drop_reason { * net.rst) or RPS flow limit */ SKB_DROP_REASON_XDP, /* dropped by XDP in input path */ + SKB_DROP_REASON_TC_INGRESS, /* dropped in TC ingress HOOK */ SKB_DROP_REASON_MAX, }; diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 8c4c343c830f..514dd2de8776 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_TC_INGRESS, TC_INGRESS) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 5ad74a46452b..7eb293684871 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5012,7 +5012,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_TC_INGRESS); return NULL; case TC_ACT_STOLEN: case TC_ACT_QUEUED: From patchwork Fri Mar 4 06:00:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Menglong Dong X-Patchwork-Id: 12768505 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 E1944C433F5 for ; Fri, 4 Mar 2022 06:03:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235393AbiCDGEW (ORCPT ); Fri, 4 Mar 2022 01:04:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238281AbiCDGD3 (ORCPT ); Fri, 4 Mar 2022 01:03:29 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC23918A785; Thu, 3 Mar 2022 22:02:26 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id e6so6665771pgn.2; Thu, 03 Mar 2022 22:02:26 -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=YZbkpW2xKyTTQVG0byMXWAewCWAfEpaA/1L3B4lDmmY=; b=A7frI2uSydGO/1AMxE9wse0pRdmM6SCrTeiSC4ks2zdnKTOoh79K11ogjz+dYrzatF 5SGOQG4TcrzA0vB0ZaFznZ9OL7oCYfF8OfDavaviKC3I3/jb4u8bZhdIu7Zxbi0viaiO dj7rdX0opfA2OhKzhmMp/BLJAqcUXVAgAqgaqfTa79bJ6Sg2WDQlHDVmLwcqJQzS1nFz yb/7EQ4+5yTyGXISzo0Of/SD4jKh+8rhYZfdO3DbYNHQD5f6Xr1yhhqWkJ5qMtEkZt76 C6UBw7+HdANoaTOuEl8Lr6zvAbPmhgCHBxA/1agdVvzcFJTyIsPHDr4Gl4bj5Jopb99I fpJw== 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=YZbkpW2xKyTTQVG0byMXWAewCWAfEpaA/1L3B4lDmmY=; b=KGEMiCIqlzZdz/YOQXuW6K35h3yjVWINy6xStTmH3Z0DTYvTHWGWycVKTs4BOXpa5X S/KGFZwvMfrO9IIYcnhO0j8AkCnMZ1VvcCWBHRGlLClNHye6A5fBZb0jMTuondV5Ml3M lHle7UATv5T7BkTf4GYFXt/d9x4kH96n89QPZeang3YLCy5lDSQ51EVRHtlCkZpe90MX rQfr9SeDalW+/r5B3XmFsff6XDyE+nFGWzjD8sd6iw2zxdmjaskIMYKUIRi2QBDQfXtu vxAqX1w2yJ95A9IXEEki3wilV46Froxnu02Jpua2mWq+EVkYSVfdWQFAME2k+fOevYce XQgQ== X-Gm-Message-State: AOAM532TYftNmBv84resKbkKchGCVHuMXQ1qNClOytRRASe6ck9LD67I +mAx7e0zUMbaCPZeMFOrYPs= X-Google-Smtp-Source: ABdhPJzmLM2E3rhp2SgsGu9pz4Do1FqlS0eTGN2KQSFic0NNqz1Z5lmft9TgfEh+k86XL63ysJGIsg== X-Received: by 2002:a05:6a00:1889:b0:4f6:ae19:130d with SMTP id x9-20020a056a00188900b004f6ae19130dmr3034130pfh.28.1646373745719; Thu, 03 Mar 2022 22:02:25 -0800 (PST) Received: from localhost.localdomain ([203.205.141.116]) by smtp.gmail.com with ESMTPSA id y5-20020a056a00190500b004f104b5350fsm4569073pfi.93.2022.03.03.22.02.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 22:02:24 -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 v2 7/7] net: dev: use kfree_skb_reason() for __netif_receive_skb_core() Date: Fri, 4 Mar 2022 14:00:46 +0800 Message-Id: <20220304060046.115414-8-imagedong@tencent.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220304060046.115414-1-imagedong@tencent.com> References: <20220304060046.115414-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 +++++ include/trace/events/skb.h | 1 + net/core/dev.c | 8 +++++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index d0a10fa477be..070111aecfd3 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -407,6 +407,11 @@ enum skb_drop_reason { */ SKB_DROP_REASON_XDP, /* dropped by XDP in input path */ SKB_DROP_REASON_TC_INGRESS, /* dropped in TC ingress HOOK */ + 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/include/trace/events/skb.h b/include/trace/events/skb.h index 514dd2de8776..c0769d943f8e 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -50,6 +50,7 @@ EM(SKB_DROP_REASON_CPU_BACKLOG, CPU_BACKLOG) \ EM(SKB_DROP_REASON_XDP, XDP) \ EM(SKB_DROP_REASON_TC_INGRESS, TC_INGRESS) \ + EM(SKB_DROP_REASON_PTYPE_ABSENT, PTYPE_ABSENT) \ EMe(SKB_DROP_REASON_MAX, MAX) #undef EM diff --git a/net/core/dev.c b/net/core/dev.c index 7eb293684871..c690c0f7b18c 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5329,11 +5329,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. :-) */