Re: [PATCH 2/2] tracing: Allocate the ftrace event profile bufferdynamically

From: Frederic Weisbecker
Date: Fri Sep 18 2009 - 00:32:00 EST


On Fri, Sep 18, 2009 at 06:24:14AM +0200, Frederic Weisbecker wrote:
> static void prof_syscall_enter(struct pt_regs *regs, long id)
> {
> - struct syscall_trace_enter *rec;
> struct syscall_metadata *sys_data;
> + struct syscall_trace_enter *rec;
> + char *raw_data;
> int syscall_nr;
> int size;
> + int cpu;
>
> syscall_nr = syscall_get_nr(current, regs);
> if (!test_bit(syscall_nr, enabled_prof_enter_syscalls))
> @@ -402,20 +404,39 @@ static void prof_syscall_enter(struct pt_regs *regs, long id)
> size = ALIGN(size + sizeof(u32), sizeof(u64));
> size -= sizeof(u32);
>
> - do {
> - char raw_data[size];
> + if (WARN_ONCE(size > FTRACE_MAX_PROFILE_SIZE,
> + "profile buffer not large enough"))
> + return;
> +
> + /*
> + * We are not in nmi. Also we can't be preempted by a sysenter event
> + * from interrupt, so we can safely take this buffer without
> + * masking interrupts. But we still need rcu_read_lock to protect
> + * against concurrent buffer release.
> + */
> + rcu_read_lock();



Oh...now that we use a global buffer, the buffer is not safe anymore against
interrupts or NMIs.

Looks like I will need a third iteration.

Sorry for the noise...

--
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/