Received: by 2002:a05:6504:1d0:b0:1de:de76:8684 with SMTP id e16csp878048ltn; Fri, 2 Sep 2022 09:13:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Y1EJIs6U9FIBduzi6JhUNeJHPg6MZsOuiMykgXoC4UszWEP74dZXDJ19T9tuGf5Pg272V X-Received: by 2002:a17:902:ab59:b0:175:2cb4:48b4 with SMTP id ij25-20020a170902ab5900b001752cb448b4mr16844103plb.73.1662135217494; Fri, 02 Sep 2022 09:13:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662135217; cv=none; d=google.com; s=arc-20160816; b=XcUrUWdXYvpgwIOlGo9WcxILP5OnlZ8H5nCWyOooco2/6HpikrXICmPSA3AFd6sAfl mw3E8dlyuugXXcxq4zJwrj9rPvp12QG41XNabWnjiGnp7TfOXSIgpxZw792Q2Lq4K3Sm lsP4lxIg0MmguW9lNF9lxsyQ0ddwuHNPD5gVNCPP036Og6J7a3NHxqEB2ahVNmmCJzH5 F9Snmje9zInjLEFh9m0M9fKCLKw12t8TGXDse7XANEhUb8nvUAp74UlNF4Yu+hlGMphy Q63OZ8/d87ze3oP4BU3AF0zqQsZA5yeTOSPM7DOMxh1e1/RpsdY+DYCUzkwu7zyinBWY dQ9Q== 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=muJcJek/qJin6SE1cDfVZCiOzJRrsAG0GRyTkhFku90=; b=WHxZ7nSVbFk44+rjb48bBQv25MQEJTfUrn3VR7Liq82cRY7qFEGUIBK7FrSLlQQk0y mVg7NG5XR1d1PHHjyeqUEI58m41cJ3hGVO4Yn3B3Iv+F+OnlALU4sWBFiGGU1buvdl1b evR/T4023MmjebsEw6J3Ov5gxJyPcvKJ2vtLO2F7pC1F/6ssEQ6U4fl4QTJmwkbj04yV 2MI3Ve68Crq7gXL3jS0zM9snCNetK+gjtND8zqG3jmncb5bd4xBqUuPJGUDbyUvl5Zkv OFsnsvaSee5yAjq158QSAH6f2ljbdZfhdpIOz2HKY0O5WnE7tShXnMGTqysP6L/sreMV rsQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=dMZrKujo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d13-20020a056a00198d00b00536c1bda94fsi2454563pfl.281.2022.09.02.09.13.20; Fri, 02 Sep 2022 09:13:37 -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=@google.com header.s=20210112 header.b=dMZrKujo; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235835AbiIBPwY (ORCPT + 99 others); Fri, 2 Sep 2022 11:52:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237318AbiIBPwD (ORCPT ); Fri, 2 Sep 2022 11:52:03 -0400 Received: from mail-yb1-xb33.google.com (mail-yb1-xb33.google.com [IPv6:2607:f8b0:4864:20::b33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D1BB51434 for ; Fri, 2 Sep 2022 08:43:19 -0700 (PDT) Received: by mail-yb1-xb33.google.com with SMTP id c9so3676423ybf.5 for ; Fri, 02 Sep 2022 08:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=muJcJek/qJin6SE1cDfVZCiOzJRrsAG0GRyTkhFku90=; b=dMZrKujoZPQ3uZWpAJdfytQXosFVeKJQV3yxnJq9YF1KnKWaIgDDM7an4Wk92yRYCH qxjU6Ah3m6yKtfX+NY8WKqj501LGdxTBUTMVhINfxjxLRkMid+EC/Z835bL4gp8NDx8s gxQJJDdkv21Bu1/kvOsSxlCWHGt8+bSm2WbW7E3+la+l63WcSUotJNyqJbqb1U8aguRu Aa43HyjPqwvA7LXIsbQabqLNX+1h6FTGIoQu8p4MQXte8nZxSkZwc6zvpE4bLQaHqRHZ 0su3aIXcHh/sWcncF3xwBxk3SpXtZ2NVRTpSbgXNcITC2HMxXZ3fCJRKSroWFXsNp58G TzEg== 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=muJcJek/qJin6SE1cDfVZCiOzJRrsAG0GRyTkhFku90=; b=jYDdXRTGTMthy5Ed2guL4jQKPOhvdhT3A4b6k+X/+4x+AEs7i0d1Q2vT6oxepTKKQv eoqMwuFipkAhsr2ptbTaAhwHdOFaCxzVEa7Xe/OoWARQxNHcO4S+rFZaE7PuHk3Ly91E dUVA7RDALicN9FKgd1Ed99yKpnDGG1HjKwyvjU3MaS0H9yQTi2BL6+ofZ6vKF4cuQ8kB wW8poODpX+N+cU4j7sZ9TMi33ItKzXuuse+rxKrMXJHQBfhA/qTLejSu8LDAbUDLkaut Bem7l5jW7XgItuJ7F0bml+SrIlEcY0BOyEea4Bbfp0SP/C2xgyVAoJLTPgOBk6mTCwHa qS+w== X-Gm-Message-State: ACgBeo1QcT3EiSO4TmHdqqm7o6WVGA/ch3ZhfIWFZkaZdysL4gE5DcwG L9fxutXy4H06MfmOOFsSUJLBy4gHJrUiiZH+IrRLyw== X-Received: by 2002:a25:415:0:b0:696:814:7c77 with SMTP id 21-20020a250415000000b0069608147c77mr23564025ybe.36.1662133398148; Fri, 02 Sep 2022 08:43:18 -0700 (PDT) MIME-Version: 1.0 References: <20220902141715.1038615-1-imagedong@tencent.com> In-Reply-To: <20220902141715.1038615-1-imagedong@tencent.com> From: Eric Dumazet Date: Fri, 2 Sep 2022 08:43:07 -0700 Message-ID: Subject: Re: [PATCH net-next v2] net: skb: export skb drop reaons to user by TRACE_DEFINE_ENUM To: Menglong Dong Cc: Jakub Kicinski , David Miller , Paolo Abeni , Steven Rostedt , 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=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 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. This would also hint that this patch should target net tree, not net-next ? > Signed-off-by: Menglong Dong > --- > v2: > - undef FN/FNe after use it (Jakub Kicinski) I would love some feedback from Steven :)