All of lore.kernel.org
 help / color / mirror / Atom feed
From: Santosh Shilimkar <santosh.shilimkar@ti.com>
To: Will Deacon <will.deacon@arm.com>,
	linux-kernel@vger.kernel.org, oprofile-list@lists.sf.net
Cc: Robert Richter <robert.richter@amd.com>
Subject: RE: [PATCH v2] oprofile: add SMP barriers for hrtimer hotplug code
Date: Tue, 1 Feb 2011 10:57:32 +0530	[thread overview]
Message-ID: <1db705ac90529708ef559eee9708b648@mail.gmail.com> (raw)
In-Reply-To: <1296496389-30647-1-git-send-email-will.deacon@arm.com>

> -----Original Message-----
> From: Will Deacon [mailto:will.deacon@arm.com]
> Sent: Monday, January 31, 2011 11:23 PM
> To: linux-kernel@vger.kernel.org; oprofile-list@lists.sf.net
> Cc: Will Deacon; Santosh Shilimkar; Robert Richter
> Subject: [PATCH v2] oprofile: add SMP barriers for hrtimer hotplug
> code
>
> OProfile uses a CPU notifier to start and stop any hrtimers when
> CPUs change
> between ONLINE and DEAD. A static int ctr_running is used to keep
> track of
> the counter state.
>
> This can lead to problems where writes to the state variable are re-
> ordered
> with repect to reads of the variable occurring on other CPUs,
> meaning that
> __oprofile_hrtimer_start may read ctr_running as 0 and not
> initialise the
> hrtimer. Potential deadlock can occur in __oprofile_hrtimer_stop
> because
> lock_hrtimer_base will poll until timer->base != NULL, which will
> never
> happen.
>
> This patch adds an smp_mb() before initialising the hrtimers to
> ensure that
> ctr_running mirrors the correct counter state.
>
> Cc: Santosh Shilimkar <santosh.shilimkar@ti.com>
> Cc: Robert Richter <robert.richter@amd.com>
> Signed-off-by: Will Deacon <will.deacon@arm.com>
> ---
>
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>

> Changes since v1: Removed redundant barrier from stop() code.
>
>  drivers/oprofile/timer_int.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/oprofile/timer_int.c
> b/drivers/oprofile/timer_int.c
> index 0107251..a3a94ea 100644
> --- a/drivers/oprofile/timer_int.c
> +++ b/drivers/oprofile/timer_int.c
> @@ -48,6 +48,7 @@ static int oprofile_hrtimer_start(void)
>  {
>  	get_online_cpus();
>  	ctr_running = 1;
> +	smp_mb();
>  	on_each_cpu(__oprofile_hrtimer_start, NULL, 1);
>  	put_online_cpus();
>  	return 0;
> --
> 1.7.0.4
>

  reply	other threads:[~2011-02-01  5:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-31 17:53 [PATCH v2] oprofile: add SMP barriers for hrtimer hotplug code Will Deacon
2011-02-01  5:27 ` Santosh Shilimkar [this message]
2011-02-01  8:03   ` Ming Lei
2011-02-01 17:08     ` Will Deacon

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=1db705ac90529708ef559eee9708b648@mail.gmail.com \
    --to=santosh.shilimkar@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oprofile-list@lists.sf.net \
    --cc=robert.richter@amd.com \
    --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 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.