public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] slow_work_execute() needs mb() before test_bit(SLOW_WORK_PENDING)
@ 2009-04-13 20:13 Oleg Nesterov
  2009-04-13 20:13 ` Oleg Nesterov
  0 siblings, 1 reply; 6+ messages in thread
From: Oleg Nesterov @ 2009-04-13 20:13 UTC (permalink / raw)
  To: Andrew Morton, David Howells, David Miller
  Cc: Serge Hallyn, Steve Dickson, Trond Myklebust, Al Viro,
	Daire Byrne, linux-kernel

slow_work_execute:

	clear_bit_unlock(SLOW_WORK_EXECUTING, &work->flags);

	if (test_bit(SLOW_WORK_PENDING, &work->flags) {

clear_bit_unlock() implies release semantics, iow we have a one-way barrier
before clear_bit(). But we need the mb() semantics after clear_bit(), before
we test SLOW_WORK_PENDING. Otherwise we can miss SLOW_WORK_ENQ_DEFERRED if
we race slow_work_enqueue().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>

--- 6.30/kernel/slow-work.c~2_BITS_MB	2009-04-13 19:40:20.000000000 +0200
+++ 6.30/kernel/slow-work.c	2009-04-13 21:19:33.000000000 +0200
@@ -198,7 +198,8 @@ static bool slow_work_execute(void)
 
 	if (very_slow)
 		atomic_dec(&vslow_work_executing_count);
-	clear_bit_unlock(SLOW_WORK_EXECUTING, &work->flags);
+	clear_bit(SLOW_WORK_EXECUTING, &work->flags);
+	smp_mb__after_clear_bit();
 
 	/* if someone tried to enqueue the item whilst we were executing it,
 	 * then it'll be left unenqueued to avoid multiple threads trying to


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-04-16 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-13 20:13 [PATCH] slow_work_execute() needs mb() before test_bit(SLOW_WORK_PENDING) Oleg Nesterov
2009-04-13 20:13 ` Oleg Nesterov
2009-04-13 21:47   ` David Howells
2009-04-13 22:02     ` Oleg Nesterov
2009-04-16  9:43       ` David Howells
2009-04-16 14:15         ` Oleg Nesterov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox