public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizf@cn.fujitsu.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tracing/profile: Fix profile_disable vs module_unload
Date: Tue, 25 Aug 2009 13:22:13 +0800	[thread overview]
Message-ID: <4A937505.5000209@cn.fujitsu.com> (raw)
In-Reply-To: <1251106058.7538.149.camel@twins>

>>>>>> If the correspoding module is unloaded before ftrace_profile_disable()
>>>>>> is called, event->profile_disable() won't be called, which can
>>>>>> cause oops:
>>>>>>
>>>>>>   # insmod trace-events-sample.ko
>>>>>>   # perf record -f -a -e sample:foo_bar sleep 3 &
>>>>>>   # sleep 1
>>>>>>   # rmmod trace_events_sample
>>>>>>   # insmod trace-events-sample.ko
>>>>>>   OOPS!
>>>>>>
>>>>>> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
>>>>>
>>>>> Hrmm, feel fragile, why don't we check if all a modules tracepoints are
>>>>> unused on unload?
>>>>>
>>>> I don't think it's fragile. We are profiling via a module's
>>>> tracepoint, so we should pin the module, via module_get().
>>>> If event->profile_enable() has been calld, we should make
>>>> sure it's profile_disable() will be called.
>>> What I call fragile is that everyone registering a tracepoint 
>>> callback will now apparently need to worry about modules, _that_ 
>>> is fragile.
>>>
>>> Either make module unload look at tracepoint users, or place the 
>>> try_get_module() in the registration hooks so that regular users 
>>> don't need to worry about it.
>> The bug found by Li needs to be fixed obviously.
>>
>> I tend to agree with you that this does not appear to be the best 
>> place to do it: so you suggest to implicitly increase the module 
>> refcount on callback registr instead? (and releasing it when 
>> unregistering)
>>
>> Same end result, slightly cleaner place to bump the refcount.
> 
> Yes, because the user of tracepoints should never need to care about
> modules.
> 

I'm afraid it is not feasible to bump module refcnt implicitly
in tracepoint_probe_register().

If a tracepoint is registered in module_init, and unregistered
in module_exit (see sample/tracepoints), the module is unloadable:

 insmod
 ->call mod->init()
   ->trace_reg_foo()
     ->module_get()

 rmmod
 ->check mod refcnt
 ->call mod->exit()
   ->trace_unreg_foo()
     ->module_put()

  parent reply	other threads:[~2009-08-25  5:23 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-24  4:19 [PATCH] tracing/profile: Fix profile_disable vs module_unload Li Zefan
2009-08-24  6:01 ` Peter Zijlstra
2009-08-24  6:22   ` Li Zefan
2009-08-24  6:56     ` Peter Zijlstra
2009-08-24  9:24       ` Ingo Molnar
2009-08-24  9:27         ` Peter Zijlstra
2009-08-24 16:13           ` Steven Rostedt
2009-08-25  5:22           ` Li Zefan [this message]
2009-08-25  6:21             ` Peter Zijlstra
2009-08-25  6:33               ` Li Zefan
2009-08-25  6:40                 ` Peter Zijlstra
2009-08-25  9:05                   ` Ingo Molnar
2009-08-25  9:12                     ` Peter Zijlstra
2009-08-25 10:22                       ` Ingo Molnar
2009-08-25 10:32                         ` Peter Zijlstra
2009-08-25 10:39                           ` Ingo Molnar
2009-08-25 10:47                             ` Peter Zijlstra
2009-08-25 14:52                               ` Peter Zijlstra
2009-08-26  6:18                                 ` Li Zefan
2009-08-26  6:46                                   ` Peter Zijlstra
2009-08-26  6:52                                     ` Peter Zijlstra
2009-08-26  7:01                                     ` Peter Zijlstra
2009-08-26  7:10                                       ` Li Zefan
2009-08-26  7:26                                         ` Peter Zijlstra
2009-08-26  7:31                                           ` Li Zefan
2009-08-26  7:39                                             ` Peter Zijlstra
2009-08-26  7:44                                               ` Li Zefan
2009-08-26 14:37                                         ` Steven Rostedt
2009-08-26 16:46                                           ` Mathieu Desnoyers
2009-08-26 17:48                                             ` Steven Rostedt
2009-08-26 18:01                                               ` Mathieu Desnoyers
2009-08-26 18:17                                                 ` Mathieu Desnoyers
2009-08-26 19:48                                                   ` Steven Rostedt
2009-08-26 19:53                                                     ` Mathieu Desnoyers
2009-08-26 21:21                                                       ` Steven Rostedt
2009-08-26 22:29                                                         ` Mathieu Desnoyers
2009-08-27  1:53                                                     ` Li Zefan
2009-08-27  2:13                                                       ` Steven Rostedt
2009-08-27 14:39                                                         ` Mathieu Desnoyers
2009-08-27 14:56                                                           ` Steven Rostedt
2009-08-27 15:11                                                             ` Mathieu Desnoyers
2009-08-27 15:51                                                               ` Steven Rostedt
2009-08-27 15:59                                                                 ` Mathieu Desnoyers
2009-08-27 16:03                                                                   ` Steven Rostedt
2009-08-27  6:25                                                     ` Peter Zijlstra
2009-08-27 15:57                                                       ` Steven Rostedt
2009-08-27 16:04                                                         ` Peter Zijlstra
2009-08-27 16:18                                                           ` Steven Rostedt
2009-08-27  1:01                                                 ` Li Zefan
2009-08-26 19:14                                             ` Peter Zijlstra
2009-08-26 19:44                                               ` Mathieu Desnoyers
2009-09-13 15:02 ` [tip:tracing/core] tracing/profile: fix " tip-bot for Li Zefan

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=4A937505.5000209@cn.fujitsu.com \
    --to=lizf@cn.fujitsu.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.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