public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Stephane Eranian <eranian@google.com>,
	Will Deacon <will.deacon@arm.com>,
	Paul Mundt <lethal@linux-sh.org>,
	David Miller <davem@davemloft.net>,
	Borislav Petkov <bp@amd64.org>
Subject: Re: [RFC PATCH 5/6] perf: Fix race in callchains
Date: Thu, 1 Jul 2010 17:42:36 +0200	[thread overview]
Message-ID: <20100701154232.GA10616@nowhere> (raw)
In-Reply-To: <1277998562-21366-6-git-send-regression-fweisbec@gmail.com>

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;
> +}


  reply	other threads:[~2010-07-01 15:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-01 15:35 [RFC PATCH 0/6] perf: cleanup and fixes Frederic Weisbecker
2010-07-01 15:35 ` [RFC PATCH 1/6] perf: Drop unappropriate tests on arch callchains Frederic Weisbecker
2010-07-01 15:35 ` [RFC PATCH 2/6] perf: Generalize callchain_store() Frederic Weisbecker
2010-07-01 15:35 ` [RFC PATCH 3/6] perf: Generalize some arch callchain code Frederic Weisbecker
2010-07-01 15:46   ` Peter Zijlstra
2010-07-01 15:47     ` Frederic Weisbecker
2010-07-01 15:49     ` Frederic Weisbecker
2010-07-01 15:51       ` Peter Zijlstra
2010-07-01 15:53         ` Frederic Weisbecker
2010-07-01 15:36 ` [RFC PATCH 4/6] perf: Factorize callchain context handling Frederic Weisbecker
2010-07-01 15:36 ` [RFC PATCH 5/6] perf: Fix race in callchains Frederic Weisbecker
2010-07-01 15:42   ` Frederic Weisbecker [this message]
2010-07-02 18:07   ` Peter Zijlstra
2010-07-03 20:28     ` Frederic Weisbecker
2010-07-01 15:36 ` [RFC PATCH 6/6] perf: Fix double put_ctx Frederic Weisbecker
  -- strict thread matches above, loose matches on Subject: below --
2010-08-16 20:48 [RFC PATCH 0/0 v3] callchain fixes and cleanups Frederic Weisbecker
2010-08-16 20:48 ` [RFC PATCH 5/6] perf: Fix race in callchains Frederic Weisbecker

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=20100701154232.GA10616@nowhere \
    --to=fweisbec@gmail.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=bp@amd64.org \
    --cc=davem@davemloft.net \
    --cc=eranian@google.com \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=paulus@samba.org \
    --cc=will.deacon@arm.com \
    /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