All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
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, 08 Jul 2008 16:37:45 -0400	[thread overview]
Message-ID: <4873D019.4090504@redhat.com> (raw)
In-Reply-To: <487243EC.1010704@redhat.com>

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.

Thank you,
-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


  reply	other threads:[~2008-07-08 20:40 UTC|newest]

Thread overview: 30+ 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 [this message]
2008-07-09  3:03       ` Mathieu Desnoyers
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-04 23:52   ` Mathieu Desnoyers
2008-07-05  9:42   ` KOSAKI Motohiro
2008-07-05  9:42     ` KOSAKI Motohiro
2008-07-07 20:38     ` Mathieu Desnoyers
2008-07-07 20:38       ` Mathieu Desnoyers
2008-07-11  8:36       ` KOSAKI Motohiro
2008-07-11  8:36         ` KOSAKI Motohiro
2008-07-11 14:17         ` Mathieu Desnoyers
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   ` 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=4873D019.4090504@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=fche@redhat.com \
    --cc=haoki@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.