Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp262281rwe; Wed, 24 Aug 2022 22:46:55 -0700 (PDT) X-Google-Smtp-Source: AA6agR7LFTOyDtAJCau1IkOPIdXidhG29ND6Qi+Ms0TdnMsG5+qJheq/Hn4eMyVwKWdSN/MCLRXw X-Received: by 2002:a17:907:271b:b0:730:aa8e:74eb with SMTP id w27-20020a170907271b00b00730aa8e74ebmr1383899ejk.478.1661406415014; Wed, 24 Aug 2022 22:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661406415; cv=none; d=google.com; s=arc-20160816; b=KfT35BhmPz2xbsmRfHWSNlRoHic/JY8+ARXoVEx08J0z4uIM2vG7Xx8kbTg+0DpW4l 6ke0yoJQNBRHlK7K9aPQPqzSOPkI9x3eSDfefUDi+Km26KNkTX94n9BVEajtT8irxVcL Ei0GPi2o+D/6GvaHrBKKuGJoQI9j+I0AZ9F4LYsSU2Ktk8sbkzwMbtuKe51AapZog1Bb 40Im7EhRQIP27a8ylORLBtIY3iM/HyDsHOPN39O5BkTJsNzuwfVLhjvp2Ew/4u02PygA M0RwWVBhxRalYLGBV3EX7o2M9Cko773BeSm5ut9xNom56jkrj6HU1lB0HF10waKZCEod nQlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=EJr+R7ARbeiugKJJbNfdiybcH6LH0V+lvHZhpBPikbU=; b=LU3RlzMbPUPIM9Ri5OXhOACQot7Zx0FV1Ez78Pj+6UhZ5UQcV80JlBrewBrIzgvyJY FacnbYPKtorQIOXMiJvX1Y7Pa3WnfJoB5qqNsSsDiLfjmjU3ZS+Tp6FqsdqslKeBl0i1 GpiB3V49KnyW+q8820lbNcN/z4Az8U0xNOBdz2BtDNjm8053KXrJgqJu4lF9/tuAgU/G kKtVx6wEfnyicZwn8RwRtnngkCz0Liu/mAKnAMeRVrHpltksPG3h6S9lpWbNxi7CFpFS HxhwVyOsECmU9MGbPOHJZnT6sfvJMGXqQHd30YKXfioK7yML6RagJuBbEDoMoLfwC3f/ 6WuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F4ZoMmuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz9-20020a1709077d8900b0073d798629c1si3539170ejc.754.2022.08.24.22.46.29; Wed, 24 Aug 2022 22:46:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F4ZoMmuX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233969AbiHYFhr (ORCPT + 99 others); Thu, 25 Aug 2022 01:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbiHYFhp (ORCPT ); Thu, 25 Aug 2022 01:37:45 -0400 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 BFB4790C67 for ; Wed, 24 Aug 2022 22:37:44 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id 2so17633164pll.0 for ; Wed, 24 Aug 2022 22:37:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=EJr+R7ARbeiugKJJbNfdiybcH6LH0V+lvHZhpBPikbU=; b=F4ZoMmuXAUNMQ6Dy6YOgASr/O8yTAgsXy1s9puhvSlZwA4cEt1dgLOs7+QuyNmJY3Y U5z7ECV2ka2nnSGdyNQvIJq/fWAy5UuIFiSSThrwiP7ElCljvgFLe7ro7MOzJ914/K6L e8jtIRp8uF7e1YHp1Sn6nYJ9ruIZbXLfs8J5kOmxwyOgZxJ3cGTkuRUhNC4CE0845XMZ f7p6w/easm2Sl9b2HrTh37PpjIRkYRZ+3hZJzfNv9sJ/C0+tuVaQ6dfcV/m8AWLXNyWS PdyjKFcMd6LqvWBGMnCxAeJZJK08PXq60UFauGKH7UhAbiNlsB7DnYTNI5RmOfyu2FBJ h0wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=EJr+R7ARbeiugKJJbNfdiybcH6LH0V+lvHZhpBPikbU=; b=KRJ4wWnW351e5xN9ZOXmOprpP6h4fkdKKdcTqdr7y5y+W66F+GrI15lbTEmz6jsydQ 3vi8Ip86G7q3b8SGZAwR62NHA9U2qlIatZ7xRBMdEV9D+dcIB7unzTUrhLUQM/7ShE2A r1bTi36pYFE2Zwt0JI9expfo+j7j9HxBL75J0Tt00W+rwf+NiNA/zHfhqaK54QIR4NdM DXRIK/HLOGR72G+hcs13oLU6L7eFNjp2rqhg+G7/XVStrD8f6hyxHyffgPtOstuW/d6D iqgzo/WUFs7LUUnaThjgvDD3scq0gGuLqd1ljIZ1UIQ9twGxUPf4WHTtJIFU7qpsY0dI xujg== X-Gm-Message-State: ACgBeo04QLkluIK36Z4HnJ3bXFXqjLHrnoe0TH0ZcwUkyhb5xtej6rkQ oszi1y5MFgj+hyz0U5sFHS4= X-Received: by 2002:a17:903:22c4:b0:16f:a93:9197 with SMTP id y4-20020a17090322c400b0016f0a939197mr2402533plg.134.1661405864316; Wed, 24 Aug 2022 22:37:44 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.11]) by smtp.gmail.com with ESMTPSA id b18-20020a62a112000000b005362314bf80sm11433082pff.67.2022.08.24.22.37.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Aug 2022 22:37:44 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: edumazet@google.com Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net, imagedong@tencent.com, dsahern@kernel.org, flyingpeng@tencent.com, dongli.zhang@oracle.com, linux-kernel@vger.kernel.org Subject: [PATCH net-next] net: skb: fix kfree_skb event output error in perf Date: Thu, 25 Aug 2022 13:37:38 +0800 Message-Id: <20220825053738.476903-1-imagedong@tencent.com> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Menglong Dong As Eric reported, the 'reason' field is not presented when trace the kfree_skb event by perf: $ perf record -e skb:kfree_skb -a sleep 10 $ perf script ip_defrag 14605 [021] 221.614303: skb:kfree_skb: skbaddr=0xffff9d2851242700 protocol=34525 location=0xffffffffa39346b1 reason: The cause seems to be passing kernel address directly to TP_printk(), which is not right. Therefore, fix this by adding a '__string' field to the TP_STRUCT of kfree_skb, which is 'reason_str', and passing it to TP_printk(). (Not sure if we should still keep the 'reason' field in TP_STRUCT__entry) Reported-by: Eric Dumazet Signed-off-by: Menglong Dong --- include/trace/events/skb.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h index 45264e4bb254..7235554141c3 100644 --- a/include/trace/events/skb.h +++ b/include/trace/events/skb.h @@ -24,6 +24,7 @@ TRACE_EVENT(kfree_skb, __field(void *, location) __field(unsigned short, protocol) __field(enum skb_drop_reason, reason) + __string(reason_str, drop_reasons[reason]) ), TP_fast_assign( @@ -31,11 +32,12 @@ TRACE_EVENT(kfree_skb, __entry->location = location; __entry->protocol = ntohs(skb->protocol); __entry->reason = reason; + __assign_str(reason_str, drop_reasons[reason]); ), TP_printk("skbaddr=%p protocol=%u location=%p reason: %s", __entry->skbaddr, __entry->protocol, __entry->location, - drop_reasons[__entry->reason]) + __get_str(reason_str)) ); TRACE_EVENT(consume_skb, -- 2.37.2