[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 5/6] tcg: introduce tb_lock_recursive()
From: |
Alex Bennée |
Subject: |
[Qemu-devel] [PATCH v2 5/6] tcg: introduce tb_lock_recursive() |
Date: |
Tue, 5 Jul 2016 17:18:15 +0100 |
In some cases it is useful to have a recursive lock that can be safely
taken when nested in other critical regions. Rather than make all
tb_locks() recursive having a separate function serves to notify the
reader that it explicitly a possibility in this case.
Signed-off-by: Alex Bennée <address@hidden>
---
tcg/tcg.h | 1 +
translate-all.c | 11 +++++++++++
2 files changed, 12 insertions(+)
diff --git a/tcg/tcg.h b/tcg/tcg.h
index 66d7fc0..62e4ced 100644
--- a/tcg/tcg.h
+++ b/tcg/tcg.h
@@ -647,6 +647,7 @@ void tcg_pool_reset(TCGContext *s);
void tcg_pool_delete(TCGContext *s);
void tb_lock(void);
+bool tb_lock_recursive(void);
void tb_unlock(void);
void tb_lock_reset(void);
diff --git a/translate-all.c b/translate-all.c
index 97e834a..414bc7e 100644
--- a/translate-all.c
+++ b/translate-all.c
@@ -134,6 +134,17 @@ void tb_lock(void)
#endif
}
+bool tb_lock_recursive(void)
+{
+#ifdef CONFIG_USER_ONLY
+ if (have_tb_lock) {
+ return false;
+ }
+ tb_lock();
+#endif
+ return true;
+}
+
void tb_unlock(void)
{
#ifdef CONFIG_USER_ONLY
--
2.7.4
[Qemu-devel] [PATCH v2 6/6] tcg: cpu-exec: roll-up tb_find_fast/slow, Alex Bennée, 2016/07/05