[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [RFC v3 03/19] translate-all: add DEBUG_LOCKING asserts
From: |
Alex Bennée |
Subject: |
Re: [Qemu-devel] [RFC v3 03/19] translate-all: add DEBUG_LOCKING asserts |
Date: |
Thu, 23 Jun 2016 18:14:27 +0100 |
User-agent: |
mu4e 0.9.17; emacs 25.0.95.3 |
Sergey Fedorov <address@hidden> writes:
> On 03/06/16 23:40, Alex Bennée wrote:
>> diff --git a/translate-all.c b/translate-all.c
>> index ec6fdbb..e3f44d9 100644
>> --- a/translate-all.c
>> +++ b/translate-all.c
> (snip)
>> @@ -60,6 +61,7 @@
>>
>> /* #define DEBUG_TB_INVALIDATE */
>> /* #define DEBUG_TB_FLUSH */
>> +/* #define DEBUG_LOCKING */
>
> A bit of bikeshedding: have you considered naming it 'DEBUG_LOCKS'. How
> does it sound for a native English speaker? :)
>
>> /* make various TB consistency checks */
>> /* #define DEBUG_TB_CHECK */
>>
>> @@ -68,6 +70,28 @@
>> #undef DEBUG_TB_CHECK
>> #endif
>>
>> +/* Access to the various translations structures need to be serialised via
>> locks
>> + * for consistency. This is automatic for SoftMMU based system
>> + * emulation due to its single threaded nature. In user-mode emulation
>> + * access to the memory related structures are protected with the
>> + * mmap_lock.
>> + */
>> +#ifdef DEBUG_LOCKING
>> +#define DEBUG_MEM_LOCKS 1
>> +#else
>> +#define DEBUG_MEM_LOCKS 0
>> +#endif
>> +
>> +#ifdef CONFIG_SOFTMMU
>> +#define assert_memory_lock() do { /* nothing */ } while (0)
>> +#else
>> +#define assert_memory_lock() do { \
>> + if (DEBUG_MEM_LOCKS) { \
>> + g_assert(have_mmap_lock()); \
>> + } \
>> + } while (0)
>> +#endif
>> +
>
> Why not simply:
>
> #if !defined(DEBUG_LOCKING) || defined(CONFIG_SOFTMMU)
> # define assert_memory_lock() do { /* nothing */ } while (0)
> #else
> # define assert_memory_lock() g_assert(have_mmap_lock())
> #endif
>
> One more nit: maybe it would be a bit more clear to name it after the
> lock name, i.e. assert_mmap_lock(), or check_mmap_lock(), or
> debug_mmap_lock() etc?
Yes I can do it that way around. The if (FOO) form makes more sense for
debug output to ensure the compiler checks format strings etc. The
resulting code should be the same either way.
>
> Thanks,
> Sergey
--
Alex Bennée
- [Qemu-devel] [RFC v3 00/19] Base enabling patches for MTTCG, Alex Bennée, 2016/06/03
- [Qemu-devel] [RFC v3 05/19] exec: add assert_debug_safe and notes on debug structures, Alex Bennée, 2016/06/03
- [Qemu-devel] [RFC v3 06/19] tcg: comment on which functions have to be called with tb_lock held, Alex Bennée, 2016/06/03
- [Qemu-devel] [RFC v3 04/19] docs: new design document multi-thread-tcg.txt (DRAFTING), Alex Bennée, 2016/06/03
- [Qemu-devel] [RFC v3 07/19] translate-all: Add assert_memory_lock annotations, Alex Bennée, 2016/06/03
- [Qemu-devel] [RFC v3 12/19] tcg: add kick timer for single-threaded vCPU emulation, Alex Bennée, 2016/06/03