From patchwork Fri Oct 23 20:52:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Davide Caratti X-Patchwork-Id: 11854527 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 X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95189C388F9 for ; Fri, 23 Oct 2020 20:52:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 322EB20897 for ; Fri, 23 Oct 2020 20:52:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i3NTMI2c" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756418AbgJWUwb (ORCPT ); Fri, 23 Oct 2020 16:52:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:37039 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756412AbgJWUwa (ORCPT ); Fri, 23 Oct 2020 16:52:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1603486349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=BkkVwPtn1DQdSlrc077BWPrlkRKWINT920vgmPR1Boo=; b=i3NTMI2coDfCefufeUKqXSHjLpOWaJ/uenfdxN92UkS9fNrDDf6TwRHb+fXqpPqv3esvVY ZHIGQmQzn0T5U/r/IzKsm8tW6q3LqjrghUpwK69dHxQU3X4XdOhSOEpwN5Yezkph0Ru8w2 Dkl4BIsheGEbkVoRGWyk7VtE8tyVMn8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-210-FUIcEZqGNQONvMFFJezMcw-1; Fri, 23 Oct 2020 16:52:25 -0400 X-MC-Unique: FUIcEZqGNQONvMFFJezMcw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2DA931009E2D; Fri, 23 Oct 2020 20:52:24 +0000 (UTC) Received: from new-host-6.station (unknown [10.40.192.164]) by smtp.corp.redhat.com (Postfix) with ESMTP id C954719C66; Fri, 23 Oct 2020 20:52:22 +0000 (UTC) From: Davide Caratti To: netdev@vger.kernel.org Cc: Marcelo Ricardo Leitner , Xin Long , linux-sctp@vger.kernel.org, Jakub Kicinski Subject: [RFC PATCH net-next] net: use a dedicated tracepoint for kfree_skb_list() Date: Fri, 23 Oct 2020 22:52:14 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC kfree_skb_list() calls kfree_skb(), thus triggering as many dropwatch events as the number of skbs in the list. This can disturb the analysis of packet drops, e.g. with fragmented echo requests generated by ICMP sockets, or with regular SCTP packets: when consume_skb() frees them, the kernel's drop monitor may wrongly account for several packet drops: consume skb() skb_release_data() kfree_skb_list() kfree_skb() <-- false dropwatch event don't call kfree_skb() when freeing a skb list, use a dedicated tracepoint instead. By printing "cur" and "next", it also becomes possible to reconstruct the skb list from its members. Signed-off-by: Davide Caratti --- include/trace/events/skb.h | 19 +++++++++++++++++++ net/core/skbuff.c | 6 +++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 9e92f22eb086..b16e3544bbbe 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -51,6 +51,25 @@ TRACE_EVENT(consume_skb, TP_printk("skbaddr=%p", __entry->skbaddr) ); +TRACE_EVENT(kfree_skb_list, + + TP_PROTO(struct sk_buff *cur, struct sk_buff *next), + + TP_ARGS(cur, next), + + TP_STRUCT__entry( + __field( void *, cur_addr ) + __field( void *, next_addr ) + ), + + TP_fast_assign( + __entry->cur_addr = cur; + __entry->next_addr = next; + ), + + TP_printk("cur=%p next=%p", __entry->cur_addr, __entry->next_addr) +); + TRACE_EVENT(skb_copy_datagram_iovec, TP_PROTO(const struct sk_buff *skb, int len), diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 1ba8f0163744..7ed6bfc5dfd0 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -702,7 +702,11 @@ void kfree_skb_list(struct sk_buff *segs) while (segs) { struct sk_buff *next = segs->next; - kfree_skb(segs); + if (!skb_unref(segs)) + continue; + + trace_kfree_skb_list(segs, next); + __kfree_skb(segs); segs = next; } }