Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp946050iog; Wed, 29 Jun 2022 13:38:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vty6DK66bKqURT74Z596vMVJDNfHjOLqzUVpAd24Dl1ndMBpEjpuOZ6sWTpFvazwLfItjO X-Received: by 2002:aa7:c2cf:0:b0:435:6576:b7c0 with SMTP id m15-20020aa7c2cf000000b004356576b7c0mr6959215edp.18.1656535108008; Wed, 29 Jun 2022 13:38:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656535108; cv=none; d=google.com; s=arc-20160816; b=YJ6CFY0Zu2kFL8/wQe3mxizVZ2nsTJFGPdMB5/DQZyxOkLe9k7k5Df+QH7+8Mvcwsg 8q2L1yo4/4CSc7KkQ7XryT73tC8Kxju7EepUVDQJpkvmHM1/6pUVx3IetpSR8rD/DzWR 1RRilkA4M/UZwJcbeUIind1jZoYtFePe6eEMKFL2HsuhF5JRoXRw/n/9+GqR/J2wTt/L /n5e30tiEIn93LkMqSi5p+PEh2LzXfhLraVW2EhmNZoDq9q9R2TVw9o+Gqzj79ZZWJhN jQgIyeSrK8XxPb4pox9/iLRAbR4uw+o+g6ECS1A7tPlaB9/zom/SPfX8irgcD/HGNo7n If7A== 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 :references:in-reply-to:message-id:subject:cc:to:from:date; bh=j2ijoiu22cZQmhmVW1/RF7KuTxJ11Ga1/tyXhFcfWNA=; b=u2z32XSN5wnb/ZRFBo/qbMTijNC7f/PLh6CIx4XeDs3A6EcezSQVN1Rytbt4ywPLTC +J43P2zfUL0lvpbYO0aL6/WUIopsb4Mzaq2zM/svZ4OEeB3maCzp/QesP7x5PL7PYhQ8 K63agl7xhYw3zWhYR3tpPy/87s4g3rAcdzRsyFSFZtjiQ50x/mPSn58yCJzE99wQT9zs NR17cQRH9qusjE4f9d+Vlp2puaEY1VxE2A8QVrEWVQAJ2qMFQAzEydQdIz6yZJGUHUUW pvVytTWxtTICV9ZTqZvgPLTsHp1UP6wbQX3DTF+9LqiGWGCIrfy9b9f38Y0xze+Y6fRL q3fw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dz9-20020a0564021d4900b00437a255e8e9si11402198edb.509.2022.06.29.13.38.02; Wed, 29 Jun 2022 13:38:27 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230370AbiF2UbA (ORCPT + 99 others); Wed, 29 Jun 2022 16:31:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229615AbiF2Ua6 (ORCPT ); Wed, 29 Jun 2022 16:30:58 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D61B24F27; Wed, 29 Jun 2022 13:30:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D587E620FD; Wed, 29 Jun 2022 20:30:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10AC1C34114; Wed, 29 Jun 2022 20:30:53 +0000 (UTC) Date: Wed, 29 Jun 2022 16:30:52 -0400 From: Steven Rostedt To: Jim Cromie Cc: jbaron@akamai.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, gregkh@linuxfoundation.org, daniel.vetter@ffwll.ch, seanpaul@chromium.org, robdclark@gmail.com, mathieu.desnoyers@efficios.com, quic_saipraka@quicinc.com, will@kernel.org, catalin.marinas@arm.com, quic_psodagud@quicinc.com, maz@kernel.org, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, mingo@redhat.com Subject: Re: [PATCH v2 26/27] dyndbg: 4 new trace-events: pr_debug, dev_dbg, drm_{,dev}debug Message-ID: <20220629163052.6656c0cb@gandalf.local.home> In-Reply-To: <20220516225640.3102269-27-jim.cromie@gmail.com> References: <20220516225640.3102269-1-jim.cromie@gmail.com> <20220516225640.3102269-27-jim.cromie@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Sorry for the late review. I finally got some time to look at this. On Mon, 16 May 2022 16:56:39 -0600 Jim Cromie wrote: > diff --git a/include/trace/events/drm.h b/include/trace/events/drm.h > new file mode 100644 > index 000000000000..6de80dd68620 > --- /dev/null > +++ b/include/trace/events/drm.h > @@ -0,0 +1,68 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM drm > + > +#if !defined(_TRACE_DRM_H) || defined(TRACE_HEADER_MULTI_READ) > +#define _TRACE_DRM_H > + > +#include > + > +/* drm_debug() was called, pass its args */ > +TRACE_EVENT(drm_debug, > + TP_PROTO(int drm_debug_category, struct va_format *vaf), > + > + TP_ARGS(drm_debug_category, vaf), > + > + TP_STRUCT__entry( > + __field(int, drm_debug_category) > + __dynamic_array(char, msg, 256) > + ), > + > + TP_fast_assign( > + int len; > + > + __entry->drm_debug_category = drm_debug_category; > + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); > + > + len = strlen(__get_str(msg)); > + if (len > 0 && (__get_str(msg)[len - 1] == '\n')) > + len -= 1; > + __get_str(msg)[len] = 0; > + ), > + > + TP_printk("%s", __get_str(msg)) > +); > + > +/* drm_devdbg() was called, pass its args, preserving order */ > +TRACE_EVENT(drm_devdbg, > + TP_PROTO(const struct device *dev, int drm_debug_category, struct va_format *vaf), > + > + TP_ARGS(dev, drm_debug_category, vaf), > + > + TP_STRUCT__entry( > + __field(const struct device*, dev) > + __field(int, drm_debug_category) > + __dynamic_array(char, msg, 256) You do not want to hardcode the 256 here. That will cause 256 bytes to be reserved on the buffer, and you will not get that back. Might as well make it a static array, as you also add 4 bytes to for the offset and size. I think you want (haven't tested it) __dynamic_array(char, msg, get_msg_size(vaf)) Where you have: static unsigned int get_msg_size(struct va_format *vaf) { va_list aq; unsigned int ret; va_copy(aq, vaf->va); ret = vsnprintf(NULL, 0, vaf->fmt, aq); va_end(aq); return min(ret + 1, 256); } What is in the last parameter of __dynamic_array() is used to calculate the size needed to store the dynamic array. Hmm, looking at other users of __dynamic_array(), this appears to be a constant problem. I need to document this better. -- Steve > + ), > + > + TP_fast_assign( > + int len; > + > + __entry->drm_debug_category = drm_debug_category; > + __entry->dev = dev; > + vsnprintf(__get_str(msg), 256, vaf->fmt, *vaf->va); > + > + len = strlen(__get_str(msg)); > + if (len > 0 && (__get_str(msg)[len - 1] == '\n')) > + len -= 1; > + __get_str(msg)[len] = 0; > + ), > + > + TP_printk("cat:%d, %s %s", __entry->drm_debug_category, > + dev_name(__entry->dev), __get_str(msg)) > +); > + > +#endif /* _TRACE_DRM_H */ > +