[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7d971eef-72bc-db32-e6a3-26e94b1b4236@rasmusvillemoes.dk>
Date: Wed, 21 Apr 2021 16:50:30 +0200
From: Rasmus Villemoes <linux@...musvillemoes.dk>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: Dan Williams <dan.j.williams@...el.com>,
"fweisbec@...il.com" <fweisbec@...il.com>,
"jeyu@...nel.org" <jeyu@...nel.org>,
"mathieu.desnoyers@...icios.com" <mathieu.desnoyers@...icios.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"mingo@...e.hu" <mingo@...e.hu>,
"chris@...is-wilson.co.uk" <chris@...is-wilson.co.uk>,
"yuanhan.liu@...ux.intel.com" <yuanhan.liu@...ux.intel.com>,
"Grumbach, Emmanuel" <emmanuel.grumbach@...el.com>
Subject: Re: [PATCH][RFC] tracing: Enable tracepoints via module parameters
On 21/04/2021 16.20, Steven Rostedt wrote:
> On Wed, 21 Apr 2021 09:30:01 +0200
> Rasmus Villemoes <linux@...musvillemoes.dk> wrote:
>
>> On 20/04/2021 22.32, Steven Rostedt wrote:
>>> /* vsnprintf() will not append null for zero-length strings */
>>> if (ret == 0)
>>> buf[0] = '\0';
>>
>> Wrong. snprintf(buf, 16, "") will work just fine and cause a '\0' to be
>> written to buf[0]. As will snprintf(buf, 16, "%s", ""), and any other
>> case where there ends up being no characters printed.
>
> I just cut and pasted the bpf_trace_printk() code and modified it for here.
OK, thanks for the pointer, lemme go write a patch to remove that
bogosity before it gets cargo-culted further.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/bpf_trace.c#n404
>
>>>
>>> #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.
>>
>> dynamic_debug has been implemented in terms of static_keys for a long
>> time. And that's a per-dev_dbg invocation static key. IIUC, the above
>> would cause every single dev_dbg in the kernel to pass through the "grab
>> a raw spin lock and do the snprintf" thing even when one is just
>> interested in the dev_dbgs inside a single driver or function.
>
> If you want to make it per device, I'm sure three's a way. Or allocate a
> per-cpu buffer for the sprintf storage, and then you only need to disable
> interrupts. And if you make the storage 4 levels deep per CPU (like
> trace_printk does), then you only need to disable preemption and not even
> interrupts.
>
> The above wasn't a patch submission. It was a proof of concept. Everything
> you brought up can be trivially dealt with.
I don't "want" anything. I just fail to see what advantage that proof of
concept would bring over the current dev_dbg implementation.
Rasmus
Powered by blists - more mailing lists