Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp1626435rwb; Sat, 3 Sep 2022 21:43:03 -0700 (PDT) X-Google-Smtp-Source: AA6agR4fBeJiJ44LwmGTbPGEEDGxIsmmkLbJE26DhvzyRM5NYTcW0sJ7LTDxgAT7ayIBdacHs1Jn X-Received: by 2002:a17:902:ea0c:b0:176:75a2:625b with SMTP id s12-20020a170902ea0c00b0017675a2625bmr7595726plg.150.1662266583026; Sat, 03 Sep 2022 21:43:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662266583; cv=none; d=google.com; s=arc-20160816; b=jSjKGvtP8+0EdmaL8TjbUyXn2txpspfyePJy8wcX1zDFX9cR/3rTjJgPF6cz/OkzLq DRVTZapnUa6SvC+9htltlGkqtiRCNDijbsrVSbNcLRNOwdtf9BwJ9qiya68x1IDiNohg I0x1HV0r90ImLwsaTvgRHNckIw9m0XPvizr938yYdQ+dlXmQjHGSzuk0052ZAEBmWNuY BG3ND/v3zxRMW94Nyf7m6xFUVRtmVaU6AIQKzj0IbGbFUgHKrgSg/0/BSP6VUKofTMMm P/ssh1KOgNEHduRPfrDZ3MAvgiqN/ir/MHIpSQ4DldkUfSgclufIaRXqfCg6W2Mp0/1G 7nSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rwZfnPErYVdrHZlGao6PR4yNldq77TfSQMeE7mXUsqE=; b=gqBwwz/7FornNsWoeTx84D8mTAnVAdwxue9H05FEz/3Iib6Y9WCWfnk7+BHkfrmfzS q9pjDgUkiJ5N8XOEVwQ5PjQiDlNTcJfV24q4wkd/qPtCzFjna9fiHRMqC0516SCe+T4p yRVQn7vFntluAcf0Eb0SVmUQ6jlEzU1AWxmFWwELy66HESSyVv02Mf77p+fxfbRYA2lB CNCCcHiGq2GuneNd/BfsZX7TidhFQUcXe+5GJFBs+Hsbho3Q6YBlbGMFNH4TJ7A74s9S ppVAFc4Ob34VM4YqnOAac1p7MfK/KEi7vnsuvpSV0n/1zdCPV32kguftRZ/RabzO1GeD LvZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IESSFQr6; 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 z7-20020a63c047000000b00429e6ef0e88si6822583pgi.232.2022.09.03.21.42.52; Sat, 03 Sep 2022 21:43:03 -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=IESSFQr6; 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 S233099AbiIDEed (ORCPT + 99 others); Sun, 4 Sep 2022 00:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiIDEeb (ORCPT ); Sun, 4 Sep 2022 00:34:31 -0400 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 C3B0D38AA; Sat, 3 Sep 2022 21:34:29 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id l65so5689238pfl.8; Sat, 03 Sep 2022 21:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=rwZfnPErYVdrHZlGao6PR4yNldq77TfSQMeE7mXUsqE=; b=IESSFQr6sBOdPgDU0pkieqe5dkTbyrCb2vwGezLC5PA9WwF2V7fL102dSFGaE1Ocna ymw1NWXD1AAFVH5JVRSx6Zcyk/603+O9c/SDOAuHFE41Ax56C6Px32Iu7tJkfLRgWKjY tSDK8gytZudktmDSfCjSinfoYvVdsM6pB4fduOeGLEFhcE7Gb5kdP+zauty9jGhKKjtO ER4h1XNzhcICD4h8cvbz+zaw1n1pGnCTY/DIXB7QkNSHE/i7uyXrzeQr5HTvmQZvmxFi grP4cdmGjgNoiwPj1wBCy5cZQZ5cGNqMe+66iStSMFviWPGDh9K+LQypBze25dW2cT1B eiqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=rwZfnPErYVdrHZlGao6PR4yNldq77TfSQMeE7mXUsqE=; b=x9GubfAPXU7cmOi8co0ymKkumxSV2807PfDorjQRCLircAjbuRnwQKq4Z32SIiIY1c a7UfnuivM/mlt1kk0jMqSZFffq0+ms/rNNBgFuKTjyba5ATXh0Syg90S83Dd3LgbovhN aJY7OPvcuiGlbT/9f+fCQLGd+WyaWKDJAN7hH88kmx88jt3Zp9kCkee4yk8ZhT4THHRd Q2G2D4gG+gK6wSZDcugBD5ZWSnOtrlRRS8qfJFmZtj6JSzmHGN5/tuyZnHdZUgi6NLAs IDrUzRL/LDasyd4SlL8YIxgt+qjn9EEY/aqmI6bClJl6sgXEZLxL0xsQm8s5gc0cHTUm jpTA== X-Gm-Message-State: ACgBeo1ufw1UGJYI7j/dJqpP0amnlnDczECKCvQCpZKiRwv50Ztu9BbS wODM0lnnEREIw/lZMpLpUD6/0KdCXtssw48hTVg= X-Received: by 2002:a63:83c7:0:b0:42b:b618:31b4 with SMTP id h190-20020a6383c7000000b0042bb61831b4mr30080252pge.607.1662266069201; Sat, 03 Sep 2022 21:34:29 -0700 (PDT) MIME-Version: 1.0 References: <20220902141715.1038615-1-imagedong@tencent.com> In-Reply-To: From: Menglong Dong Date: Sun, 4 Sep 2022 12:34:18 +0800 Message-ID: Subject: Re: [PATCH net-next v2] net: skb: export skb drop reaons to user by TRACE_DEFINE_ENUM To: Eric Dumazet , Steven Rostedt Cc: Jakub Kicinski , David Miller , Paolo Abeni , Ingo Molnar , Menglong Dong , David Ahern , Hao Peng , Dongli Zhang , robh@kernel.org, Pavel Begunkov , Luiz Augusto von Dentz , Vasily Averin , LKML , netdev Content-Type: text/plain; charset="UTF-8" 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 On Fri, Sep 2, 2022 at 11:43 PM Eric Dumazet wrote: > > On Fri, Sep 2, 2022 at 7:18 AM wrote: > > > > 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. As the enum 'skb_drop_reason' is not exported to > > user space through TRACE_DEFINE_ENUM(), perf can't get the drop reason > > string from the 'reason' field, which is a number. > > > > Therefore, we introduce the macro DEFINE_DROP_REASON(), which is used > > to define the trace enum by TRACE_DEFINE_ENUM(). With the help of > > DEFINE_DROP_REASON(), now we can remove the auto-generate that we > > introduced in the commit ec43908dd556 > > ("net: skb: use auto-generation to convert skb drop reason to string"), > > and define the string array 'drop_reasons'. > > > > Hmmmm...now we come back to the situation that have to maintain drop > > reasons in both enum skb_drop_reason and DEFINE_DROP_REASON. But they > > are both in dropreason.h, which makes it easier. > > > > After this commit, now the format of kfree_skb is like this: > > > > $ cat /tracing/events/skb/kfree_skb/format > > name: kfree_skb > > ID: 1524 > > format: > > field:unsigned short common_type; offset:0; size:2; signed:0; > > field:unsigned char common_flags; offset:2; size:1; signed:0; > > field:unsigned char common_preempt_count; offset:3; size:1; signed:0; > > field:int common_pid; offset:4; size:4; signed:1; > > > > field:void * skbaddr; offset:8; size:8; signed:0; > > field:void * location; offset:16; size:8; signed:0; > > field:unsigned short protocol; offset:24; size:2; signed:0; > > field:enum skb_drop_reason reason; offset:28; size:4; signed:0; > > > > print fmt: "skbaddr=%p protocol=%u location=%p reason: %s", REC->skbaddr, REC->protocol, REC->location, __print_symbolic(REC->reason, { 1, "NOT_SPECIFIED" }, { 2, "NO_SOCKET" } ...... > > > > Reported-by: Eric Dumazet > > Note that I also provided the sha1 of the faulty patch. > > You should add a corresponding Fixes: tag, to help both humans and bots. > Okay, I'll add the Fixes tag......and the Link tag. > This would also hint that this patch should target net tree, not net-next ? > It seems that the net tree is more suitable. I'll change it. Thanks! > > Signed-off-by: Menglong Dong > > --- > > v2: > > - undef FN/FNe after use it (Jakub Kicinski) > > I would love some feedback from Steven :) Hi, Steven! Do you have any feedback? Yes, I add the TRACE_DEFINE_ENUM() back! (Hmm...I deleted it before, without knowing its function :/ ) Thanks! Menglong Dong