From: Li Zefan <lizf@cn.fujitsu.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>,
LKML <linux-kernel@vger.kernel.org>, Ingo Molnar <mingo@elte.hu>,
Frederic Weisbecker <fweisbec@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH v2][GIT PULL] tracing: Prevent unloadable modules from using trace_bprintk()
Date: Mon, 25 Oct 2010 09:32:21 +0800 [thread overview]
Message-ID: <4CC4DE25.1020408@cn.fujitsu.com> (raw)
In-Reply-To: <1287755374.16971.629.camel@gandalf.stny.rr.com>
Steven Rostedt wrote:
> On Fri, 2010-10-22 at 13:30 +0800, Li Zefan wrote:
>
>> In fact tracepoint is free from this bug, because we'll empty the ring
>> buffer if the unloading module has tracepoints in it.
>
> Hehe, and I should know, I wrote that code :-)
>
I reported that bug. ;)
>
>> So for trace_bprintk, why can't we do the same thing? If a module has
>> trace_bprintk calls in it, just empty the ring buffer when unloading
>> module.
>>
>> And that's as simple as something like this:
>>
>> diff --git a/kernel/trace/trace_printk.c b/kernel/trace/trace_printk.c
>> index 2547d88..103987f 100644
>> --- a/kernel/trace/trace_printk.c
>> +++ b/kernel/trace/trace_printk.c
>> @@ -80,6 +80,13 @@ static int module_trace_bprintk_format_notify(struct notifier_block *self,
>>
>> if (val == MODULE_STATE_COMING)
>> hold_module_trace_bprintk_format(start, end);
>> + else if (val == MODULE_STATE_GOING) {
>> + /*
>> + * It is safest to reset the ring buffer if the
>> + * module being unloaded uses trace_bprintk.
>> + */
>> + tracing_reset_current_online_cpus();
>> + }
>> }
>> return 0;
>> }
>
> This could definitely work.
>
> But this prevents developers using trace_printk() in their exit() code.
> We should probably add a trace_mod_printk() or something that just
> forces the slow version that does not require flushing the ring buffer
> on removal. As long as there's not a single trace_printk() in the
> module, and it only uses the alternative, then this should work.
>
Agreed. Add this trace_mod_printk() and add some comments to
explain why and when use it.
next prev parent reply other threads:[~2010-10-25 1:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-21 13:45 [PATCH v2][GIT PULL] tracing: Prevent unloadable modules from using trace_bprintk() Steven Rostedt
2010-10-21 21:35 ` Rusty Russell
2010-10-21 22:34 ` Steven Rostedt
2010-10-22 3:43 ` Rusty Russell
2010-10-22 3:58 ` Steven Rostedt
2010-10-22 4:34 ` Rusty Russell
2010-10-22 5:30 ` Li Zefan
2010-10-22 13:49 ` Steven Rostedt
2010-10-25 1:32 ` Li Zefan [this message]
2010-10-22 8:05 ` Ingo Molnar
2010-10-22 13:50 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CC4DE25.1020408@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox