Skip to contentSkip to conversation

oprofile: fix memory ordering

PATCH Applied Nick Piggin 2 participants 2 messages Oct 23, 2008 – Oct 27, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 oprofile: fix memory ordering

Regular bitops don't work as locks on all architectures.

Also: can use non-atomic unlock as no concurrent stores to the word.

---

drivers/oprofile/event_buffer.c +3 -3
Index: linux-2.6/drivers/oprofile/event_buffer.c
===================================================================
@@ -105,7 +105,7 @@ static int event_buffer_open(struct inod
 	if (!capable(CAP_SYS_ADMIN))
 		return -EPERM;
 
-	if (test_and_set_bit(0, &buffer_opened))
+	if (test_and_set_bit_lock(0, &buffer_opened))
 		return -EBUSY;
 
 	/* Register as a user of dcookies
@@ -129,7 +129,7 @@ static int event_buffer_open(struct inod
 fail:
 	dcookie_unregister(file->private_data);
 out:
-	clear_bit(0, &buffer_opened);
+	__clear_bit_unlock(0, &buffer_opened);
 	return err;
 }
 
@@ -141,7 +141,7 @@ static int event_buffer_release(struct i
 	dcookie_unregister(file->private_data);
 	buffer_pos = 0;
 	atomic_set(&buffer_ready, 0);
-	clear_bit(0, &buffer_opened);
+	__clear_bit_unlock(0, &buffer_opened);
 	return 0;
 }
 
#1 lore raw
Quoted 5 lines · Nick Piggin

Regular bitops don't work as locks on all architectures.

Also: can use non-atomic unlock as no concurrent stores to the word.

I applied your patch to oprofile/oprofile-for-tip. Thanks Nick.

-Robert

Signature · 3 lines
Advanced Micro Devices, Inc.
Operating System Research Center
email: [email protected]