Messages in this thread Patch in this message | | | From | David Howells <> | Subject | Re: [PATCH] slow_work_thread() should do the exclusive wait | Date | Thu, 23 Apr 2009 17:00:35 +0100 |
| |
Andrew Morton <akpm@linux-foundation.org> wrote:
> I wonder if slow_work_cull_timeout() should have some sort of barrier, > so the write is suitably visible to the woken thread. Bearing in mind > that the thread might _already_ have been woken by someone else?
Perhaps the attached patch?
David --- From: David Howells <dhowells@redhat.com> Subject: [PATCH] slow_work_cull_timeout() should have a memory barrier
slow_work_cull_timeout() should have a write memory barrier so that the setting of the cull flag is seen before the wakeup takes place. This is required because wake_up() does not guarantee any memory barriership at all.
Concomitant to this, slow_work_thread() should have a read memory barrier between its return from schedule() and its testing of slow_work_cull() as finish_wait() isn't a guaranteed barrier either.
Signed-off-by: David Howells <dhowells@redhat.com> ---
kernel/slow-work.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/kernel/slow-work.c b/kernel/slow-work.c index 521ed20..96e418d 100644 --- a/kernel/slow-work.c +++ b/kernel/slow-work.c @@ -382,6 +382,7 @@ static int slow_work_thread(void *_data) finish_wait(&slow_work_thread_wq, &wait); try_to_freeze(); + smp_rmb(); vsmax = vslow_work_proportion; vsmax *= atomic_read(&slow_work_thread_count); @@ -416,6 +417,7 @@ static int slow_work_thread(void *_data) static void slow_work_cull_timeout(unsigned long data) { slow_work_cull = true; + smp_wmb(); wake_up(&slow_work_thread_wq); }
| |