[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100701154232.GA10616@nowhere>
Date: Thu, 1 Jul 2010 17:42:36 +0200
From: Frederic Weisbecker <fweisbec@...il.com>
To: LKML <linux-kernel@...r.kernel.org>
Cc: Ingo Molnar <mingo@...e.hu>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
Paul Mackerras <paulus@...ba.org>,
Stephane Eranian <eranian@...gle.com>,
Will Deacon <will.deacon@....com>,
Paul Mundt <lethal@...ux-sh.org>,
David Miller <davem@...emloft.net>,
Borislav Petkov <bp@...64.org>
Subject: Re: [RFC PATCH 5/6] perf: Fix race in callchains
On Thu, Jul 01, 2010 at 05:36:01PM +0200, Frederic Weisbecker wrote:
> +static struct perf_callchain_entry *get_callchain_entry(int *rctx)
> +{
> + struct perf_callchain_entry_cpus *cpu_entries;
> +
> + *rctx = get_recursion_context(&__get_cpu_var(callchain_recursion));
> + if (*rctx == -1)
> + return NULL;
> +
> + cpu_entries = rcu_dereference(callchain_entries[*rctx]);
> + if (!cpu_entries)
> + return NULL;
> +
> + return this_cpu_ptr(cpu_entries->entries);
> +}
> +
> +static void
> +put_callchain_entry(int rctx)
> +{
> + put_recursion_context(&__get_cpu_var(callchain_recursion), rctx);
> +}
> +
> +static struct perf_callchain_entry *perf_callchain(struct pt_regs *regs)
> +{
> + int rctx;
> + struct perf_callchain_entry *entry;
> +
> +
> + entry = get_callchain_entry(&rctx);
> + if (!entry)
> + goto exit_put;
I realize this should only call put_callchain_entry() if rctx == -1, but you
got the idea...
> +
> + entry->nr = 0;
> +
> + if (!user_mode(regs)) {
> + perf_callchain_store(entry, PERF_CONTEXT_KERNEL);
> + perf_callchain_kernel(entry, regs);
> + if (current->mm)
> + regs = task_pt_regs(current);
> + else
> + regs = NULL;
> + }
> +
> + if (regs) {
> + perf_callchain_store(entry, PERF_CONTEXT_USER);
> + perf_callchain_user(entry, regs);
> + }
> +
> +exit_put:
> + put_callchain_entry(rctx);
> +
> + return entry;
> +}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists