提交 fce8c41c 编写于 作者: J Jeff Dike 提交者: Linus Torvalds

uml: use barrier() instead of mb()

signals_enabled and pending have requirements on the order in which they are
modified.  This used to be done by declaring them volatile and putting an mb()
where the ordering requirements were in effect.

After getting a better (I hope) understanding of how to do this correctly, the
volatile declarations are gone and the mb()'s replaced by barrier()'s.

One of the mb()'s was deleted because I see no problematic writes that could
be re-ordered past that point.
Signed-off-by: NJeff Dike <jdike@linux.intel.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 0983a88b
...@@ -15,6 +15,9 @@ ...@@ -15,6 +15,9 @@
#include "sysdep/sigcontext.h" #include "sysdep/sigcontext.h"
#include "user.h" #include "user.h"
/* Copied from linux/compiler-gcc.h since we can't include it directly */
#define barrier() __asm__ __volatile__("": : :"memory")
/* /*
* These are the asynchronous signals. SIGPROF is excluded because we want to * These are the asynchronous signals. SIGPROF is excluded because we want to
* be able to profile all of UML, not just the non-critical sections. If * be able to profile all of UML, not just the non-critical sections. If
...@@ -27,13 +30,8 @@ ...@@ -27,13 +30,8 @@
#define SIGVTALRM_BIT 1 #define SIGVTALRM_BIT 1
#define SIGVTALRM_MASK (1 << SIGVTALRM_BIT) #define SIGVTALRM_MASK (1 << SIGVTALRM_BIT)
/* static int signals_enabled;
* These are used by both the signal handlers and static unsigned int pending;
* block/unblock_signals. I don't want modifications cached in a
* register - they must go straight to memory.
*/
static volatile int signals_enabled = 1;
static volatile int pending = 0;
void sig_handler(int sig, struct sigcontext *sc) void sig_handler(int sig, struct sigcontext *sc)
{ {
...@@ -198,7 +196,7 @@ void block_signals(void) ...@@ -198,7 +196,7 @@ void block_signals(void)
* This might matter if gcc figures out how to inline this and * This might matter if gcc figures out how to inline this and
* decides to shuffle this code into the caller. * decides to shuffle this code into the caller.
*/ */
mb(); barrier();
} }
void unblock_signals(void) void unblock_signals(void)
...@@ -224,21 +222,11 @@ void unblock_signals(void) ...@@ -224,21 +222,11 @@ void unblock_signals(void)
* Setting signals_enabled and reading pending must * Setting signals_enabled and reading pending must
* happen in this order. * happen in this order.
*/ */
mb(); barrier();
save_pending = pending; save_pending = pending;
if (save_pending == 0) { if (save_pending == 0)
/*
* This must return with signals enabled, so
* this barrier ensures that writes are
* flushed out before the return. This might
* matter if gcc figures out how to inline
* this (unlikely, given its size) and decides
* to shuffle this code into the caller.
*/
mb();
return; return;
}
pending = 0; pending = 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册