lkml.org 
[lkml]   [2011]   [Oct]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] CPU hotplug, freezer: Fix bugs in CPU hotplug call path
From
Date
On Tue, 2011-10-04 at 18:58 +0530, Srivatsa S. Bhat wrote:
> +static int tasks_frozen;
> +
> +void set_tasks_frozen_flag(void)
> +{
> + tasks_frozen = 1;
> + smp_mb();
> +}
> +
> +void clear_tasks_frozen_flag(void)
> +{
> + tasks_frozen = 0;
> + smp_mb();
> +}
> +
> +int tasks_are_frozen(void)
> +{
> + return tasks_frozen;
> +}

See Documentation/memory-barriers.txt, memory barriers always come in
pairs, furthermore memory barriers always should have a comment
explaining the ordering and referring to the pair match.

I think you want at least an smp_rmb() before reading tasks_frozen,
possible you also want to use ACCESS_ONCE() to force the compiler to
emit the read.

Furthermore, do you really need this? isn't it both set and read from
the same task context, all under pm_mutex?


\
 
 \ /
  Last update: 2011-10-04 15:41    [W:0.091 / U:0.940 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site