The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: akpm@linux-foundation.org, Ingo Molnar <mingo@elte.hu>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Hideo AOKI <haoki@redhat.com>,
	Takashi Nishiie <t-nishiie@np.css.fujitsu.com>,
	Alexander Viro <viro@zeniv.linux.org.uk>
Subject: Re: [RFC patch 01/12] Kernel Tracepoints
Date: Tue, 8 Jul 2008 23:03:30 -0400	[thread overview]
Message-ID: <20080709030330.GB4378@Krystal> (raw)
In-Reply-To: <4873D019.4090504@redhat.com>

* Masami Hiramatsu (mhiramat@redhat.com) wrote:
> Hi Mathieu,
> 
> Masami Hiramatsu wrote:
> [...]
> >> +int tracepoint_probe_register(const char *name, void *probe)
> >> +{
> >> +	struct tracepoint_entry *entry;
> >> +	int ret = 0;
> >> +	void *old;
> >> +
> >> +	mutex_lock(&tracepoints_mutex);
> >> +	entry = get_tracepoint(name);
> >> +	if (!entry) {
> >> +		entry = add_tracepoint(name);
> >> +		if (IS_ERR(entry)) {
> >> +			ret = PTR_ERR(entry);
> >> +			goto end;
> >> +		}
> >> +	}
> >> +	/*
> >> +	 * If we detect that a call_rcu is pending for this tracepoint,
> >> +	 * make sure it's executed now.
> >> +	 */
> >> +	if (entry->rcu_pending)
> >> +		rcu_barrier();
> >> +	old = tracepoint_entry_add_probe(entry, probe);
> >> +	if (IS_ERR(old)) {
> >> +		ret = PTR_ERR(old);
> >> +		goto end;
> >> +	}
> >> +	mutex_unlock(&tracepoints_mutex);
> >> +	tracepoint_update_probes();		/* may update entry */
> >> +	mutex_lock(&tracepoints_mutex);
> >> +	entry = get_tracepoint(name);
> >> +	WARN_ON(!entry);
> 
> As I said in another patch, you might have to check
> old != NULL here, because tracepoint_entry_add_probe() will
> return NULL when you add a first probe to the entry.
> 
> >> +	entry->oldptr = old;
> >> +	entry->rcu_pending = 1;
> >> +	/* write rcu_pending before calling the RCU callback */
> >> +	smp_wmb();
> >> +#ifdef CONFIG_PREEMPT_RCU
> >> +	synchronize_sched();	/* Until we have the call_rcu_sched() */
> >> +#endif
> >> +	call_rcu(&entry->rcu, free_old_closure);
> >> +end:
> >> +	mutex_unlock(&tracepoints_mutex);
> >> +	return ret;
> >> +}
> >> +EXPORT_SYMBOL_GPL(tracepoint_probe_register);
> >> +
> >> +/**
> >> + * tracepoint_probe_unregister -  Disconnect a probe from a tracepoint
> >> + * @name: tracepoint name
> >> + * @probe: probe function pointer
> >> + *
> >> + * We do not need to call a synchronize_sched to make sure the probes have
> >> + * finished running before doing a module unload, because the module unload
> >> + * itself uses stop_machine(), which insures that every preempt disabled section
> >> + * have finished.
> >> + */
> >> +int tracepoint_probe_unregister(const char *name, void *probe)
> >> +{
> >> +	struct tracepoint_entry *entry;
> >> +	void *old;
> >> +	int ret = -ENOENT;
> >> +
> >> +	mutex_lock(&tracepoints_mutex);
> >> +	entry = get_tracepoint(name);
> >> +	if (!entry)
> >> +		goto end;
> >> +	if (entry->rcu_pending)
> >> +		rcu_barrier();
> >> +	old = tracepoint_entry_remove_probe(entry, probe);
> >> +	mutex_unlock(&tracepoints_mutex);
> >> +	tracepoint_update_probes();		/* may update entry */
> >> +	mutex_lock(&tracepoints_mutex);
> >> +	entry = get_tracepoint(name);
> >> +	if (!entry)
> >> +		goto end;
> >> +	entry->oldptr = old;
> >> +	entry->rcu_pending = 1;
> >> +	/* write rcu_pending before calling the RCU callback */
> >> +	smp_wmb();
> >> +#ifdef CONFIG_PREEMPT_RCU
> >> +	synchronize_sched();	/* Until we have the call_rcu_sched() */
> >> +#endif
> >> +	call_rcu(&entry->rcu, free_old_closure);
> >> +	remove_tracepoint(name);	/* Ignore busy error message */
> >> +	ret = 0;
> >> +end:
> >> +	mutex_unlock(&tracepoints_mutex);
> >> +	return ret;
> >> +}
> >> +EXPORT_SYMBOL_GPL(tracepoint_probe_unregister);
> >> +
> 
> On the other hand, tracepoint_entry_remove_probe() doesn't return NULL,
> however, I think it might be better to introduce tracepoint_entry_free_old()
> and simplify both of tracepoint_probe_register/unregister.
> 

Yes, the cleanup makes sense and removes an unnecessary call to call_rcu
(which in fact simply kfree a NULL pointer, which is pointless). I'll
integrate this change.

Thanks,

Mathieu

> Thank you,
> -- 
> Masami Hiramatsu
> 
> Software Engineer
> Hitachi Computer Products (America) Inc.
> Software Solutions Division
> 
> e-mail: mhiramat@redhat.com
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68

  reply	other threads:[~2008-07-09  3:03 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-04 23:52 [RFC patch 00/12] Tracepoints v2 Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 01/12] Kernel Tracepoints Mathieu Desnoyers
2008-07-07 16:27   ` Masami Hiramatsu
2008-07-08 20:37     ` Masami Hiramatsu
2008-07-09  3:03       ` Mathieu Desnoyers [this message]
2008-07-04 23:52 ` [RFC patch 02/12] LTTng tracepoint instrumentation fs Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 03/12] LTTng instrumentation ipc Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 04/12] LTTng instrumentation kernel Mathieu Desnoyers
2008-07-07 16:36   ` Masami Hiramatsu
2008-07-04 23:52 ` [RFC patch 05/12] LTTng instrumentation mm Mathieu Desnoyers
2008-07-05  9:42   ` KOSAKI Motohiro
2008-07-07 20:38     ` Mathieu Desnoyers
2008-07-11  8:36       ` KOSAKI Motohiro
2008-07-11 14:17         ` Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 06/12] LTTng instrumentation net Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 07/12] Traceprobes Mathieu Desnoyers
2008-07-07 16:28   ` Masami Hiramatsu
2008-07-04 23:52 ` [RFC patch 08/12] LTTng instrumentation FS tracepoint probes Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 09/12] LTTng instrumentation ipc " Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 10/12] LTTng instrumentation kernel " Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 11/12] LTTng instrumentation mm " Mathieu Desnoyers
2008-07-04 23:52 ` [RFC patch 12/12] LTTng instrumentation net " Mathieu Desnoyers
2008-07-05 23:27 ` [RFC patch 00/12] Tracepoints v2 Eduard - Gabriel Munteanu
2008-07-07 13:43   ` Mathieu Desnoyers

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=20080709030330.GB4378@Krystal \
    --to=mathieu.desnoyers@polymtl.ca \
    --cc=akpm@linux-foundation.org \
    --cc=fche@redhat.com \
    --cc=haoki@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=t-nishiie@np.css.fujitsu.com \
    --cc=viro@zeniv.linux.org.uk \
    /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