Re: [PATCH] tracing: Move tracepoint callbacks into DEFINE

From: Jason Baron
Date: Wed Aug 19 2009 - 12:14:48 EST


On Tue, Aug 18, 2009 at 12:23:47AM -0700, Josh Stone wrote:
> --- a/kernel/tracepoint.c
> +++ b/kernel/tracepoint.c
> @@ -243,6 +243,11 @@ static void set_tracepoint(struct tracepoint_entry **entry,
> {
> WARN_ON(strcmp((*entry)->name, elem->name) != 0);
>
> + if (elem->regfunc && !elem->state && active)
> + elem->regfunc();
> + else if (elem->unregfunc && elem->state && !active)
> + elem->unregfunc();
> +
> /*
> * rcu_assign_pointer has a smp_wmb() which makes sure that the new
> * probe callbacks array is consistent before setting a pointer to it.
> @@ -262,6 +267,9 @@ static void set_tracepoint(struct tracepoint_entry **entry,
> */
> static void disable_tracepoint(struct tracepoint *elem)
> {
> + if (elem->unregfunc && elem->state)
> + elem->unregfunc();
> +
> elem->state = 0;
> rcu_assign_pointer(elem->funcs, NULL);
> }
> @@ -581,15 +589,13 @@ __initcall(init_tracepoints);
>
> #ifdef CONFIG_FTRACE_SYSCALLS
>
> -static DEFINE_MUTEX(regfunc_mutex);
> -static int sys_tracepoint_refcount;
> +static int sys_tracepoint_refcount; /* guarded by tracepoints_mutex */
>
> void syscall_regfunc(void)
> {
> unsigned long flags;
> struct task_struct *g, *t;
>
> - mutex_lock(&regfunc_mutex);
> if (!sys_tracepoint_refcount) {
> read_lock_irqsave(&tasklist_lock, flags);
> do_each_thread(g, t) {
> @@ -598,7 +604,6 @@ void syscall_regfunc(void)
> read_unlock_irqrestore(&tasklist_lock, flags);
> }
> sys_tracepoint_refcount++;
> - mutex_unlock(&regfunc_mutex);
> }
>
> void syscall_unregfunc(void)
> @@ -606,7 +611,6 @@ void syscall_unregfunc(void)
> unsigned long flags;
> struct task_struct *g, *t;
>
> - mutex_lock(&regfunc_mutex);
> sys_tracepoint_refcount--;
> if (!sys_tracepoint_refcount) {
> read_lock_irqsave(&tasklist_lock, flags);
> @@ -615,6 +619,5 @@ void syscall_unregfunc(void)
> } while_each_thread(g, t);
> read_unlock_irqrestore(&tasklist_lock, flags);
> }
> - mutex_unlock(&regfunc_mutex);
> }
> #endif

if we disable, CONFIG_FTRACE_SYSCALLS, then we get undefined references
to syscall_regfunc, and syscall_unregfunc. So, i think we just need to
remove the 'CONFIG_FTRACE_SYSCALLS' ifdef here.

thanks,

-Jason
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/