Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp95694pxy; Tue, 20 Apr 2021 13:34:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1q5HS5JeTDGI2Wn2S1Oj01bmHgszGsN+oYp+gt93XCLTQE0oWibeUTFDGjgvm3vhteEll X-Received: by 2002:a17:90a:fe11:: with SMTP id ck17mr6880402pjb.49.1618950846277; Tue, 20 Apr 2021 13:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618950846; cv=none; d=google.com; s=arc-20160816; b=G138yGtS3ZslVy+p+s32l9GWev/56REvFKtnrOGyxelNSPXx6Tt1c9giHjrDv6l/p+ +vgPqsU0CZPKeYQqvyf6uki5TbsUaW6s58hJYvCwiGBOREb1Ih60zHQJVBWegS1rMic2 3tpiyr/pKTecz26z0jvvNoHvlUkiy3k0A5GCXioTU0dWUGde4pIDfA/3TZy0b1YOu0TV Hm8n0FsGeQwZ81G0ulhApl06isACCZcpSwlSUyaauUuJvCJ8BTTvCc12eV4oC0UCt9q+ 1YPs4XGf1SxvOMZkKn7WRcDt5wzUNeMpf1Iw9xI4e4mU/42zRIIWb7YsOaUBe9kZ66UQ GO+g== 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=M0YdmFGfzIAD87+ErdqUP2ywvDnxJSqkSUkb/E6Y8MI=; b=hQRJjYalOB1cv0HdbTOPdLGCX/SxV4pWFL/sLPVqdFvnQ/xuohGSe5U3opQ5L7Gf2+ GO8hdxGbNuXTFsFaX6aNpjkUjlsbJh9qBvMESrhKZnD4PiuS74V5X3FPlq/MiewGPMrL jatwJvdFY/wQv2uXe4QTG3aaCxJ3/BumS3BFJE4aXIRD6mDoLstFJwPsI1EACBcmNTif yFDXNYVsC1BTaUIi1sAtpMUgjRQur/1I8H9+aF5Z5Zedv7BT6UQhqvClij4jelfYeCrH Rt0us+NRF8h07FEgc9Jr1gq02r7YN3g0I3wrimtP+NWqWWMXi4UlFtJW5y5nfzVEmN5s gqbA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v17si21020934pfm.62.2021.04.20.13.33.53; Tue, 20 Apr 2021 13:34:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233961AbhDTUdU (ORCPT + 99 others); Tue, 20 Apr 2021 16:33:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:54286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbhDTUdT (ORCPT ); Tue, 20 Apr 2021 16:33:19 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8C01F613C8; Tue, 20 Apr 2021 20:32:45 +0000 (UTC) Date: Tue, 20 Apr 2021 16:32:43 -0400 From: Steven Rostedt To: Dan Williams Cc: "fweisbec@gmail.com" , "jeyu@kernel.org" , "mathieu.desnoyers@efficios.com" , "linux-kernel@vger.kernel.org" , "mingo@elte.hu" , "chris@chris-wilson.co.uk" , "yuanhan.liu@linux.intel.com" , "Grumbach, Emmanuel" Subject: Re: [PATCH][RFC] tracing: Enable tracepoints via module parameters Message-ID: <20210420163243.45293c9a@gandalf.local.home> In-Reply-To: References: <1299622684.20306.77.camel@gandalf.stny.rr.com> <877hc64klm.fsf@rustcorp.com.au> <20130813111442.632f3421@gandalf.local.home> <87siybk8yl.fsf@rustcorp.com.au> <20130814233228.778f25d0@gandalf.local.home> <77a6e40b57df092d1bd8967305906a210f286111.camel@intel.com> <20210419181111.5eb582e8@gandalf.local.home> <20210420085532.4062b15e@gandalf.local.home> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 20 Apr 2021 12:54:39 -0700 Dan Williams wrote: > On Tue, Apr 20, 2021 at 5:55 AM Steven Rostedt wrote: > > > > > > The dev_dbg() filter language is attractive, it's too bad > > > > Not sure what you mean by that. What filter language. Tracepoints do have a > > pretty good filtering too. > > I'm trying to replicate dev_dbg() usability with tracing. So, when > people say "don't use dev_dbg() for that" that tracing can reliably > replace everything that dev_dbg() was offering. What I think that > looks like is the ability to turn on function tracing by a function > name glob in addition to any tracepoints in those same functions all > from the kernel boot command line, or a module parameter. You can enable functions on the kernel command line in globs (and trace events as well). And if the kernel command line doesn't work properly (it's not as tested as the run time side is), it should be trivial to fix it. > > > > trace_printk() has such a high runtime cost as combining dynamic-debug > > > and tracing would seem to be a panacea. > > > > trace_printk() has a high runtime cost? Besides that it's not allowed on > > production code (see nasty banner), it is made to be extremely fast. > > Although, it does do sprintf() work. > > I was referring to the banner. dev_dbg() does not have that production > code restriction. You can have a tracepoint like trace_printk that doesn't give a banner. Basically, the reason trace_printk() has that restriction is because you can't filter it like you can trace events. It's similar to a printk(). If I had allowed trace_printk() in the kernel, it would be all over the place, and it would just add a bunch of noise to the trace output, because its either on or off. And if you have trace_printk() and so would all other systems, and then you would deal with trace_printk()s from everyone which could drown out the ones you want. Hence, I added that banner to keep that from happening. trace_printk() will even drown out events. (I hate it when I leave one in my debug kernel, and it adds a bunch of noise against what I'm trying to debug with events!). But you can add your own trace point, and even make it generic. That's what bpf did for their bpf_trace_printk. You could convert dev_dbg() into a tracepoint! static __printf(2, 3) int __dev_dbg(const struct device *dev, char *fmt, ...) { static char buf[DEV_DEBUG_PRINTK_SIZE]; unsigned long flags; va_list ap; int ret; raw_spin_lock_irqsave(&dev_dbg_printk_lock, flags); va_start(ap, fmt); ret = vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); /* vsnprintf() will not append null for zero-length strings */ if (ret == 0) buf[0] = '\0'; trace_dev_dbg_printk(dev, buf); raw_spin_unlock_irqrestore(&dev_dbg_printk_lock, flags); return ret; } #define dev_dbg(dev, fmt, ...) \ do { \ if (trace_dev_dbg_printk_enabled()) \ __dev_dbg(dev, fmt, ##__VA_ARGS__); \ } while (0) Note, the "trace_dev_dbg_printk_enabled()" is a static branch, which means it is a nop when the dev_dbg_printk tracepoint is not enabled, and is a jmp to the __dev_dbg() logic when it is enabled. It's not a conditional branch. And have: TRACE_EVENT(dev_dbg_printk, TP_PROTO(const struct device *dev, const char *dbg_str), TP_ARGS(dev, dbg_str), TP_STRUCT__entry( __field(const struct device *dev) __string(dev_name, dev_name(dev)) __string(dbg_str, dbg_str) ), TP_fast_assign( __entry->dev = dev; __assign_str(dev_name, dev_name(dev)) __assign_str(dbg_str, dbg_str); ), TP_printk("%p dev=%s %s", __entry->dev, __get_string(dev_name), __get_str(dbg_str)) ); And then you could even filter on the device name, or even parts of the string, as you can filter events, and even have them have glob matches. > > > Would adding automatic module parameters be an issue? That is, you can add > > in the insmod command line a parameter that will enable tracepoints. We > > could have a way to even see them from the modinfo. I think I had that > > working once, and it wasn't really that hard to do. > > Yeah, that's what you seemed to have working at the beginning of this thread: > > https://lore.kernel.org/lkml/1299622684.20306.77.camel@gandalf.stny.rr.com/ Yeah, and I should brush that off and resubmit ;-) -- Steve