2011-04-25 07:31:01

by Mike Frysinger

[permalink] [raw]
Subject: [PATCH] freezer: use smp barriers

The freezer processes are dealing with multiple threads running
simultaneously, and on a UP system, the memory reads/writes do
not need barriers to keep things in sync. These are only needed
on SMP systems, so use SMP barriers instead.

Signed-off-by: Mike Frysinger <[email protected]>
---
kernel/freezer.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/freezer.c b/kernel/freezer.c
index 66ecd2e..7b01de9 100644
--- a/kernel/freezer.c
+++ b/kernel/freezer.c
@@ -17,7 +17,7 @@ static inline void frozen_process(void)
{
if (!unlikely(current->flags & PF_NOFREEZE)) {
current->flags |= PF_FROZEN;
- wmb();
+ smp_wmb();
}
clear_freeze_flag(current);
}
@@ -93,7 +93,7 @@ bool freeze_task(struct task_struct *p, bool sig_only)
* the task as frozen and next clears its TIF_FREEZE.
*/
if (!freezing(p)) {
- rmb();
+ smp_rmb();
if (frozen(p))
return false;

--
1.7.5.rc1


2011-04-25 08:38:36

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH] freezer: use smp barriers

On Mon 2011-04-25 03:31:05, Mike Frysinger wrote:
> The freezer processes are dealing with multiple threads running
> simultaneously, and on a UP system, the memory reads/writes do
> not need barriers to keep things in sync. These are only needed
> on SMP systems, so use SMP barriers instead.
>
> Signed-off-by: Mike Frysinger <[email protected]>

ACK.

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

2011-04-25 10:38:03

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] freezer: use smp barriers

On Monday, April 25, 2011, Mike Frysinger wrote:
> The freezer processes are dealing with multiple threads running
> simultaneously, and on a UP system, the memory reads/writes do
> not need barriers to keep things in sync. These are only needed
> on SMP systems, so use SMP barriers instead.
>
> Signed-off-by: Mike Frysinger <[email protected]>

Applied to suspend-2.6/linux-next.

Thanks,
Rafael


> ---
> kernel/freezer.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/freezer.c b/kernel/freezer.c
> index 66ecd2e..7b01de9 100644
> --- a/kernel/freezer.c
> +++ b/kernel/freezer.c
> @@ -17,7 +17,7 @@ static inline void frozen_process(void)
> {
> if (!unlikely(current->flags & PF_NOFREEZE)) {
> current->flags |= PF_FROZEN;
> - wmb();
> + smp_wmb();
> }
> clear_freeze_flag(current);
> }
> @@ -93,7 +93,7 @@ bool freeze_task(struct task_struct *p, bool sig_only)
> * the task as frozen and next clears its TIF_FREEZE.
> */
> if (!freezing(p)) {
> - rmb();
> + smp_rmb();
> if (frozen(p))
> return false;
>
>